Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main-oss' into feature/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
romansavka-mq committed May 23, 2024
2 parents 2466b82 + 563b27a commit 70bc370
Show file tree
Hide file tree
Showing 39 changed files with 2,327 additions and 1,350 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# [6.1.1](https://github.com/TheWidlarzGroup/react-native-video/compare/v6.1.0...v6.1.1) (2024-05-22)

### Bug Fixes
* **iOS:** sometimes aspect ratio is invalid ([#3821](https://github.com/TheWidlarzGroup/react-native-video/issues/3821)) ([dac0985](https://github.com/TheWidlarzGroup/react-native-video/commit/dac09854303335d8e37b633c37bca399499d1999))

### Features
* **android:** change default user agent value ([#3813](https://github.com/TheWidlarzGroup/react-native-video/issues/3813)) ([089dc7e](https://github.com/TheWidlarzGroup/react-native-video/commit/089dc7e03251983ed3e1581519ffe4b3020ff5f8))


# [6.1.0](https://github.com/TheWidlarzGroup/react-native-video/compare/v6.0.0...v6.1.0) (2024-05-22)


### Bug Fixes

* **android:** avoid blinking on video track change ([#3782](https://github.com/TheWidlarzGroup/react-native-video/issues/3782)) ([7b1e129](https://github.com/TheWidlarzGroup/react-native-video/commit/7b1e1293f67c0e25e0763d08d830fcf192bb713c))
* **android:** implement live configuration management ([#3792](https://github.com/TheWidlarzGroup/react-native-video/issues/3792)) ([e16730d](https://github.com/TheWidlarzGroup/react-native-video/commit/e16730de11d50b8a85cd09fa2b102fdbf777d8ad))
* **android:** implement seek backward in notification service ([#3808](https://github.com/TheWidlarzGroup/react-native-video/issues/3808)) ([94b3da3](https://github.com/TheWidlarzGroup/react-native-video/commit/94b3da3477af3d82e4b16e6c93beb5c92ccee59b))
* **android:** playback doesn't work with 0 startPositionMs ([#3784](https://github.com/TheWidlarzGroup/react-native-video/issues/3784)) ([66e0ba5](https://github.com/TheWidlarzGroup/react-native-video/commit/66e0ba579b84d745b4ca1b076d41d8eb880ef616))
* **android:** random android crash ([#3777](https://github.com/TheWidlarzGroup/react-native-video/issues/3777)) ([d4c9be2](https://github.com/TheWidlarzGroup/react-native-video/commit/d4c9be2ba09dd410f0d878ce3f6a1cca987f6713))
* **android:** remove remaining ad view when zapping ([#3786](https://github.com/TheWidlarzGroup/react-native-video/issues/3786)) ([324b461](https://github.com/TheWidlarzGroup/react-native-video/commit/324b46152703d813945778f55d87310d4e0b03cf))
* **android:** source metadata compare function ([#3775](https://github.com/TheWidlarzGroup/react-native-video/issues/3775)) ([6455380](https://github.com/TheWidlarzGroup/react-native-video/commit/6455380f9e15099b975dce9beaf9b9af8298f998))
* **tvos:** fix tvOS build and sample ([#3785](https://github.com/TheWidlarzGroup/react-native-video/issues/3785)) ([cd42dd7](https://github.com/TheWidlarzGroup/react-native-video/commit/cd42dd78c96e20da377c9b05c321218f1411ba97))


### Features

* add setVolume function to component's ref ([#3794](https://github.com/TheWidlarzGroup/react-native-video/issues/3794)) ([3cd7ab6](https://github.com/TheWidlarzGroup/react-native-video/commit/3cd7ab60b27e8820607bd83a5681bc7ba7e6c52e))
* **android:** add possibility to hide seekBar ([#3789](https://github.com/TheWidlarzGroup/react-native-video/issues/3789)) ([95e6140](https://github.com/TheWidlarzGroup/react-native-video/commit/95e6140eead56efab83871e29b57d30f4f11a77a))

# [6.0.0+dolbyxp.1.0]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ var styles = StyleSheet.create({
right: 0,
},
});
```
```
32 changes: 32 additions & 0 deletions android/src/main/java/com/brentvatne/common/api/BufferConfig.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.brentvatne.common.api

import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetDouble
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetFloat
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetInt
import com.facebook.react.bridge.ReadableMap

Expand All @@ -20,6 +21,35 @@ class BufferConfig {
var minBackBufferMemoryReservePercent = BufferConfigPropUnsetDouble
var minBufferMemoryReservePercent = BufferConfigPropUnsetDouble

var live: Live = Live()

class Live {
var maxPlaybackSpeed: Float = BufferConfigPropUnsetDouble.toFloat()
var minPlaybackSpeed: Float = BufferConfigPropUnsetDouble.toFloat()
var maxOffsetMs: Long = BufferConfigPropUnsetInt.toLong()
var minOffsetMs: Long = BufferConfigPropUnsetInt.toLong()
var targetOffsetMs: Long = BufferConfigPropUnsetInt.toLong()

companion object {
private val PROP_BUFFER_CONFIG_LIVE_MAX_PLAYBACK_SPEED = "maxPlaybackSpeed"
private val PROP_BUFFER_CONFIG_LIVE_MIN_PLAYBACK_SPEED = "minPlaybackSpeed"
private val PROP_BUFFER_CONFIG_LIVE_MAX_OFFSET_MS = "maxOffsetMs"
private val PROP_BUFFER_CONFIG_LIVE_MIN_OFFSET_MS = "minOffsetMs"
private val PROP_BUFFER_CONFIG_LIVE_TARGET_OFFSET_MS = "targetOffsetMs"

@JvmStatic
fun parse(src: ReadableMap?): Live {
val live = Live()
live.maxPlaybackSpeed = safeGetFloat(src, PROP_BUFFER_CONFIG_LIVE_MAX_PLAYBACK_SPEED, BufferConfigPropUnsetDouble.toFloat())
live.minPlaybackSpeed = safeGetFloat(src, PROP_BUFFER_CONFIG_LIVE_MIN_PLAYBACK_SPEED, BufferConfigPropUnsetDouble.toFloat())
live.maxOffsetMs = safeGetInt(src, PROP_BUFFER_CONFIG_LIVE_MAX_OFFSET_MS, BufferConfigPropUnsetInt).toLong()
live.minOffsetMs = safeGetInt(src, PROP_BUFFER_CONFIG_LIVE_MIN_OFFSET_MS, BufferConfigPropUnsetInt).toLong()
live.targetOffsetMs = safeGetInt(src, PROP_BUFFER_CONFIG_LIVE_TARGET_OFFSET_MS, BufferConfigPropUnsetInt).toLong()
return live
}
}
}

companion object {
val BufferConfigPropUnsetInt = -1
val BufferConfigPropUnsetDouble = -1.0
Expand All @@ -33,6 +63,7 @@ class BufferConfig {
private val PROP_BUFFER_CONFIG_MIN_BACK_BUFFER_MEMORY_RESERVE_PERCENT = "minBackBufferMemoryReservePercent"
private val PROP_BUFFER_CONFIG_MIN_BUFFER_MEMORY_RESERVE_PERCENT = "minBufferMemoryReservePercent"
private val PROP_BUFFER_CONFIG_BACK_BUFFER_DURATION_MS = "backBufferDurationMs"
private val PROP_BUFFER_CONFIG_LIVE = "live"

@JvmStatic
fun parse(src: ReadableMap?): BufferConfig {
Expand All @@ -59,6 +90,7 @@ class BufferConfig {
BufferConfigPropUnsetDouble
)
bufferConfig.backBufferDurationMs = safeGetInt(src, PROP_BUFFER_CONFIG_BACK_BUFFER_DURATION_MS, BufferConfigPropUnsetInt)
bufferConfig.live = Live.parse(src.getMap(PROP_BUFFER_CONFIG_LIVE))
}
return bufferConfig
}
Expand Down
21 changes: 21 additions & 0 deletions android/src/main/java/com/brentvatne/common/api/ControlsConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.brentvatne.common.api

import com.brentvatne.common.toolbox.ReactBridgeUtils
import com.facebook.react.bridge.ReadableMap

class ControlsConfig {
var hideSeekBar: Boolean = false

companion object {
@JvmStatic
fun parse(src: ReadableMap?): ControlsConfig {
val config = ControlsConfig()

if (src != null) {
config.hideSeekBar = ReactBridgeUtils.safeGetBool(src, "hideSeekBar", false)
}

return config
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class VideoTrack {
var height = 0
var bitrate = 0
var codecs = ""
var id = -1
var index = -1
var trackId = ""
var isSelected = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public void load(
int videoWidth,
int videoHeight,
List<TrackInfo> audioTracks,
List<TrackInfo> videoTracks, List<TrackInfo> textTracks,
List<TrackInfo> videoTracks,
List<TrackInfo> textTracks,
String trackId) {
WritableMap event = Arguments.createMap();
event.putDouble(EVENT_PROP_DURATION, duration / 1000D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;
import androidx.media3.common.C;

@SuppressLint("InlinedApi")
Expand Down Expand Up @@ -29,6 +30,7 @@ public int getStreamType() {
return streamType;
}

@NonNull
@Override
public String toString() {
return getClass().getSimpleName() + "(" + this.mName + ", " + streamType + ")";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.brentvatne.exoplayer

import androidx.media3.common.MediaItem.LiveConfiguration
import com.brentvatne.common.api.BufferConfig
import com.brentvatne.common.api.BufferConfig.Live

/**
* Helper functions to create exoplayer configuration
*/
object ConfigurationUtils {

/**
* Create a media3.LiveConfiguration.Builder from parsed BufferConfig
*/
@JvmStatic
fun getLiveConfiguration(bufferConfig: BufferConfig): LiveConfiguration.Builder {
val liveConfiguration = LiveConfiguration.Builder()
val live: Live = bufferConfig.live
if (bufferConfig.live.maxOffsetMs >= 0) {
liveConfiguration.setMaxOffsetMs(live.maxOffsetMs)
}
if (bufferConfig.live.maxPlaybackSpeed >= 0) {
liveConfiguration.setMaxPlaybackSpeed(live.maxPlaybackSpeed)
}
if (bufferConfig.live.targetOffsetMs >= 0) {
liveConfiguration.setTargetOffsetMs(live.targetOffsetMs)
}
if (bufferConfig.live.minOffsetMs >= 0) {
liveConfiguration.setMinOffsetMs(live.minOffsetMs)
}
if (bufferConfig.live.minPlaybackSpeed >= 0) {
liveConfiguration.setMinPlaybackSpeed(live.minPlaybackSpeed)
}
return liveConfiguration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import androidx.media3.datasource.okhttp.OkHttpDataSource;
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;

import com.brentvatne.common.toolbox.DebugLog;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.CookieJarContainer;
import com.facebook.react.modules.network.ForwardingCookieHandler;
Expand All @@ -39,7 +38,7 @@ public static void setUserAgent(String userAgent) {

public static String getUserAgent(ReactContext context) {
if (userAgent == null) {
userAgent = Util.getUserAgent(context, "ReactNativeVideo");
userAgent = Util.getUserAgent(context, context.getPackageName());
}
return userAgent;
}
Expand Down
26 changes: 11 additions & 15 deletions android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.media3.common.AdViewProvider;
import androidx.media3.common.C;
Expand Down Expand Up @@ -44,8 +45,8 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
private final AspectRatioFrameLayout layout;
private final ComponentListener componentListener;
private ExoPlayer player;
private Context context;
private ViewGroup.LayoutParams layoutParams;
private final Context context;
private final ViewGroup.LayoutParams layoutParams;
private final FrameLayout adOverlayFrameLayout;

private boolean useTextureView = true;
Expand Down Expand Up @@ -235,16 +236,6 @@ public void setResizeMode(@ResizeMode.Mode int resizeMode) {
}
}

/**
* Get the view onto which video is rendered. This is either a {@link SurfaceView} (default)
* or a {@link TextureView} if the {@code use_texture_view} view attribute has been set to true.
*
* @return either a {@link SurfaceView} or a {@link TextureView}.
*/
public View getVideoSurfaceView() {
return surfaceView;
}

public void setUseTextureView(boolean useTextureView) {
if (useTextureView != this.useTextureView) {
this.useTextureView = useTextureView;
Expand Down Expand Up @@ -298,7 +289,7 @@ public void invalidateAspectRatio() {
private final class ComponentListener implements Player.Listener {

@Override
public void onCues(CueGroup cueGroup) {
public void onCues(@NonNull CueGroup cueGroup) {
List<Cue> cues = cueGroup.cues;
if (!subtitleLinesRespected) {
ArrayList<Cue> noLineCues = new ArrayList<>();
Expand All @@ -312,7 +303,12 @@ public void onCues(CueGroup cueGroup) {
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
boolean isInitialRatio = layout.getAspectRatio() == 0;
layout.setAspectRatio(videoSize.height == 0 ? 1 : (videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height);
if (videoSize.height == 0 || videoSize.width == 0) {
// When changing video track we receive an ghost state with height / width = 0
// No need to resize the view in that case
return;
}
layout.setAspectRatio((videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height);

// React native workaround for measuring and layout on initial load.
if (isInitialRatio) {
Expand All @@ -326,7 +322,7 @@ public void onRenderedFirstFrame() {
}

@Override
public void onTracksChanged(Tracks tracks) {
public void onTracksChanged(@NonNull Tracks tracks) {
updateForCurrentTrackSelections(tracks);
}
}
Expand Down
Loading

0 comments on commit 70bc370

Please sign in to comment.