Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exoplayer to allow pre-init and content clear #2412

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,12 @@ Platforms: Android ExoPlayer
#### source
Sets the media source. You can pass an asset loaded via require or an object with a uri.

Setting the source will trigger the player to attempt to load the provided media with all other given props. Please be sure that all props are provided before/at the same time as setting the source.

Rendering the player component with a null source will init the player, and start playing once a source value is provided.

Providing a null source value after loading a previous source will stop playback, and clear out the previous source content.

The docs for this prop are incomplete and will be updated as each option is investigated and tested.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ public void run() {
player.prepare(mediaSource, !haveResumePosition, false);
playerNeedsSource = false;

reLayout(exoPlayerView);
eventEmitter.loadStart();
loadVideoStarted = true;
}
Expand Down Expand Up @@ -1012,7 +1013,6 @@ public void onMetadata(Metadata metadata) {

public void setSrc(final Uri uri, final String extension, Map<String, String> headers) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;
boolean isSourceEqual = uri.equals(srcUri);

this.srcUri = uri;
Expand All @@ -1022,12 +1022,23 @@ public void setSrc(final Uri uri, final String extension, Map<String, String> he
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
this.requestHeaders);

if (!isOriginalSourceNull && !isSourceEqual) {
if (!isSourceEqual) {
reloadSource();
}
}
}

public void clearSrc() {
if (srcUri != null) {
player.stop(true);
this.srcUri = null;
this.extension = null;
this.requestHeaders = null;
this.mediaDataSourceFactory = null;
clearResumePosition();
}
}

public void setProgressUpdateInterval(final float progressUpdateInterval) {
mProgressUpdateInterval = progressUpdateInterval;
}
Expand All @@ -1038,14 +1049,13 @@ public void setReportBandwidth(boolean reportBandwidth) {

public void setRawSrc(final Uri uri, final String extension) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;
boolean isSourceEqual = uri.equals(srcUri);

this.srcUri = uri;
this.extension = extension;
this.mediaDataSourceFactory = buildDataSourceFactory(true);

if (!isOriginalSourceNull && !isSourceEqual) {
if (!isSourceEqual) {
reloadSource();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void setSrc(final ReactExoplayerView videoView, @Nullable ReadableMap src
Map<String, String> headers = src.hasKey(PROP_SRC_HEADERS) ? toStringMap(src.getMap(PROP_SRC_HEADERS)) : null;

if (TextUtils.isEmpty(uriString)) {
videoView.clearSrc();
return;
}

Expand Down