use of de.danoeh.antennapod.core.util.playback.AudioPlayer in project AntennaPod by AntennaPod.
the class LocalPSMP method setMediaPlayerListeners.
private void setMediaPlayerListeners(IPlayer mp) {
if (mp == null || media == null) {
return;
}
if (mp instanceof VideoPlayer) {
if (media.getMediaType() != MediaType.VIDEO) {
Log.w(TAG, "video player, but media type is " + media.getMediaType());
}
VideoPlayer vp = (VideoPlayer) mp;
vp.setOnCompletionListener(videoCompletionListener);
vp.setOnSeekCompleteListener(videoSeekCompleteListener);
vp.setOnErrorListener(videoErrorListener);
vp.setOnBufferingUpdateListener(videoBufferingUpdateListener);
vp.setOnInfoListener(videoInfoListener);
} else if (mp instanceof AudioPlayer) {
if (media.getMediaType() != MediaType.AUDIO) {
Log.w(TAG, "audio player, but media type is " + media.getMediaType());
}
AudioPlayer ap = (AudioPlayer) mp;
ap.setOnCompletionListener(audioCompletionListener);
ap.setOnSeekCompleteListener(audioSeekCompleteListener);
ap.setOnErrorListener(audioErrorListener);
ap.setOnBufferingUpdateListener(audioBufferingUpdateListener);
ap.setOnInfoListener(audioInfoListener);
} else if (mp instanceof ExoPlayerWrapper) {
ExoPlayerWrapper ap = (ExoPlayerWrapper) mp;
ap.setOnCompletionListener(audioCompletionListener);
ap.setOnSeekCompleteListener(audioSeekCompleteListener);
ap.setOnBufferingUpdateListener(audioBufferingUpdateListener);
ap.setOnErrorListener(message -> EventBus.getDefault().postSticky(new PlayerErrorEvent(message)));
ap.setOnInfoListener(audioInfoListener);
} else {
Log.w(TAG, "Unknown media player: " + mp);
}
}
use of de.danoeh.antennapod.core.util.playback.AudioPlayer in project AntennaPod by AntennaPod.
the class LocalPSMP method clearMediaPlayerListeners.
private void clearMediaPlayerListeners() {
if (mediaPlayer instanceof VideoPlayer) {
VideoPlayer vp = (VideoPlayer) mediaPlayer;
vp.setOnCompletionListener(x -> {
});
vp.setOnSeekCompleteListener(x -> {
});
vp.setOnErrorListener((mediaPlayer, i, i1) -> false);
vp.setOnBufferingUpdateListener((mediaPlayer, i) -> {
});
vp.setOnInfoListener((mediaPlayer, i, i1) -> false);
} else if (mediaPlayer instanceof AudioPlayer) {
AudioPlayer ap = (AudioPlayer) mediaPlayer;
ap.setOnCompletionListener(x -> {
});
ap.setOnSeekCompleteListener(x -> {
});
ap.setOnErrorListener((x, y, z) -> false);
ap.setOnBufferingUpdateListener((arg0, percent) -> {
});
ap.setOnInfoListener((arg0, what, extra) -> false);
} else if (mediaPlayer instanceof ExoPlayerWrapper) {
ExoPlayerWrapper ap = (ExoPlayerWrapper) mediaPlayer;
ap.setOnCompletionListener(x -> {
});
ap.setOnSeekCompleteListener(x -> {
});
ap.setOnBufferingUpdateListener((arg0, percent) -> {
});
ap.setOnErrorListener(x -> {
});
ap.setOnInfoListener((arg0, what, extra) -> false);
}
}
use of de.danoeh.antennapod.core.util.playback.AudioPlayer in project AntennaPod by AntennaPod.
the class LocalPSMP method createMediaPlayer.
private IPlayer createMediaPlayer() {
if (mediaPlayer != null) {
mediaPlayer.release();
}
if (media == null || media.getMediaType() == MediaType.VIDEO) {
mediaPlayer = new VideoPlayer();
} else {
mediaPlayer = new AudioPlayer(context);
}
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
return setMediaPlayerListeners(mediaPlayer);
}
Aggregations