mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Fixed FCast Android full-screen and pause/resume behaviour when going to background.
This commit is contained in:
parent
e38dd7dedb
commit
3621794a3d
4 changed files with 22 additions and 3 deletions
2
clients/terminal/Cargo.lock
generated
2
clients/terminal/Cargo.lock
generated
|
@ -66,7 +66,7 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastcast"
|
||||
name = "fcast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
android:theme="@style/Theme.Main"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -32,7 +32,7 @@
|
|||
<activity
|
||||
android:name=".PlayerActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
android:theme="@style/Theme.Player" />
|
||||
|
||||
<receiver
|
||||
android:name=".BootReceiver"
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context
|
|||
import android.net.*
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.exoplayer2.*
|
||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||
|
@ -23,6 +25,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||
private var _shouldPlaybackRestartOnConnectivity: Boolean = false
|
||||
private lateinit var _connectivityManager: ConnectivityManager
|
||||
private lateinit var _scope: CoroutineScope
|
||||
private var _wasPlaying = false;
|
||||
|
||||
val currentPosition get() = _exoPlayer.currentPosition
|
||||
val isPlaying get() = _exoPlayer.isPlaying
|
||||
|
@ -137,6 +140,20 @@ class PlayerActivity : AppCompatActivity() {
|
|||
TcpListenerService.activityCount++
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
|
||||
_wasPlaying = _exoPlayer.isPlaying
|
||||
_exoPlayer.pause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (_wasPlaying) {
|
||||
_exoPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Log.i(TAG, "onDestroy")
|
||||
|
@ -186,6 +203,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||
_exoPlayer.seekTo(playMessage.time * 1000)
|
||||
}
|
||||
|
||||
_wasPlaying = false
|
||||
_exoPlayer.playWhenReady = true
|
||||
_exoPlayer.prepare()
|
||||
_exoPlayer.play()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="Theme.Player" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Main" parent="Theme.AppCompat.NoActionBar">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue