fix(android): fix null pointer exception at playback start with item metadata (#3879)
* fix(android): fix null pointer exception at playback start with item metadata
This commit is contained in:
parent
d4a8c24f65
commit
c2cd7529fd
@ -15,6 +15,7 @@ import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetMap
|
|||||||
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString
|
||||||
import com.facebook.react.bridge.ReadableMap
|
import com.facebook.react.bridge.ReadableMap
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import java.util.Objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing Source props for host.
|
* Class representing Source props for host.
|
||||||
@ -50,6 +51,8 @@ class Source {
|
|||||||
*/
|
*/
|
||||||
var textTracksAllowChuncklessPreparation: Boolean = false
|
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 */
|
/** return true if this and src are equals */
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other == null || other !is Source) return false
|
if (other == null || other !is Source) return false
|
||||||
|
@ -991,6 +991,8 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
MediaItem.Builder mediaItemBuilder = new MediaItem.Builder()
|
MediaItem.Builder mediaItemBuilder = new MediaItem.Builder()
|
||||||
.setUri(uri);
|
.setUri(uri);
|
||||||
|
|
||||||
|
// refresh custom Metadata
|
||||||
|
customMetadata = ConfigurationUtils.buildCustomMetadata(source.getMetadata());
|
||||||
if (customMetadata != null) {
|
if (customMetadata != null) {
|
||||||
mediaItemBuilder.setMediaMetadata(customMetadata);
|
mediaItemBuilder.setMediaMetadata(customMetadata);
|
||||||
}
|
}
|
||||||
@ -1761,19 +1763,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
|
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
|
||||||
source.getHeaders());
|
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) {
|
if (!isSourceEqual) {
|
||||||
reloadSource();
|
reloadSource();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user