Skip to content

Commit

Permalink
chore: bump to 6.0.0-alpha.6
Browse files Browse the repository at this point in the history
  • Loading branch information
remigallego committed Apr 25, 2024
1 parent 7fe9b6f commit 1f7a981
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 170 deletions.
26 changes: 26 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ Video with caching ([more info](docs/caching.md)):
end
```

#### Enable custom feature in podfile file

##### Google IMA

Google IMA is the google SDK to support Client Side Ads Integration (CSAI), see [google documentation](https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side) for more informations.

To enable google IMA usage define add following line in your podfile:
```podfile
$RNVideoUseGoogleIMA=true
```

</details>

### tvOS installation
Expand Down Expand Up @@ -916,6 +927,21 @@ The following other types are supported on some platforms, but aren't fully docu
`content://, ms-appx://, ms-appdata://, assets-library://`


##### Playing only a portion of the video (start & end time)

Provide an optional `startTime` and/or `endTime` for the video. Value is in milliseconds. Useful when you want to play only a portion of a large video.

Example
```
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', startTime: 36012, endTime: 48500 }}
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', startTime: 36012 }}
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', endTime: 48500 }}
```

Platforms: iOS, Android

#### subtitleStyle

Property | Description | Platforms
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### Version 6.0.0-alpha.6
- Feature: Video range support [#3030](https://github.com/react-native-video/react-native-video/pull/3030)
- iOS: remove undocumented `currentTime` property [#3064](https://github.com/react-native-video/react-native-video/pull/3064)
- iOS: make sure that the audio in ads is muted when the player is muted. [#3068](https://github.com/react-native-video/react-native-video/pull/3077)
- iOS: make IMA build optionnal

### Version 6.0.0-alpha.5

- iOS: ensure controls are not displayed when disabled by user [#3017](https://github.com/react-native-video/react-native-video/pull/3017)
Expand Down
31 changes: 9 additions & 22 deletions Video.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ImagePropTypes, ViewPropTypes } from 'deprecated-react-native-prop-types';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { findNodeHandle, Image, NativeModules, Platform, requireNativeComponent, StyleSheet, UIManager, View } from 'react-native';
import PropTypes from 'prop-types';
import { StyleSheet, requireNativeComponent, NativeModules, UIManager, View, Image, Platform, findNodeHandle } from 'react-native';
import { ViewPropTypes, ImagePropTypes } from 'deprecated-react-native-prop-types';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import DRMType from './DRMType';
import FilterType from './FilterType';
import TextTrackType from './TextTrackType';
import FilterType from './FilterType';
import DRMType from './DRMType';
import VideoResizeMode from './VideoResizeMode.js';

const styles = StyleSheet.create({
Expand All @@ -15,7 +15,7 @@ const styles = StyleSheet.create({
});

const { VideoDecoderProperties } = NativeModules

Check warning on line 17 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

Check warning on line 17 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
export { TextTrackType, FilterType, DRMType, VideoDecoderProperties };
export { TextTrackType, FilterType, DRMType, VideoDecoderProperties }

Check warning on line 18 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

Check warning on line 18 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

export default class Video extends Component {

Expand Down Expand Up @@ -77,7 +77,7 @@ export default class Video extends Component {
this.setNativeProps({ fullscreen: false });
};

save = async (options) => {
save = async (options?) => {
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
}

Expand Down Expand Up @@ -189,12 +189,6 @@ export default class Video extends Component {
}
};

_onOrientationChange = (event) => {
if (this.props.onOrientationChange) {
this.props.onOrientationChange(event.nativeEvent);
}
};

_onFullscreenPlayerDidDismiss = (event) => {
if (this.props.onFullscreenPlayerDidDismiss) {
this.props.onFullscreenPlayerDidDismiss(event.nativeEvent);
Expand Down Expand Up @@ -348,6 +342,8 @@ export default class Video extends Component {
mainVer: source.mainVer || 0,
patchVer: source.patchVer || 0,
requestHeaders: source.headers ? this.stringsOnlyObject(source.headers) : {},
startTime: source.startTime || 0,
endTime: source.endTime

Check warning on line 346 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma

Check warning on line 346 in Video.js

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma
},
onVideoLoadStart: this._onLoadStart,
onVideoPlaybackStateChanged: this._onPlaybackStateChanged,
Expand All @@ -368,7 +364,6 @@ export default class Video extends Component {
onVideoFullscreenPlayerDidPresent: this._onFullscreenPlayerDidPresent,
onVideoFullscreenPlayerWillDismiss: this._onFullscreenPlayerWillDismiss,
onVideoFullscreenPlayerDidDismiss: this._onFullscreenPlayerDidDismiss,
onVideoPlayerOrientationChange: this._onOrientationChange,
onReadyForDisplay: this._onReadyForDisplay,
onPlaybackStalled: this._onPlaybackStalled,
onPlaybackResume: this._onPlaybackResume,
Expand Down Expand Up @@ -527,7 +522,6 @@ Video.propTypes = {
disableBuffering: PropTypes.bool,
controls: PropTypes.bool,
audioOnly: PropTypes.bool,
currentTime: PropTypes.number,
fullscreenAutorotate: PropTypes.bool,
fullscreenOrientation: PropTypes.oneOf(['all', 'landscape', 'portrait']),
progressUpdateInterval: PropTypes.number,
Expand Down Expand Up @@ -557,25 +551,18 @@ Video.propTypes = {
onFullscreenPlayerDidPresent: PropTypes.func,
onFullscreenPlayerWillDismiss: PropTypes.func,
onFullscreenPlayerDidDismiss: PropTypes.func,
onOrientationChange: PropTypes.func,
onReadyForDisplay: PropTypes.func,
onPlaybackStalled: PropTypes.func,
onPlaybackResume: PropTypes.func,
onPlaybackRateChange: PropTypes.func,
onAudioFocusChanged: PropTypes.func,
onAudioBecomingNoisy: PropTypes.func,
onPictureInPictureStatusChanged: PropTypes.func,
needsToRestoreUserInterfaceForPictureInPictureStop: PropTypes.func,
onExternalPlaybackChange: PropTypes.func,
adTagUrl: PropTypes.string,
onReceiveAdEvent: PropTypes.func,

/* Required by react-native */
scaleX: PropTypes.number,
scaleY: PropTypes.number,
translateX: PropTypes.number,
translateY: PropTypes.number,
rotation: PropTypes.number,
...ViewPropTypes,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.google.android.exoplayer2.C.CONTENT_TYPE_HLS;
import static com.google.android.exoplayer2.C.CONTENT_TYPE_OTHER;
import static com.google.android.exoplayer2.C.CONTENT_TYPE_SS;
import static com.google.android.exoplayer2.C.TIME_END_OF_SOURCE;

import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down Expand Up @@ -93,6 +94,7 @@
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.source.ClippingMediaSource;

import com.google.common.collect.ImmutableList;
import java.net.CookieHandler;
Expand Down Expand Up @@ -181,6 +183,8 @@ class ReactExoplayerView extends FrameLayout implements
// Props from React
private int backBufferDurationMs = DefaultLoadControl.DEFAULT_BACK_BUFFER_DURATION_MS;
private Uri srcUri;
private long startTimeMs = -1;
private long endTimeMs = -1;
private String extension;
private boolean repeat;
private String audioTrackType;
Expand Down Expand Up @@ -301,9 +305,7 @@ private void createViews() {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// uncommented `initializePlayer()`, because it caused video to restart when it is running
// behind another screen and the user navigated back to the screen where the video runs
// initializePlayer();
initializePlayer();
}

@Override
Expand Down Expand Up @@ -671,7 +673,7 @@ private DrmSessionManager initializePlayerDrm(ReactExoplayerView self) {

private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) {
ArrayList<MediaSource> mediaSourceList = buildTextSources();
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager, startTimeMs, endTimeMs);
MediaSource mediaSourceWithAds = null;
if (adTagUrl != null) {
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
Expand Down Expand Up @@ -766,7 +768,7 @@ private DrmSessionManager buildDrmSessionManager(UUID uuid, String licenseUrl, S
}
}

private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessionManager drmSessionManager) {
private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessionManager drmSessionManager, long startTimeMs, long endTimeMs) {
if (uri == null) {
throw new IllegalStateException("Invalid video uri");
}
Expand All @@ -783,7 +785,7 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessi
}

MediaItem mediaItem = mediaItemBuilder.build();

MediaSource mediaSource = null;
DrmSessionManagerProvider drmProvider = null;
if (drmSessionManager != null) {
drmProvider = new DrmSessionManagerProvider() {
Expand All @@ -797,39 +799,54 @@ public DrmSessionManager get(MediaItem mediaItem) {
}
switch (type) {
case CONTENT_TYPE_SS:
return new SsMediaSource.Factory(
mediaSource = new SsMediaSource.Factory(
new DefaultSsChunkSource.Factory(mediaDataSourceFactory),
buildDataSourceFactory(false)
).setDrmSessionManagerProvider(drmProvider)
.setLoadErrorHandlingPolicy(
config.buildLoadErrorHandlingPolicy(minLoadRetryCount)
).createMediaSource(mediaItem);
break;
case CONTENT_TYPE_DASH:
return new DashMediaSource.Factory(
mediaSource = new DashMediaSource.Factory(
new DefaultDashChunkSource.Factory(mediaDataSourceFactory),
buildDataSourceFactory(false)
).setDrmSessionManagerProvider(drmProvider)
.setLoadErrorHandlingPolicy(
config.buildLoadErrorHandlingPolicy(minLoadRetryCount)
).createMediaSource(mediaItem);
break;
case CONTENT_TYPE_HLS:
return new HlsMediaSource.Factory(
mediaSource = new HlsMediaSource.Factory(
mediaDataSourceFactory
).setDrmSessionManagerProvider(drmProvider)
.setLoadErrorHandlingPolicy(
config.buildLoadErrorHandlingPolicy(minLoadRetryCount)
).createMediaSource(mediaItem);
break;
case CONTENT_TYPE_OTHER:
return new ProgressiveMediaSource.Factory(
mediaSource = new ProgressiveMediaSource.Factory(
mediaDataSourceFactory
).setDrmSessionManagerProvider(drmProvider)
.setLoadErrorHandlingPolicy(
config.buildLoadErrorHandlingPolicy(minLoadRetryCount)
).createMediaSource(mediaItem);
break;
default: {
throw new IllegalStateException("Unsupported type: " + type);
}
}

if (startTimeMs >= 0 && endTimeMs >= 0)
{
return new ClippingMediaSource(mediaSource, startTimeMs * 1000, endTimeMs * 1000);
} else if (startTimeMs >= 0) {
return new ClippingMediaSource(mediaSource, startTimeMs * 1000, TIME_END_OF_SOURCE);
} else if (endTimeMs >= 0) {
return new ClippingMediaSource(mediaSource, 0, endTimeMs * 1000);
}

return mediaSource;
}

private ArrayList<MediaSource> buildTextSources() {
Expand Down Expand Up @@ -1467,19 +1484,20 @@ public void onMetadata(Metadata metadata) {

// ReactExoplayerViewManager public api

public void setSrc(final Uri uri, final String extension, Map<String, String> headers) {
public void setSrc(final Uri uri, final long startTimeMs, final long endTimeMs, final String extension, Map<String, String> headers) {
if (uri != null) {
boolean isSourceEqual = uri.equals(srcUri);
boolean isSourceEqual = uri.equals(srcUri) && startTimeMs == this.startTimeMs && endTimeMs == this.endTimeMs;
hasDrmFailed = false;
this.srcUri = uri;
this.startTimeMs = startTimeMs;
this.endTimeMs = endTimeMs;
this.extension = extension;
this.requestHeaders = headers;
this.mediaDataSourceFactory =
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
this.requestHeaders);

if (!isSourceEqual) {
Log.d("PLAYER", "reload1");
reloadSource();
}
}
Expand All @@ -1490,6 +1508,8 @@ public void clearSrc() {
player.stop();
player.clearMediaItems();
this.srcUri = null;
this.startTimeMs = -1;
this.endTimeMs = -1;
this.extension = null;
this.requestHeaders = null;
this.mediaDataSourceFactory = null;
Expand Down Expand Up @@ -1517,15 +1537,13 @@ public void setRawSrc(final Uri uri, final String extension) {
this.mediaDataSourceFactory = buildDataSourceFactory(true);

if (!isSourceEqual) {
Log.d("PLAYER", "reload2");
reloadSource();
}
}
}

public void setTextTracks(ReadableArray textTracks) {
this.textTracks = textTracks;
Log.d("PLAYER", "reload3");
reloadSource();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerView> {

private static final String REACT_CLASS = "RCTVideo";

private static final String PROP_SRC = "src";
private static final String PROP_SRC_URI = "uri";
private static final String PROP_SRC_START_TIME = "startTime";
private static final String PROP_SRC_END_TIME = "endTime";
private static final String PROP_AD_TAG_URL = "adTagUrl";
private static final String PROP_SRC_TYPE = "type";
private static final String PROP_DRM = "drm";
Expand Down Expand Up @@ -152,6 +153,8 @@ public void setDRM(final ReactExoplayerView videoView, @Nullable ReadableMap drm
public void setSrc(final ReactExoplayerView videoView, @Nullable ReadableMap src) {
Context context = videoView.getContext().getApplicationContext();
String uriString = src.hasKey(PROP_SRC_URI) ? src.getString(PROP_SRC_URI) : null;
int startTimeMs = src.hasKey(PROP_SRC_START_TIME) ? src.getInt(PROP_SRC_START_TIME) : -1;
int endTimeMs = src.hasKey(PROP_SRC_END_TIME) ? src.getInt(PROP_SRC_END_TIME) : -1;
String extension = src.hasKey(PROP_SRC_TYPE) ? src.getString(PROP_SRC_TYPE) : null;
Map<String, String> headers = src.hasKey(PROP_SRC_HEADERS) ? toStringMap(src.getMap(PROP_SRC_HEADERS)) : null;

Expand All @@ -164,7 +167,7 @@ public void setSrc(final ReactExoplayerView videoView, @Nullable ReadableMap src
Uri srcUri = Uri.parse(uriString);

if (srcUri != null) {
videoView.setSrc(srcUri, extension, headers);
videoView.setSrc(srcUri, startTimeMs, endTimeMs, extension, headers);
}
} else {
int identifier = context.getResources().getIdentifier(
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ install! 'cocoapods', :deterministic_uuids => false
target 'videoplayer' do
config = use_native_modules!

# $RNVideoUseGoogleIMA = true

# Flags change depending on the env values.
flags = get_default_flags()

Expand Down
4 changes: 0 additions & 4 deletions ios/RCTVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
0177D39D27170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39627170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift */; };
0177D39E27170A7A00F5BE18 /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39727170A7A00F5BE18 /* RCTVideoManager.m */; };
0177D39F27170A7A00F5BE18 /* RCTVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39927170A7A00F5BE18 /* RCTVideo.swift */; };
832E109729C34D2100DD1D3A /* RCTPlayerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832E109629C34D2100DD1D3A /* RCTPlayerDelegate.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -50,7 +49,6 @@
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; };
83064F5229C350FE0060F947 /* RCTPlayerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RCTPlayerDelegate.swift; path = Video/RCTPlayerDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -89,7 +87,6 @@
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
83064F5229C350FE0060F947 /* RCTPlayerDelegate.swift */,
01489050272001A100E69940 /* DataStructures */,
01489051272001A100E69940 /* Features */,
0177D39527170A7A00F5BE18 /* RCTSwiftLog */,
Expand Down Expand Up @@ -192,7 +189,6 @@
0177D39B27170A7A00F5BE18 /* UIView+FindUIViewController.swift in Sources */,
0177D39F27170A7A00F5BE18 /* RCTVideo.swift in Sources */,
0177D39E27170A7A00F5BE18 /* RCTVideoManager.m in Sources */,
832E109729C34D2100DD1D3A /* RCTPlayerDelegate.swift in Sources */,
0177D39A27170A7A00F5BE18 /* RCTVideoManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Loading

0 comments on commit 1f7a981

Please sign in to comment.