Skip to content

Commit

Permalink
Merge branch 'master' of github.com:react-native-video/react-native-v…
Browse files Browse the repository at this point in the history
…ideo
  • Loading branch information
freeboub committed May 15, 2024
2 parents a5e10a3 + 464ce7c commit 9ce1d95
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 30 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@


# [6.0.0](https://github.com/TheWidlarzGroup/react-native-video/compare/v6.0.0-rc.2...v6.0.0) (2024-05-14)


### Bug Fixes

* **android:** poster hidding ([#3768](https://github.com/TheWidlarzGroup/react-native-video/issues/3768)) ([98b4a75](https://github.com/TheWidlarzGroup/react-native-video/commit/98b4a75a90c6bc97cde267ea1c6a4a68d0bfdf45))
* **android:** video tracks crash and clean ([#3767](https://github.com/TheWidlarzGroup/react-native-video/issues/3767)) ([219496f](https://github.com/TheWidlarzGroup/react-native-video/commit/219496ff3abf6d7362ae01fb66c0bf28dfb00510))

# [6.0.0-rc.2](https://github.com/TheWidlarzGroup/react-native-video/compare/v6.0.0-rc.1...v6.0.0-rc.2) (2024-05-13)


### Bug Fixes

* **avoid:** avoid early return in setSrc ([#3759](https://github.com/TheWidlarzGroup/react-native-video/issues/3759)) ([2e623ca](https://github.com/TheWidlarzGroup/react-native-video/commit/2e623ca0fb074e64a6125994effb8723f5c4ce59))
* **ios:** call `onLoadStart` earlier ([#3750](https://github.com/TheWidlarzGroup/react-native-video/issues/3750)) ([b3f08f6](https://github.com/TheWidlarzGroup/react-native-video/commit/b3f08f6c990f4670311e6d918aea191e72673057))
* **js:** fix onPlaybackStateChanged callback ([#3753](https://github.com/TheWidlarzGroup/react-native-video/issues/3753)) ([f87a793](https://github.com/TheWidlarzGroup/react-native-video/commit/f87a7938c6941c69915477fcf5f08c54a2635597))
* **ts:** add missing type ([#3757](https://github.com/TheWidlarzGroup/react-native-video/issues/3757)) ([2d94844](https://github.com/TheWidlarzGroup/react-native-video/commit/2d9484499cfb58d86b0aa82872d494a03fe67bba))


### Features

* **android:** make buffering strategy dynamic ([#3756](https://github.com/TheWidlarzGroup/react-native-video/issues/3756)) ([e420418](https://github.com/TheWidlarzGroup/react-native-video/commit/e420418e8f74894c443bd232e99f9b860e1d0b93))


### Reverts

* Revert "fix(android): video flickering add playback start (#3746)" (#3748) ([d25629b](https://github.com/TheWidlarzGroup/react-native-video/commit/d25629bb62cb9a7772ec2704f678e0fdf4927d12)), closes [#3746](https://github.com/TheWidlarzGroup/react-native-video/issues/3746) [#3748](https://github.com/TheWidlarzGroup/react-native-video/issues/3748)

# [6.0.0-rc.1](https://github.com/TheWidlarzGroup/react-native-video/compare/v6.0.0-rc.0...v6.0.0-rc.1) (2024-05-08)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ private VideoTrack exoplayerVideoTrackToGenericVideoTrack(Format format, int tra
videoTrack.setHeight(format.height == Format.NO_VALUE ? 0 : format.height);
videoTrack.setBitrate(format.bitrate == Format.NO_VALUE ? 0 : format.bitrate);
if (format.codecs != null) videoTrack.setCodecs(format.codecs);
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);;
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);
return videoTrack;
}

Expand Down Expand Up @@ -1646,14 +1646,13 @@ public void setSrc(final Uri uri, final long startPositionMs, final long cropSta
if (this.customMetadata != customMetadata && player != null) {
MediaItem currentMediaItem = player.getCurrentMediaItem();

if (currentMediaItem == null) {
return;
}
if (currentMediaItem != null) {

MediaItem newMediaItem = currentMediaItem.buildUpon().setMediaMetadata(customMetadata).build();
MediaItem newMediaItem = currentMediaItem.buildUpon().setMediaMetadata(customMetadata).build();

// This will cause video blink/reload but won't louse progress
player.setMediaItem(newMediaItem, false);
// This will cause video blink/reload but won't louse progress
player.setMediaItem(newMediaItem, false);
}
}

if (uri != null) {
Expand Down Expand Up @@ -1799,9 +1798,14 @@ public void setSelectedTrack(int trackType, String type, String value) {
}
}
} else if ("index".equals(type)) {
int iValue = Integer.parseInt(value);
if (iValue < groups.length) {
groupIndex = iValue;
try {
int iValue = Integer.parseInt(value);
if (iValue < groups.length) {
groupIndex = iValue;
}
} catch (Exception e) {
DebugLog.e(TAG, "cannot parse index:" + value);
groupIndex = 0;
}
} else if ("resolution".equals(type)) {
int height = Integer.parseInt(value);
Expand Down Expand Up @@ -1867,7 +1871,6 @@ public void setSelectedTrack(int trackType, String type, String value) {
if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO && groups.length != 0) { // Video auto
// Add all tracks as valid options for ABR to choose from
TrackGroup group = groups.get(0);
tracks = new ArrayList<>(group.length);
ArrayList<Integer> allTracks = new ArrayList<>(group.length);
groupIndex = 0;
for (int j = 0; j < group.length; j++) {
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ PODS:
- React-Mapbuffer (0.74.0):
- glog
- React-debug
- react-native-video (6.0.0-rc.0):
- react-native-video (6.0.0-rc.1):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -949,15 +949,15 @@ PODS:
- React-featureflags
- React-graphics
- React-ImageManager
- react-native-video/Video (= 6.0.0-rc.0)
- react-native-video/Video (= 6.0.0-rc.1)
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-video/Video (6.0.0-rc.0):
- react-native-video/Video (6.0.0-rc.1):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1421,7 +1421,7 @@ SPEC CHECKSUMS:
React-jsitracing: 72dce571a387f9d085482142837222c31a8d6c3a
React-logger: 03f2f7b955cfe24593a2b8c9705c23e142d1ad24
React-Mapbuffer: 1ab3316cb736411bc641311b4b71e75099ae56ad
react-native-video: 3262598f55f8632e5d4dae90ba63d9d6e09bd563
react-native-video: 6bcf0049420848ecf85a46bc5ab3225022843fe6
React-nativeconfig: fef0a46effa630d72f137636a990d7df2f6a5f7c
React-NativeModulesApple: 8257dd73991f2e410b9c9d12801691439a0dc821
React-perflogger: 271f1111779fef70f9502d1d38da5132e5585230
Expand Down
39 changes: 26 additions & 13 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
}
}

private var _isBuffering = false {
didSet {
onVideoBuffer?(["isBuffering": _isBuffering, "target": reactTag as Any])
}
}

/* IMA Ads */
private var _adTagUrl: String?
#if USE_GOOGLE_IMA
Expand Down Expand Up @@ -375,6 +381,17 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
throw NSError(domain: "", code: 0, userInfo: nil)
}

// Perform on next run loop, otherwise onVideoLoadStart is nil
onVideoLoadStart?([
"src": [
"uri": _source?.uri ?? NSNull(),
"type": _source?.type ?? NSNull(),
"isNetwork": NSNumber(value: _source?.isNetwork ?? false),
],
"drm": _drm?.json ?? NSNull(),
"target": reactTag,
])

if let uri = source.uri, uri.starts(with: "ph://") {
let photoAsset = await RCTVideoUtils.preparePHAsset(uri: uri)
return await playerItemPrepareText(asset: photoAsset, assetOptions: nil, uri: source.uri ?? "")
Expand Down Expand Up @@ -467,16 +484,6 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_imaAdsManager.setUpAdsLoader()
}
#endif
// Perform on next run loop, otherwise onVideoLoadStart is nil
onVideoLoadStart?([
"src": [
"uri": _source?.uri ?? NSNull(),
"type": _source?.type ?? NSNull(),
"isNetwork": NSNumber(value: _source?.isNetwork ?? false),
],
"drm": _drm?.json ?? NSNull(),
"target": reactTag,
])
isSetSourceOngoing = false
applyNextSource()
}
Expand Down Expand Up @@ -1296,7 +1303,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
}

func handleReadyForDisplay(changeObject _: Any, change _: NSKeyValueObservedChange<Bool>) {
onVideoBuffer?(["isBuffering": false, "target": reactTag as Any])
if _isBuffering {
_isBuffering = false
}
onReadyForDisplay?([
"target": reactTag,
])
Expand Down Expand Up @@ -1430,12 +1439,16 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
}

func handlePlaybackBufferKeyEmpty(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<Bool>) {
onVideoBuffer?(["isBuffering": true, "target": reactTag as Any])
if !_isBuffering {
_isBuffering = true
}
}

// Continue playing (or not if paused) after being paused due to hitting an unbuffered zone.
func handlePlaybackLikelyToKeepUp(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<Bool>) {
onVideoBuffer?(["isBuffering": false, "target": reactTag as Any])
if _isBuffering {
_isBuffering = false
}
}

func handleTimeControlStatusChange(player: AVPlayer, change: NSKeyValueObservedChange<AVPlayer.TimeControlStatus>) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-video",
"version": "6.0.0-rc.1",
"version": "6.0.0",
"description": "A <Video /> element for react-native",
"main": "lib/index",
"source": "src/index",
Expand Down
4 changes: 3 additions & 1 deletion src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
onAudioFocusChanged={
onAudioFocusChanged ? _onAudioFocusChanged : undefined
}
onReadyForDisplay={onReadyForDisplay ? _onReadyForDisplay : undefined}
onReadyForDisplay={
onReadyForDisplay || hasPoster ? _onReadyForDisplay : undefined
}
onPlaybackRateChange={
onPlaybackRateChange ? _onPlaybackRateChange : undefined
}
Expand Down

0 comments on commit 9ce1d95

Please sign in to comment.