Add progressUpdateInterval to android-exoplayer (#540)

This commit is contained in:
RalfNieuwenhuizen 2017-03-31 18:15:39 +02:00 committed by Matt Apperson
parent ebc6617ba4
commit c45f5f5b38
2 changed files with 13 additions and 1 deletions

View File

@ -50,6 +50,7 @@ import com.google.android.exoplayer2.util.Util;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.lang.Math;
@SuppressLint("ViewConstructor")
class ReactExoplayerView extends FrameLayout implements
@ -91,6 +92,7 @@ class ReactExoplayerView extends FrameLayout implements
private String extension;
private boolean repeat;
private boolean disableFocus;
private float mProgressUpdateInterval = 250.0f;
// \ End props
// React
@ -110,7 +112,7 @@ class ReactExoplayerView extends FrameLayout implements
long pos = player.getCurrentPosition();
eventEmitter.progressChanged(pos, player.getBufferedPercentage());
msg = obtainMessage(SHOW_PROGRESS);
sendMessageDelayed(msg, 1000 - (pos % 1000));
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));
}
break;
}
@ -533,6 +535,10 @@ class ReactExoplayerView extends FrameLayout implements
}
}
public void setProgressUpdateInterval(final float progressUpdateInterval) {
mProgressUpdateInterval = progressUpdateInterval;
}
public void setRawSrc(final Uri uri, final String extension) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;

View File

@ -27,6 +27,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_PAUSED = "paused";
private static final String PROP_MUTED = "muted";
private static final String PROP_VOLUME = "volume";
private static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
private static final String PROP_SEEK = "seek";
private static final String PROP_RATE = "rate";
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
@ -129,6 +130,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
videoView.setVolumeModifier(volume);
}
@ReactProp(name = PROP_PROGRESS_UPDATE_INTERVAL, defaultFloat = 250.0f)
public void setProgressUpdateInterval(final ReactExoplayerView videoView, final float progressUpdateInterval) {
videoView.setProgressUpdateInterval(progressUpdateInterval);
}
@ReactProp(name = PROP_SEEK)
public void setSeek(final ReactExoplayerView videoView, final float seek) {
videoView.seekTo(Math.round(seek * 1000f));