๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[Sample] PictureInPictureKotlin ์ฝ”๋“œ ์‚ดํ”ผ๊ธฐ - 1

์ƒ˜ํ”Œ ์ฝ”๋“œ ํ”„๋กœ์ ํŠธ

https://github.com/android/media-samples/tree/main/PictureInPictureKotlin

 

media-samples/PictureInPictureKotlin at main · android/media-samples

Multiple samples showing the best practices in media APIs on Android (audio, video, etc.). - android/media-samples

github.com

 

 

AndroidManifest.xml ์‚ดํ”ผ๊ธฐ

1) android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

2) android:supportsPictureInPicture="true"

<manifest
	...
    >

    <application
        ... 
        >

        <activity
            android:name=".MovieActivity"
            android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
            android:supportsPictureInPicture="true" />

    </application>

</manifest>


์ฐธ๊ณ 

https://developer.android.com/develop/ui/views/picture-in-picture#declaring

 

PIP ๋ชจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋™์˜์ƒ ์ถ”๊ฐ€  |  Views  |  Android Developers

Android 8.0์—์„œ๋Š” ํ™œ๋™์„ PIP ๋ชจ๋“œ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

developer.android.com

 

์•ฑ์—์„œ PiP๋ฅผ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•ด AndroidManifest์— PiP ๋Œ€์ƒ ์•กํ‹ฐ๋น„ํ‹ฐ์— android:supportsPictureInPicture ๋ฅผ true๋กœ ์„ค์ •ํ•œ๋‹ค. configuration ๋ณ€๊ฒฝ์‹œ ์•กํ‹ฐ๋น„ํ‹ฐ์˜ ์žฌ์‹คํ–‰์„ ๋ง‰๊ธฐ ์œ„ํ•ด andoird:configChanges ๊ฐ’๋„ ์„ค์ •ํ•œ๋‹ค.

 

 

์ฐธ๊ณ 

https://developer.android.com/guide/topics/manifest/activity-element

 

<activity>  |  Android Developers

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์‹œ๊ฐ์  ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค ์ผ๋ถ€๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ํ™œ๋™(Activity ์„œ๋ธŒํด๋ž˜์Šค)์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ํ™œ๋™์€ ๋งค๋‹ˆํŽ˜์ŠคํŠธ ํŒŒ์ผ์˜ {@code } ์š”์†Œ๋กœ ๋‚˜ํƒ€๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์— ์„ ์–ธ๋˜์ง€ ์•Š์€ ํ™œ๋™

developer.android.com

android:configChanges ์— ์ง€์ •ํ•œ configuration ๋ณ€๊ฒฝ์ด ๋ฐœ์ƒํ•  ๊ฒฝ์šฐ, ์•กํ‹ฐ๋น„ํ‹ฐ๋Š” ์žฌ์‹คํ–‰๋˜์ง€ ์•Š๊ณ , activity์˜ onConfigurationChanged()๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค. ๋‹ค์ˆ˜์˜ configuration ๊ฐ’์„ ์„ค์ •ํ•  ๊ฒฝ์šฐ, "|"๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.

์˜ˆ: android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

 

์ƒ˜ํ”Œ ์ฝ”๋“œ์— ๋‚˜์˜จ configuration ๊ฐ’๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • screenSize : ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ™”๋ฉด ํฌ๊ธฐ์˜ ๋ณ€๊ฒฝ. ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ™”๋ฉด์˜ ๊ฐ€๋กœ ์„ธ๋กœ ๋น„์œจ์ด ๋ณ€๊ฒฝ๋œ ๊ฒƒ.
  • smallestScreenSize : ๋ฌผ๋ฆฌ์ ์ธ ๋””์Šคํ”Œ๋ ˆ์ด ํ™”๋ฉด์˜ ๋ณ€๊ฒฝ. 
  • screenLayout : ํ™”๋ฉด ๋ ˆ์ด์•„์›ƒ์˜ ๋ณ€๊ฒฝ. ๋‹ค๋ฅธ ๋””์Šคํ”Œ๋ ˆ์ด ํ™”๋ฉด์ด ํ™œ์„ฑํ™” ๋˜๋Š” ๊ฒƒ.
  • orientation : ํ™”๋ฉด ๋ฐฉํ–ฅ์˜ ๋ณ€๊ฒฝ. ์‚ฌ์šฉ์ž๊ฐ€ ๊ธฐ๊ธฐ๋ฅผ ํšŒ์ „ํ•˜๋Š” ๊ฒƒ. ์•ฑ์ด Android 3.2(API level 13) ์ด์ƒ์„ ํƒ€๊ฒŒํŒ…ํ•  ๋•Œ, screenSize์™€ screenLayout๋„ ๊ฐ™์ด ์„ค์ •ํ•ด์•ผํ•œ๋‹ค. ํ™”๋ฉด์˜ ๊ฐ€๋กœ, ์„ธ๋กœ ๋ฐฉํ–ฅ์ด ๋ณ€ํ•˜๋ฉด์„œ ํ™”๋ฉด ํฌ๊ธฐ์™€ ๋ ˆ์ด์•„์›ƒ๋„ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.