Commit a3086bbb authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Playbackservice Kotlin refactor

parent 4d915f05
This diff is collapsed.
This diff is collapsed.
......@@ -200,7 +200,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
if (hasMedia() && !isVideoPlaying && isVisible
&& settings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)) {
settings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply()
currentMediaWrapper.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
currentMediaWrapper?.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
switchToVideo()
return
}
......@@ -366,11 +366,13 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
fun onResumeToVideoClick(v: View) {
service?.apply {
if (hasRenderer()) VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
currentMediaWrapper.uri, currentMediaPosition)
else if (hasMedia()) {
currentMediaWrapper.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
switchToVideo()
currentMediaWrapper?.let {
if (hasRenderer()) VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
it.uri, currentMediaPosition)
else if (hasMedia()) {
it.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
switchToVideo()
}
}
}
}
......
......@@ -32,8 +32,8 @@ class NowPlayingDelegate(private val fragment: MainTvFragment): PlaybackService.
PlaylistManager.showAudioPlayer.removeObserver(observer)
}
override fun onMediaPlayerEvent(event: MediaPlayer.Event?) {
when (event?.type) {
override fun onMediaPlayerEvent(event: MediaPlayer.Event) {
when (event.type) {
MediaPlayer.Event.MediaChanged -> updateCurrent()
}
}
......@@ -44,10 +44,10 @@ class NowPlayingDelegate(private val fragment: MainTvFragment): PlaybackService.
})
}
override fun onConnected(service: PlaybackService?) {
override fun onConnected(service: PlaybackService) {
this.service = service
updateCurrent()
service?.addCallback(this)
service.addCallback(this)
}
override fun onDisconnected() {
......
......@@ -78,10 +78,9 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
public void removePopup() {
hideNotification();
if (mRootView == null)
return;
if (mRootView == null) return;
mService.removeCallback(this);
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
vlcVout.detachViews();
mRootView.close();
mRootView = null;
......@@ -104,7 +103,7 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
gestureDetector.setOnDoubleTapListener(this);
mRootView.setGestureDetector(gestureDetector);
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
vlcVout.setVideoView((SurfaceView) mRootView.findViewById(R.id.player_surface));
vlcVout.addCallback(this);
vlcVout.attachViews(this);
......
......@@ -768,11 +768,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSavedTime = -1;
mPlaybackStarted = true;
IVLCVout vlcVout = mService.getVLCVout();
IVLCVout vlcVout = mService.getVout();
if (vlcVout.areViewsAttached()) {
if (mService.isPlayingPopup()) {
mService.stop();
vlcVout = mService.getVLCVout();
vlcVout = mService.getVout();
} else
vlcVout.detachViews();
}
......@@ -857,7 +857,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.removeCallback(this);
mHandler.removeCallbacksAndMessages(null);
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
vlcVout.removeCallback(this);
vlcVout.detachViews();
if (mService.hasMedia() && mSwitchingView) {
......@@ -1796,7 +1796,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private void handleVout(int voutCount) {
mHandler.removeCallbacks(mSwitchAudioRunnable);
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
if (vlcVout.areViewsAttached() && voutCount == 0) {
mHandler.postDelayed(mSwitchAudioRunnable, 4000);
}
......@@ -1904,7 +1904,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
if (mService != null) {
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
vlcVout.setWindowSize(sw, sh);
}
......@@ -2022,7 +2022,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private void sendMouseEvent(int action, int x, int y) {
if (mService == null)
return;
final IVLCVout vlcVout = mService.getVLCVout();
final IVLCVout vlcVout = mService.getVout();
vlcVout.sendMouseEvent(action, 0, x, y);
}
......
......@@ -150,8 +150,8 @@ object EmptyMLCallbacks : MediaAddedCb, MediaUpdatedCb, Medialibrary.ArtistsAdde
object EmptyPBSCallback : PlaybackService.Callback {
override fun update() {}
override fun updateProgress() {}
override fun onMediaEvent(event: Media.Event?) {}
override fun onMediaPlayerEvent(event: MediaPlayer.Event?) {}
override fun onMediaEvent(event: Media.Event) {}
override fun onMediaPlayerEvent(event: MediaPlayer.Event) {}
}
interface RefreshModel {
......
......@@ -28,7 +28,7 @@ class PlaylistModel(private val service: PlaybackService) : ViewModel(), Playbac
}
override fun update() {
dataset.value = service.medias
dataset.value = service.medias.toMutableList()
}
override fun updateProgress() {
......
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