Commit 22b9e837 authored by Geoffrey Métais's avatar Geoffrey Métais

Use cached state for isPlaying() value

parent 572f1b38
......@@ -28,7 +28,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
var pausable = false
var previousMediaStats: Media.Stats? = null
private set
var playbackState = PlaybackStateCompat.STATE_STOPPED
@Volatile var playbackState = PlaybackStateCompat.STATE_STOPPED
private set
fun getVout() = mediaplayer.vlcVout
......@@ -90,7 +90,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
if (seekable) mediaplayer.time = time
}
fun isPlaying() = mediaplayer.isPlaying
fun isPlaying() = playbackState == PlaybackStateCompat.STATE_PLAYING
fun isVideoPlaying() = mediaplayer.vlcVout.areViewsAttached()
......@@ -154,6 +154,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
player.setVideoTrackEnabled(false)
if (isVideoPlaying()) player.vlcVout.detachViews()
launch(playerContext) { player.release() }
playbackState = PlaybackStateCompat.STATE_STOPPED
}
fun setSlaves(media: MediaWrapper) = launch {
......@@ -161,7 +162,6 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
for (slave in list) mediaplayer.addSlave(slave.type, Uri.parse(slave.uri), false)
}
private fun newMediaPlayer() : MediaPlayer {
return MediaPlayer(VLCInstance.get()).apply {
VLCOptions.getAout(VLCApplication.getSettings())?.let { setAudioOutput(it) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment