Skip to content
Snippets Groups Projects
Commit bbf2bc30 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#173 - Resume player before playing next media, keep playing current media...

#173 - Resume player before playing next media, keep playing current media than playing new media from different pad
parent c2fc4cf9
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,8 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte ...@@ -33,6 +33,8 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
private var showingLastFrame: Boolean = false private var showingLastFrame: Boolean = false
private var isPause: Boolean = false private var isPause: Boolean = false
var stopMediaByOtherPlayer = false
private val fadeController = new LinearFadeController(value => { private val fadeController = new LinearFadeController(value => {
if (getCurrentPlayingMediaIndex >= 0) { if (getCurrentPlayingMediaIndex >= 0) {
ContentPluginMain.playerViewController.setFadeValue(getSelectedZones, value) ContentPluginMain.playerViewController.setFadeValue(getSelectedZones, value)
...@@ -75,11 +77,13 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte ...@@ -75,11 +77,13 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
override def stop(): Boolean = { override def stop(): Boolean = {
isPause = false isPause = false
if (getCurrentPlayingMediaIndex != -1) {
mediaPlayers(getCurrentPlayingMediaIndex).stop() mediaPlayers(getCurrentPlayingMediaIndex).stop()
if (showingLastFrame) { if (showingLastFrame) {
ContentPluginMain.playerViewController.clearHold(mediaPlayers(getCurrentPlayingMediaIndex)) ContentPluginMain.playerViewController.clearHold(mediaPlayers(getCurrentPlayingMediaIndex))
} }
}
currentRunningIndexProperty.set(-1) currentRunningIndexProperty.set(-1)
true true
......
...@@ -40,6 +40,17 @@ class ContentPlayerBinding(val player: ContentPlayer, val zone: Zone) { ...@@ -40,6 +40,17 @@ class ContentPlayerBinding(val player: ContentPlayer, val zone: Zone) {
}) })
def play(media: ContentPlayerMediaContainer, withFadeIn: Boolean): Unit = { def play(media: ContentPlayerMediaContainer, withFadeIn: Boolean): Unit = {
if (currentMedia.get() != null && currentMedia.get().content.getPad != media.content.getPad) {
if (currentMedia.get().content.getPad.isPlay) {
// Stop the current playing media on this player and hold the last frame
currentMedia.get().content.stopMediaByOtherPlayer = true
currentMedia.get().content.getPad.stop()
} else if (currentMedia.get().content.getPad.isPaused) {
// The player mist be resumed before playing the next media
player.Resume(withFadeIn)
currentMedia.get().content.getPad.stop()
}
}
player.Play(media.getPath, withFadeIn) player.Play(media.getPath, withFadeIn)
currentMedia.set(media) currentMedia.set(media)
} }
...@@ -51,7 +62,15 @@ class ContentPlayerBinding(val player: ContentPlayer, val zone: Zone) { ...@@ -51,7 +62,15 @@ class ContentPlayerBinding(val player: ContentPlayer, val zone: Zone) {
def pause(media: ContentPlayerMediaContainer): Unit = player.Pause() def pause(media: ContentPlayerMediaContainer): Unit = player.Pause()
def stop(media: ContentPlayerMediaContainer): Unit = player.Stop() def stop(media: ContentPlayerMediaContainer): Unit = {
// If media is stopped by a different pad, the current media should keep playing to have a smooth transition
// to the new media. Otherwise the media will be stopped normally.
if (media.content.stopMediaByOtherPlayer) {
media.content.stopMediaByOtherPlayer = false
} else {
player.Stop()
}
}
def clearHold(): Unit = player.ClearHold() def clearHold(): Unit = player.ClearHold()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment