diff --git a/tvplayer/src/main/java/com/kaltura/tvplayer/KalturaPlayer.java b/tvplayer/src/main/java/com/kaltura/tvplayer/KalturaPlayer.java index 6312216b..5ff3a168 100644 --- a/tvplayer/src/main/java/com/kaltura/tvplayer/KalturaPlayer.java +++ b/tvplayer/src/main/java/com/kaltura/tvplayer/KalturaPlayer.java @@ -745,23 +745,6 @@ public void loadPlaylist(@NonNull OTTPlaylistOptions playlistOptions, @NonNull f ); } - private void loadPlaylistHelper(@NonNull ProviderPlaylistOptions playlistOptions, @NonNull OnPlaylistControllerListener controllerListener, PKPlaylistType playlistType) { - final PlaylistProvider provider = playlistOptions.buildPlaylistProvider(getServerUrl(), getPartnerId(), playlistOptions.ks); - provider.load(response -> playlistLoadCompleted(response, (playlist, error) -> { - if (error != null) { - return; - } - PlaylistController playlistController = new PKPlaylistController(KalturaPlayer.this, playlist, playlistType); - playlistController.setPlaylistOptions(playlistOptions); - controllerListener.onPlaylistControllerComplete(playlistController, null); - setPlaylistController(playlistController); - if (messageBus != null) { - messageBus.post(new PlaylistEvent.PlaylistStarted(playlist)); - } - playlistController.playItem(playlistOptions.startIndex, autoPlay); - })); - } - public void loadPlaylist(@NonNull BasicPlaylistOptions playlistOptions, @NonNull final OnPlaylistControllerListener controllerListener) { if (!isValidBasicPlayer()) @@ -800,6 +783,23 @@ public void loadPlaylist(@NonNull BasicPlaylistOptions playlistOptions, @NonNull playlistController.playItem(playlistOptions.startIndex, autoPlay); } + private void loadPlaylistHelper(@NonNull ProviderPlaylistOptions playlistOptions, @NonNull OnPlaylistControllerListener controllerListener, PKPlaylistType playlistType) { + final PlaylistProvider provider = playlistOptions.buildPlaylistProvider(getServerUrl(), getPartnerId(), playlistOptions.ks); + provider.load(response -> playlistLoadCompleted(response, (playlist, error) -> { + if (error != null) { + return; + } + PlaylistController playlistController = new PKPlaylistController(KalturaPlayer.this, playlist, playlistType); + playlistController.setPlaylistOptions(playlistOptions); + controllerListener.onPlaylistControllerComplete(playlistController, null); + setPlaylistController(playlistController); + if (messageBus != null) { + messageBus.post(new PlaylistEvent.PlaylistStarted(playlist)); + } + playlistController.playItem(playlistOptions.startIndex, autoPlay); + })); + } + public void loadMedia(@NonNull OTTMediaOptions mediaOptions, @NonNull final OnEntryLoadListener listener) { if (!isValidOTTPlayer()) @@ -808,10 +808,7 @@ public void loadMedia(@NonNull OTTMediaOptions mediaOptions, @NonNull final OnEn prepareLoadMedia(mediaOptions); runAfterRetrieve( - () -> { - final MediaEntryProvider provider = mediaOptions.buildMediaProvider(getServerUrl(), getPartnerId()); - provider.load(response -> mediaLoadCompleted(response, listener)); - }, + () -> loadMediaHelper(mediaOptions, listener), () -> listener.onEntryLoadComplete(null, KalturaPlayerNotInitializedError)); } @@ -823,14 +820,16 @@ public void loadMedia(@NonNull OVPMediaOptions mediaOptions, @NonNull final OnEn prepareLoadMedia(mediaOptions); runAfterRetrieve( - () -> { - final MediaEntryProvider provider = mediaOptions.buildMediaProvider(getServerUrl(), getPartnerId()); - provider.load(response -> mediaLoadCompleted(response, listener)); - }, + () -> loadMediaHelper(mediaOptions, listener), () -> listener.onEntryLoadComplete(null, KalturaPlayerNotInitializedError) ); } + private void loadMediaHelper(@NonNull MediaOptions mediaOptions, @NonNull OnEntryLoadListener listener) { + final MediaEntryProvider provider = mediaOptions.buildMediaProvider(getServerUrl(), getPartnerId()); + provider.load(response -> mediaLoadCompleted(response, listener)); + } + private boolean isValidOVPPlayer() { if (Type.basic.equals(tvPlayerType)) { return false;