[Android] Use cached state for isPlaying() value
Geoffrey Métais
git at videolan.org
Fri Jan 26 15:16:46 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 22 17:59:12 2018 +0100| [22b9e83759323217a7d28e82429d3deec2d1ab7f] | committer: Geoffrey Métais
Use cached state for isPlaying() value
> https://code.videolan.org/videolan/vlc-android/commit/22b9e83759323217a7d28e82429d3deec2d1ab7f
---
vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index a71b2d3bb..6e9369fc0 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -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) }
More information about the Android
mailing list