Commit c45f5f5b authored by RalfNieuwenhuizen's avatar RalfNieuwenhuizen Committed by Matt Apperson
Browse files

Add progressUpdateInterval to android-exoplayer (#540)

parent ebc6617b
Loading
Loading
Loading
Loading
+7 −1
Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
+6 −0
Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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));