Skip to content

Commit

Permalink
Added support for setting an interval to setOnCastSessionProgressUpda…
Browse files Browse the repository at this point in the history
…teListener
  • Loading branch information
mradzinski committed Aug 18, 2018
1 parent 15ac04f commit 9314fc3
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions caster/src/main/java/com/mradzinski/caster/Caster.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Caster implements CasterPlayer.OnMediaLoadedListener {
private CasterPlayer casterPlayer;
private WeakReference<Activity> activity;
private List<IntroductoryOverlay> introductionOverlays = new ArrayList<>();
private Long progressListenerInterval = 1000L;

private boolean deliveredFinishStatus = false;
private boolean deliveredPlayingVideo = false;
Expand Down Expand Up @@ -326,7 +327,21 @@ public void setOnCastSessionUpdatedListener(@Nullable OnCastSessionUpdatedListen
}

/**
* Sets {@link OnCastSessionProgressUpdateListener}
* Sets {@link OnCastSessionProgressUpdateListener} with a custom interval.
*
* @param interval The interval in ms for this listener to be called.
* @param onCastSessionProgressUpdateListener An instance of {@link OnCastSessionProgressUpdateListener}
*/
public void setOnCastSessionProgressUpdateListener(Long interval, @Nullable OnCastSessionProgressUpdateListener onCastSessionProgressUpdateListener) {
this.onCastSessionProgressUpdateListener = onCastSessionProgressUpdateListener;
this.progressListenerInterval = interval;
}

/**
* Sets {@link OnCastSessionProgressUpdateListener} which will be called with a default interval of 1000 ms.
* To customize the interval this listener is called please use:
*
* <p><code>setOnCastSessionProgressUpdateListener(interval, callback)</code></p>
*
* @param onCastSessionProgressUpdateListener An instance of {@link OnCastSessionProgressUpdateListener}
*/
Expand Down Expand Up @@ -437,7 +452,7 @@ private void onConnected(CastSession castSession) {

if (onConnectChangeListener != null) onConnectChangeListener.onConnected();
if (onCastSessionUpdatedListener != null) onCastSessionUpdatedListener.onCastSessionUpdated(castSession, true);
if (onCastSessionProgressUpdateListener != null) castSession.getRemoteMediaClient().addProgressListener(progressListener, 1000);
if (onCastSessionProgressUpdateListener != null) castSession.getRemoteMediaClient().addProgressListener(progressListener, progressListenerInterval);
if (onCastSessionStateChanged != null) castSession.getRemoteMediaClient().registerCallback(mediaListener);
}

Expand Down

0 comments on commit 9314fc3

Please sign in to comment.