Support Picture in Picture on Oreo+
This commit is contained in:
parent
2e9b76ce3b
commit
26127f3b96
2 changed files with 18 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:fullBackupContent="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
@ -23,7 +24,9 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".PlayerActivity"
|
||||
android:configChanges="orientation|screenSize"/>
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
tools:targetApi="n" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,8 +1,12 @@
|
|||
package net.theoks.customstreams.android
|
||||
|
||||
import android.app.PictureInPictureParams
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Rational
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer
|
||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource
|
||||
|
@ -43,4 +47,14 @@ class PlayerActivity : AppCompatActivity() {
|
|||
}
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onUserLeaveHint() {
|
||||
if(player.isPlaying) {
|
||||
val paramsBuilder = PictureInPictureParams.Builder()
|
||||
paramsBuilder.setAspectRatio(Rational(16, 9))
|
||||
enterPictureInPictureMode(paramsBuilder.build())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue