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

(ios): XHUB-5692: Apply fork modification to 6.X version #25

Merged
merged 38 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
744f050
from:
plozinski Jun 12, 2024
f1e7ec6
from:
plozinski Jun 12, 2024
51033e8
from:
plozinski Jun 12, 2024
84e5c58
from:
plozinski Jun 12, 2024
23dab1f
from:
plozinski Jun 12, 2024
3a903b2
from:
plozinski Jun 12, 2024
5e3132e
from:
plozinski Jun 12, 2024
1a47e35
from:
plozinski Jun 12, 2024
1960c34
from:
plozinski Jun 13, 2024
4605fef
from:
plozinski Jun 13, 2024
cab2919
from:
plozinski Jun 13, 2024
927d692
from:
plozinski Jun 13, 2024
a83755b
from:
plozinski Jun 13, 2024
4736c31
from:
plozinski Jun 13, 2024
06a7230
from:
plozinski Jun 13, 2024
4174ef4
sh scripts/swift-format.sh
plozinski Jun 13, 2024
b94214a
make lint happy
plozinski Jun 13, 2024
facf558
Update names in Video.tsx
plozinski Jun 13, 2024
d604093
sh scripts/clang-format.sh
plozinski Jun 13, 2024
83cfe3b
JS fixes
romansavka-mq Jun 14, 2024
6cec1c7
fix swift errors
plozinski Jun 14, 2024
5ea059c
Revert "from:"
plozinski Jun 14, 2024
1b96ed6
Replace onPlayedTracksChange with 3 callbacks.
plozinski Jun 14, 2024
4014fe7
Update changelog.
plozinski Jun 16, 2024
bb82c67
Update docs.
plozinski Jun 16, 2024
7eecb12
(android): fix cookiePolicy property typo
romansavka-mq Jun 14, 2024
41274a7
Merge branch 'main-dxp' into ios/dxp-5.x-alignment
plozinski Jun 17, 2024
38f906a
Restore --enable isEmpty swiftformat rule.
plozinski Jun 17, 2024
5281591
Remove onPlayedTracksChange.
plozinski Jun 17, 2024
6d63ae0
Update docs with info about iOS platform support.
plozinski Jun 17, 2024
9fd785f
Update changelog.
plozinski Jun 17, 2024
61c4e72
Current videos in swift.
plozinski Jun 17, 2024
13bfaf9
Update logic for tracks info events.
plozinski Jun 17, 2024
0f621d0
Post review changes.
plozinski Jun 18, 2024
5311020
Update docs.
plozinski Jun 18, 2024
484a58d
Update event on audio track
plozinski Jun 18, 2024
05f7932
Update video/audio tracks structures in JS
romansavka-mq Jun 18, 2024
ddedec8
Expose codecs on audio tracks from android
romansavka-mq Jun 18, 2024
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
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# [6.1.2+dolbyxp.1.2](https://github.com/miquido/react-native-video/compare/6.1.2+dolbyxp.1.1...miquido:react-native-video:6.1.2+dolbyxp.1.2)


### Features

* **ios:** XHUB-5327 - Expose channel (HLS) and Dolby SupplementalProperty (DASH) values from currently played resource to ReactNative
([675207f](https://github.com/miquido/react-native-video/commit/675207f6dbe7b817bb2c19292a9c487406b36ea1)
([a6823bb])(https://github.com/miquido/react-native-video/commit/a6823bbca0cfa135b995bd2117f18b6834ba20ad)
* **ios:** Add onVideoTracks event.
([1b96ed6])(https://github.com/miquido/react-native-video/pull/25/commits/1b96ed6025d65484ddab7391366c8c97ea788938)
([13bfaf9])(https://github.com/miquido/react-native-video/pull/25/commits/13bfaf9753597008ae32ba50404eb350d8e9b111)
* **ios:** Attempt to sync two videos.
([300794d])(https://github.com/miquido/react-native-video/commit/300794dd73d36c6722106ad6ec3399a580d3c407)

### Bug Fixes

* **ios:** Fix displaying string uri
([320985f])(https://github.com/miquido/react-native-video/commit/320985f7afef60a3a1e647dc02df1b5630ac7359)
* **ios:** Removed unused method
([ce29859])(https://github.com/miquido/react-native-video/commit/ce2985978d036fe0685355c6a760157603243acb)
* **ios:** Add proper audio parsing
([2c55b87])(https://github.com/miquido/react-native-video/commit/2c55b87d693cfe39651086811ebaf6a61a0c51da)
* **ios:** Fix autoplay & playing after buffering
([8a15097])(https://github.com/miquido/react-native-video/commit/8a150978234cdb2efbdd1a84dcab29fef09c08f8)
* **ios:** Adding Dolby Atmos workaround.
([3030ddd])(https://github.com/miquido/react-native-video/commit/3030ddd01a9a50b730ec0af13dc0650296347402)
* **ios:** Fix for tvOS native audio menu language selector
([a42240d])(https://github.com/miquido/react-native-video/commit/a42240d5543cbc9f7c11a0692c05d625d345457a)

# [6.1.2+dolbyxp.1.1](https://github.com/miquido/react-native-video/compare/6.1.2+dolbyxp.1.0...miquido:react-native-video:6.1.2+dolbyxp.1.1)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public void load(
int videoWidth,
int videoHeight,
List<TrackInfo> audioTracks,
List<TrackInfo> videoTracks, List<TrackInfo> textTracks,
List<TrackInfo> videoTracks,
List<TrackInfo> textTracks,
@Nullable Object manifest,
String trackId) {
WritableMap event = Arguments.createMap();
event.putDouble(EVENT_PROP_DURATION, duration / 1000D);
Expand All @@ -210,12 +212,12 @@ public void load(
event.putString(EVENT_PROP_TRACK_ID, trackId);
WritableArray videoTrackArray = Arguments.createArray();
for (TrackInfo track : videoTracks) {
videoTrackArray.pushMap(createVideoTrackInfo(track, false, null));
videoTrackArray.pushMap(createVideoTrackInfo(track, false, manifest));
}
event.putArray(EVENT_PROP_VIDEO_TRACKS, videoTrackArray);
WritableArray audioTrackArray = Arguments.createArray();
for (TrackInfo track : audioTracks) {
audioTrackArray.pushMap(createAudioTrackInfo(track, false, null));
audioTrackArray.pushMap(createAudioTrackInfo(track, false, manifest));
}
event.putArray(EVENT_PROP_AUDIO_TRACKS, audioTrackArray);
WritableArray textTrackArray = Arguments.createArray();
Expand Down Expand Up @@ -457,6 +459,7 @@ private static WritableMap createAudioTrackInfo(TrackInfo track, boolean selecte
audioTrack.putString("type", format.sampleMimeType);
audioTrack.putString("language", format.language);
audioTrack.putInt("bitrate", format.bitrate == Format.NO_VALUE ? 0 : format.bitrate);
audioTrack.putString("codecs", format.codecs);
audioTrack.putBoolean("selected", selected);
if (manifest != null) {
Representation representation = ManifestUtils.getRepresentationOf(manifest, track);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ private void videoLoaded() {
TracksUtil.getAudioTracks(info),
TracksUtil.getVideoTracks(info),
TracksUtil.getTextTracks(info),
player.getCurrentManifest(),
trackId
);
}
Expand Down
26 changes: 14 additions & 12 deletions docs/pages/component/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ An **array** of
| trackId | string | Track ID of the video track (android only) |
| title | string | Descriptive name for the track |
| language | string | 2 letter [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) representing the language |
| bitrate | number | bitrate of track |
| type | string | Mime type of track |
| bitrate | number | bitrate of track (android only) |
| type | string | Mime type of track (android only) |
| selected | boolean | true if track is playing |
| file | string | File name from DASH manifest (android only) |
| file | string | File name from DASH manifest on Android and M3U8 file on iOS |
| supplementalProperties | string | Supplemental properties for the adaptation set from DASH manifest (android only) |
| codecs | string | MimeType of codec used for this track |
| channels | array | Relevant to ports of hardware channels (iOS only) |

Example:

Expand Down Expand Up @@ -547,23 +549,23 @@ Example:

### `onVideoTracks`

<PlatformsList types={['Android']} />
<PlatformsList types={['Android', 'iOS']} />

Callback function that is called when video tracks change

Payload:

| Property | Type | Description |
| -------- | ------- | ------------|
| index | number | Track index |
| trackId | string | Track ID of the video track |
| index | number | Track index (android only) |
| trackId | string | Track ID of the video track (android only) |
| codecs | string | MimeType of codec used for this track |
| width | number | Track width |
| height | number | Track height |
| bitrate | number | Bitrate in bps |
| selected | boolean | true if track is selected for playing |
| file | string | File name from DASH manifest |
| supplementalProperties | string | Supplemental properties for the adaptation set from DASH manifest |
| width | number | Track width (android only) |
| height | number | Track height (android only) |
| bitrate | number | Bitrate in bps (android only) |
| selected | boolean | true if track is selected for playing (android only) |
| file | string | File name from DASH manifest on Android and M3U8 file on iOS |
| supplementalProperties | string | Supplemental properties for the adaptation set from DASH manifest (android only) |

Example:

Expand Down
12 changes: 12 additions & 0 deletions docs/pages/component/methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import PlatformsList from '../../components/PlatformsList/PlatformsList.tsx';

This page shows the list of available methods

### `setPrincipalVideoId`

<PlatformsList types={['iOS']} />

Method is used to assign an ID to the principal video for synchronization purposes.

### `setPeripheralVideoId`

<PlatformsList types={['iOS']} />

Method is used to assign an ID to the peripheral video for synchronization purposes.

### `dismissFullscreenPlayer`

<PlatformsList types={['Android', 'iOS']} />
Expand Down
12 changes: 12 additions & 0 deletions docs/pages/component/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ This page shows the list of available properties to configure player

## Details

### `principalVideo`

<PlatformsList types={['iOS']} />

The principal video property denotes the primary video source used for synchronization purposes.

### `peripheralVideo`

<PlatformsList types={['iOS']} />

The peripheral video property denotes the secondary video source used for synchronization purposes.

### `adTagUrl`

<PlatformsList types={['Android', 'iOS']} />
Expand Down
10 changes: 10 additions & 0 deletions ios/RCTVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
0177D39827170A7A00F5BE18 /* RCTVideo-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RCTVideo-Bridging-Header.h"; path = "Video/RCTVideo-Bridging-Header.h"; sourceTree = "<group>"; };
0177D39927170A7A00F5BE18 /* RCTVideo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideo.swift; path = Video/RCTVideo.swift; sourceTree = "<group>"; };
134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
DCD62EF02C20781F00669DF5 /* WeakVideoRef.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WeakVideoRef.swift; path = Video/WeakVideoRef.swift; sourceTree = "<group>"; };
DCD62EF12C20781F00669DF5 /* CurrentVideos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CurrentVideos.swift; path = Video/CurrentVideos.swift; sourceTree = "<group>"; };
DCD62EF32C20BB4200669DF5 /* PlayerModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PlayerModels.swift; path = Video/PlayerModels.swift; sourceTree = "<group>"; };
DCD62EF52C20BBC400669DF5 /* Dictionary+Merge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Dictionary+Merge.swift"; path = "Video/Dictionary+Merge.swift"; sourceTree = "<group>"; };
DCF8FF322C1AF64800CCA6B0 /* M3U8Kit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = M3U8Kit; path = Video/M3U8Kit; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -87,13 +92,18 @@
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
DCF8FF322C1AF64800CCA6B0 /* M3U8Kit */,
01489050272001A100E69940 /* DataStructures */,
01489051272001A100E69940 /* Features */,
0177D39527170A7A00F5BE18 /* RCTSwiftLog */,
0177D39927170A7A00F5BE18 /* RCTVideo.swift */,
DCD62EF12C20781F00669DF5 /* CurrentVideos.swift */,
DCD62EF02C20781F00669DF5 /* WeakVideoRef.swift */,
DCD62EF32C20BB4200669DF5 /* PlayerModels.swift */,
0177D39727170A7A00F5BE18 /* RCTVideoManager.m */,
0177D39227170A7A00F5BE18 /* RCTVideoManager.swift */,
0177D39427170A7A00F5BE18 /* RCTVideoPlayerViewController.swift */,
DCD62EF52C20BBC400669DF5 /* Dictionary+Merge.swift */,
0177D39627170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift */,
0177D39327170A7A00F5BE18 /* UIView+FindUIViewController.swift */,
0177D39827170A7A00F5BE18 /* RCTVideo-Bridging-Header.h */,
Expand Down
25 changes: 25 additions & 0 deletions ios/Video/CurrentVideos.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class CurrentVideos {
private var videos: [NSNumber: WeakVideoRef] = .init()

class var sharedInstance: CurrentVideos {
enum Shared {
static let instance = CurrentVideos()
}
return Shared.instance
}

func add(video: RCTVideo, for tag: NSNumber) {
let ref: WeakVideoRef = .init(video)
videos[tag] = ref
}

func video(for tag: NSNumber) -> RCTVideo? {
videos[tag]?.video
}

private func cleanup() {
for key in videos.keys where videos[key]?.video == nil {
videos.removeValue(forKey: key)
}
}
}
7 changes: 7 additions & 0 deletions ios/Video/Dictionary+Merge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extension Dictionary {
mutating func merge(dict: [Key: Value]) {
for (k, v) in dict {
updateValue(v, forKey: k)
}
}
}
40 changes: 37 additions & 3 deletions ios/Video/Features/RCTPlayerOperations.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AVFoundation
import MediaAccessibility
import MediaPlayer

let RCTVideoUnset = -1

Expand All @@ -9,6 +10,8 @@ let RCTVideoUnset = -1
* Collection of mutating functions
*/
enum RCTPlayerOperations {
static var remoteCommandHandlerForSpatialAudio: Any?

static func setSideloadedText(player: AVPlayer?, textTracks: [TextTrack], criteria: SelectedTrackCriteria?) {
let type = criteria?.type

Expand Down Expand Up @@ -116,12 +119,20 @@ enum RCTPlayerOperations {
}
}
} else { // default. invalid type or "system"
await player?.currentItem?.selectMediaOptionAutomatically(in: group)
#if os(tvOS)
// Do noting. Fix for tvOS native audio menu language selector
#else
await player?.currentItem?.selectMediaOptionAutomatically(in: group)
#endif
return
}

// If a match isn't found, option will be nil and text tracks will be disabled
await player?.currentItem?.select(mediaOption, in: group)
#if os(tvOS)
// Do noting. Fix for tvOS native audio menu language selector
#else
// If a match isn't found, option will be nil and text tracks will be disabled
await player?.currentItem?.select(mediaOption, in: group)
#endif
}

static func seek(player: AVPlayer, playerItem: AVPlayerItem, paused: Bool, seekTime: Float, seekTolerance: Float, completion: @escaping (Bool) -> Void) {
Expand Down Expand Up @@ -196,4 +207,27 @@ enum RCTPlayerOperations {
}
}
}

// MARK: - Spatial Audio / Dolby Atmos Workaround

/* These functions are a temporarily workaround to enable the rendering of Dolby Atmos on
* iOS 15 and above.
*/

static func addSpatialAudioRemoteCommandHandler() {
let command = MPRemoteCommandCenter.shared().playCommand

remoteCommandHandlerForSpatialAudio = command.addTarget(handler: { _ in
MPRemoteCommandHandlerStatus.success
})
}

static func removeSpatialAudioRemoteCommandHandler() {
let command = MPRemoteCommandCenter.shared().playCommand

if let remoteCommand = RCTPlayerOperations.remoteCommandHandlerForSpatialAudio {
command.removeTarget(remoteCommand)
RCTPlayerOperations.remoteCommandHandlerForSpatialAudio = nil
}
}
}
Loading
Loading