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]]
|
[[package]]
|
||||||
name = "fastcast"
|
name = "fcast"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
android:theme="@style/Theme.Main"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".PlayerActivity"
|
android:name=".PlayerActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
android:theme="@style/Theme.Player" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".BootReceiver"
|
android:name=".BootReceiver"
|
||||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context
|
||||||
import android.net.*
|
import android.net.*
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.Window
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.google.android.exoplayer2.*
|
import com.google.android.exoplayer2.*
|
||||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||||
|
@ -23,6 +25,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
private var _shouldPlaybackRestartOnConnectivity: Boolean = false
|
private var _shouldPlaybackRestartOnConnectivity: Boolean = false
|
||||||
private lateinit var _connectivityManager: ConnectivityManager
|
private lateinit var _connectivityManager: ConnectivityManager
|
||||||
private lateinit var _scope: CoroutineScope
|
private lateinit var _scope: CoroutineScope
|
||||||
|
private var _wasPlaying = false;
|
||||||
|
|
||||||
val currentPosition get() = _exoPlayer.currentPosition
|
val currentPosition get() = _exoPlayer.currentPosition
|
||||||
val isPlaying get() = _exoPlayer.isPlaying
|
val isPlaying get() = _exoPlayer.isPlaying
|
||||||
|
@ -137,6 +140,20 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
TcpListenerService.activityCount++
|
TcpListenerService.activityCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
|
||||||
|
_wasPlaying = _exoPlayer.isPlaying
|
||||||
|
_exoPlayer.pause()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
if (_wasPlaying) {
|
||||||
|
_exoPlayer.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
Log.i(TAG, "onDestroy")
|
Log.i(TAG, "onDestroy")
|
||||||
|
@ -186,6 +203,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
_exoPlayer.seekTo(playMessage.time * 1000)
|
_exoPlayer.seekTo(playMessage.time * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_wasPlaying = false
|
||||||
_exoPlayer.playWhenReady = true
|
_exoPlayer.playWhenReady = true
|
||||||
_exoPlayer.prepare()
|
_exoPlayer.prepare()
|
||||||
_exoPlayer.play()
|
_exoPlayer.play()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<style name="Theme.Player" parent="Theme.AppCompat.NoActionBar">
|
<style name="Theme.Player" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="android:windowFullscreen">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Main" parent="Theme.AppCompat.NoActionBar">
|
<style name="Theme.Main" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue