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

fix(android): fix null pointer exception at playback start with item metadata #3879

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
3 changes: 3 additions & 0 deletions android/src/main/java/com/brentvatne/common/api/Source.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetMap
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString
import com.facebook.react.bridge.ReadableMap
import java.util.Locale
import java.util.Objects

/**
* Class representing Source props for host.
Expand Down Expand Up @@ -50,6 +51,8 @@ class Source {
*/
var textTracksAllowChuncklessPreparation: Boolean = false

override fun hashCode(): Int = Objects.hash(uriString, uri, startPositionMs, cropStartMs, cropEndMs, extension, metadata, headers)

/** return true if this and src are equals */
override fun equals(other: Any?): Boolean {
if (other == null || other !is Source) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessi
MediaItem.Builder mediaItemBuilder = new MediaItem.Builder()
.setUri(uri);

// refresh custom Metadata
customMetadata = ConfigurationUtils.buildCustomMetadata(source.getMetadata());
if (customMetadata != null) {
mediaItemBuilder.setMediaMetadata(customMetadata);
}
Expand Down Expand Up @@ -1761,19 +1763,6 @@ public void setSrc(Source source) {
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
source.getHeaders());

// refresh custom Metadata
MediaMetadata newCustomMetadata = ConfigurationUtils.buildCustomMetadata(source.getMetadata());

// Apply custom metadata is possible
if (player != null && !Util.areEqual(newCustomMetadata, customMetadata)) {
customMetadata = newCustomMetadata;
MediaItem currentMediaItem = player.getCurrentMediaItem();
if (currentMediaItem != null) {
MediaItem newMediaItem = currentMediaItem.buildUpon().setMediaMetadata(customMetadata).build();
// This will cause video blink/reload but won't louse progress
player.setMediaItem(newMediaItem, false);
}
}
if (!isSourceEqual) {
reloadSource();
}
Expand Down
Loading