From f79782b4470f74c64926eff80db511596b07a05b Mon Sep 17 00:00:00 2001 From: Cameron Perry Date: Thu, 19 Nov 2020 16:18:31 -0800 Subject: [PATCH 1/6] =?UTF-8?q?Resolved=20an=20issue=20where=20setting=20a?= =?UTF-8?q?=20video=20to=20paused=20would=20ignore=20the=20=E2=80=9Csilent?= =?UTF-8?q?=20switch=E2=80=9D=20setting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Video/RCTVideo.m | 51 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 8780f48f..a4702cee 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -915,6 +915,7 @@ static int const RCTVideoUnset = -1; - (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch { _ignoreSilentSwitch = ignoreSilentSwitch; + [self configureAudio]; [self applyModifiers]; } @@ -930,29 +931,8 @@ static int const RCTVideoUnset = -1; [_player pause]; [_player setRate:0.0]; } else { - AVAudioSession *session = [AVAudioSession sharedInstance]; - AVAudioSessionCategory category = nil; - AVAudioSessionCategoryOptions options = nil; - if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { - category = AVAudioSessionCategoryPlayback; - } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { - category = AVAudioSessionCategoryAmbient; - } - - if([_mixWithOthers isEqualToString:@"mix"]) { - options = AVAudioSessionCategoryOptionMixWithOthers; - } else if([_mixWithOthers isEqualToString:@"duck"]) { - options = AVAudioSessionCategoryOptionDuckOthers; - } - - if (category != nil && options != nil) { - [session setCategory:category withOptions:options error:nil]; - } else if (category != nil && options == nil) { - [session setCategory:category error:nil]; - } else if (category == nil && options != nil) { - [session setCategory:session.category withOptions:options error:nil]; - } + [self configureAudio]; if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) { [_player playImmediatelyAtRate:_rate]; @@ -1086,6 +1066,33 @@ static int const RCTVideoUnset = -1; [self setAllowsExternalPlayback:_allowsExternalPlayback]; } +- (void)configureAudio +{ + AVAudioSession *session = [AVAudioSession sharedInstance]; + AVAudioSessionCategory category = nil; + AVAudioSessionCategoryOptions options = nil; + + if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { + category = AVAudioSessionCategoryPlayback; + } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { + category = AVAudioSessionCategoryAmbient; + } + + if([_mixWithOthers isEqualToString:@"mix"]) { + options = AVAudioSessionCategoryOptionMixWithOthers; + } else if([_mixWithOthers isEqualToString:@"duck"]) { + options = AVAudioSessionCategoryOptionDuckOthers; + } + + if (category != nil && options != nil) { + [session setCategory:category withOptions:options error:nil]; + } else if (category != nil && options == nil) { + [session setCategory:category error:nil]; + } else if (category == nil && options != nil) { + [session setCategory:session.category withOptions:options error:nil]; + } +} + - (void)setRepeat:(BOOL)repeat { _repeat = repeat; } From b5b5da0684195cb241100d818b76a9bf7800378d Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 30 Jun 2021 11:34:02 +0900 Subject: [PATCH 2/6] update exoplayer to allow pre-init and content clear --- README.md | 6 ++++++ .../exoplayer/ReactExoplayerView.java | 18 ++++++++++++++---- .../exoplayer/ReactExoplayerViewManager.java | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fd445187..ab9715d4 100644 --- a/README.md +++ b/README.md @@ -770,6 +770,12 @@ Platforms: Android ExoPlayer #### source Sets the media source. You can pass an asset loaded via require or an object with a uri. +Setting the source will trigger the player to attempt to load the provided media with all other given props. Please be sure that all props are provided before/at the same time as setting the source. + +Rendering the player component with a null source will init the player, and start playing once a source value is provided. + +Providing a null source value after loading a previous source will stop playback, and clear out the previous source content. + The docs for this prop are incomplete and will be updated as each option is investigated and tested. diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index d7c33214..fe95fdf4 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -465,6 +465,7 @@ class ReactExoplayerView extends FrameLayout implements player.prepare(mediaSource, !haveResumePosition, false); playerNeedsSource = false; + reLayout(exoPlayerView); eventEmitter.loadStart(); loadVideoStarted = true; } @@ -1012,7 +1013,6 @@ class ReactExoplayerView extends FrameLayout implements public void setSrc(final Uri uri, final String extension, Map headers) { if (uri != null) { - boolean isOriginalSourceNull = srcUri == null; boolean isSourceEqual = uri.equals(srcUri); this.srcUri = uri; @@ -1022,12 +1022,23 @@ class ReactExoplayerView extends FrameLayout implements DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter, this.requestHeaders); - if (!isOriginalSourceNull && !isSourceEqual) { + if (!isSourceEqual) { reloadSource(); } } } + public void clearSrc() { + if (srcUri != null) { + player.stop(true); + this.srcUri = null; + this.extension = null; + this.requestHeaders = null; + this.mediaDataSourceFactory = null; + clearResumePosition(); + } + } + public void setProgressUpdateInterval(final float progressUpdateInterval) { mProgressUpdateInterval = progressUpdateInterval; } @@ -1038,14 +1049,13 @@ class ReactExoplayerView extends FrameLayout implements public void setRawSrc(final Uri uri, final String extension) { if (uri != null) { - boolean isOriginalSourceNull = srcUri == null; boolean isSourceEqual = uri.equals(srcUri); this.srcUri = uri; this.extension = extension; this.mediaDataSourceFactory = buildDataSourceFactory(true); - if (!isOriginalSourceNull && !isSourceEqual) { + if (!isSourceEqual) { reloadSource(); } } diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 0d81e0b2..eccbee75 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -144,6 +144,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager headers = src.hasKey(PROP_SRC_HEADERS) ? toStringMap(src.getMap(PROP_SRC_HEADERS)) : null; if (TextUtils.isEmpty(uriString)) { + videoView.clearSrc(); return; } From a42240d5543cbc9f7c11a0692c05d625d345457a Mon Sep 17 00:00:00 2001 From: Shane Mckenna Date: Mon, 23 Aug 2021 11:59:53 -0700 Subject: [PATCH 3/6] Fix for tvOS native audio menu language selector --- ios/Video/RCTVideo.m | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index a4702cee..5021f95e 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -1134,12 +1134,20 @@ static int const RCTVideoUnset = -1; } } } else { // default. invalid type or "system" - [_player.currentItem selectMediaOptionAutomaticallyInMediaSelectionGroup:group]; - return; + #if TARGET_OS_TV + // Do noting. Fix for tvOS native audio menu language selector + #else + [_player.currentItem selectMediaOptionAutomaticallyInMediaSelectionGroup:group]; + return; + #endif } - - // If a match isn't found, option will be nil and text tracks will be disabled - [_player.currentItem selectMediaOption:mediaOption inMediaSelectionGroup:group]; + + #if TARGET_OS_TV + // 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 + [_player.currentItem selectMediaOption:mediaOption inMediaSelectionGroup:group]; + #endif } - (void)setSelectedAudioTrack:(NSDictionary *)selectedAudioTrack { From 31f866cd9f198cf3e1f5045bdf77a5952e62ab19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dalesjo=CC=88?= Date: Mon, 11 Oct 2021 10:20:32 +0200 Subject: [PATCH 4/6] Release 5.2.0-alpha1 --- CHANGELOG.md | 8 ++++++++ package.json | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f0646fa..7486298e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ - Fix Android AudioFocus bug that could cause player to not respond to play/pause in some instances [#2311](https://github.com/react-native-video/react-native-video/pull/2311) +### Version 5.2.0-alpha1 + +- Fix for tvOS native audio menu language selector +- Update ExoPlayer to allow pre-init and content clear [#2412] (https://github.com/react-native-video/react-native-video/pull/2412) +- iOS rate is reset to 1.0 after play/pause [#2167] (https://github.com/react-native-video/react-native-video/pull/2167) +- Upgrade ExoPlayer to 2.13.2 [#2317] (https://github.com/react-native-video/react-native-video/pull/2317) +- Fix AudoFocus pausing video when attempting to play [#2311] (https://github.com/react-native-video/react-native-video/pull/2311) + ### Version 5.1.0-alpha9 - Add ARM64 support for windows [#2137](https://github.com/react-native-community/react-native-video/pull/2137) diff --git a/package.json b/package.json index 136e59eb..12b6d9e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video", - "version": "5.1.1", + "version": "5.2.0-alpha1", "description": "A