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

Fix/ensure view drop stop playback startup #3875

Merged

Conversation

freeboub
Copy link
Collaborator

@freeboub freeboub commented Jun 4, 2024

Summary

Ensure View drop stop playback startup

Motivation

Fix real time issue when view drop during playback startup
Fix: #3567

Changes

Android: Add flags to save when view has dropped
Ios: clear RCTVideo class member

⚠️ android fix is workaround, need deeper refactor for a clean fix

Test plan

Tested with following patch in the sample

@@ -87,10 +87,11 @@ interface StateType {
   showRNVControls: boolean;
   useCache: boolean;
   poster?: string;
   showNotificationControls: boolean;
   isSeeking: boolean;
+  _key: number;
 }
 
 class VideoPlayer extends Component {
   state: StateType = {
     rate: 1,
@@ -118,10 +119,11 @@ class VideoPlayer extends Component {
     showRNVControls: false,
     useCache: false,
     poster: undefined,
     showNotificationControls: false,
     isSeeking: false,
+    _key: 0,
   };
 
   // internal usage change to index if you want to select tracks by index instead of lang
   textTracksSelectionBy = 'index';
 
@@ -555,10 +557,20 @@ class VideoPlayer extends Component {
         },
       });
     }
   };
 
+  componentDidMount(): void {
+      //this.setState({_key: this.state._key + 1})
+      setTimeout(()=> {
+        this.setState({_key: this.state._key + 1})
+        setTimeout(()=> {
+          this.setState({_key: this.state._key + 1})
+        }, 3000)
+      })
+    }
+
   onSelectedTextTrackChange = (itemValue: string) => {
     console.log('on value change ' + itemValue);
     this.setState({
       selectedTextTrack: {
         type: this.textTracksSelectionBy === 'index' ? 'index' : 'language',
@@ -760,10 +772,11 @@ class VideoPlayer extends Component {
     const additionnal = currentSrc as AdditionnalSourceInfo;
 
     return (
       <TouchableOpacity style={viewStyle}>
         <Video
+          key={this.state._key}
           showNotificationControls={this.state.showNotificationControls}
           ref={(ref: VideoRef) => {
             this.video = ref;
           }}
           source={currentSrc as ReactVideoSource}

freeboub and others added 19 commits May 5, 2024 21:06
…ideo

# Conflicts:
#	android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java
#	src/Video.tsx
…fix/avoidVideoResizingFlickering

# Conflicts:
#	.github/ISSUE_TEMPLATE/bug-report.yml
Copy link
Member

@KrzysztofMoch KrzysztofMoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense ✅

@freeboub freeboub merged commit 8693dbc into TheWidlarzGroup:master Jun 6, 2024
9 checks passed
KrzysztofMoch pushed a commit that referenced this pull request Jun 7, 2024
…ture semantics explicit (#3764) (#3881)

* Fix/ensure view drop stop playback startup (#3875)

* fix: ensure player doesn't start when view is unmounted

* Patch commit to fix the error:
  Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit

---------

Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>
KrzysztofMoch pushed a commit that referenced this pull request Jun 24, 2024
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (#3875)

* fix: ensure player doesn't start when view is unmounted

* chore(docs): fix typo
KrzysztofMoch added a commit that referenced this pull request Jul 10, 2024
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* chore(android): refactor DRM props into a dedicated class

* Update android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* chore: fix linter

* fix: ensure drm prop is correctly cleaned

* feat(android): move viewType (secure texture) & drm inside the source

The origianl behavior has been kept for interoperability, but marked as deprecated in doc

* chore: fix linter

* chore(ios): move drm prop in source like on android

* chore: fix linter

* chore: clean log

* fix: allow to disable secure View

* chore: fix viewType resolution (source value was not handled)

* chore: use contentDeepEquals instead of manual checks

* chore: fix linter

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (#3875)

* fix: ensure player doesn't start when view is unmounted

* chore: revert change

* chore: add warning in case of invalid Surface configuration

* chore: code clean

* fix: simplify surface management

* chore: restore previous code

* chore: fix typo

* chore: code cleanup

* feat(android): add multiDrm flag support

* docs: update docs

* chore: fix ios build

* chore: fix deprecated declaration

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
moskalakamil pushed a commit to moskalakamil/react-native-video that referenced this pull request Jul 12, 2024
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* chore(android): refactor DRM props into a dedicated class

* Update android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* chore: fix linter

* fix: ensure drm prop is correctly cleaned

* feat(android): move viewType (secure texture) & drm inside the source

The origianl behavior has been kept for interoperability, but marked as deprecated in doc

* chore: fix linter

* chore(ios): move drm prop in source like on android

* chore: fix linter

* chore: clean log

* fix: allow to disable secure View

* chore: fix viewType resolution (source value was not handled)

* chore: use contentDeepEquals instead of manual checks

* chore: fix linter

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (TheWidlarzGroup#3875)

* fix: ensure player doesn't start when view is unmounted

* chore: revert change

* chore: add warning in case of invalid Surface configuration

* chore: code clean

* fix: simplify surface management

* chore: restore previous code

* chore: fix typo

* chore: code cleanup

* feat(android): add multiDrm flag support

* docs: update docs

* chore: fix ios build

* chore: fix deprecated declaration

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
moskalakamil pushed a commit to moskalakamil/react-native-video that referenced this pull request Jul 17, 2024
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* chore(android): refactor DRM props into a dedicated class

* Update android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* chore: fix linter

* fix: ensure drm prop is correctly cleaned

* feat(android): move viewType (secure texture) & drm inside the source

The origianl behavior has been kept for interoperability, but marked as deprecated in doc

* chore: fix linter

* chore(ios): move drm prop in source like on android

* chore: fix linter

* chore: clean log

* fix: allow to disable secure View

* chore: fix viewType resolution (source value was not handled)

* chore: use contentDeepEquals instead of manual checks

* chore: fix linter

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (TheWidlarzGroup#3875)

* fix: ensure player doesn't start when view is unmounted

* chore: revert change

* chore: add warning in case of invalid Surface configuration

* chore: code clean

* fix: simplify surface management

* chore: restore previous code

* chore: fix typo

* chore: code cleanup

* feat(android): add multiDrm flag support

* docs: update docs

* chore: fix ios build

* chore: fix deprecated declaration

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
KrzysztofMoch pushed a commit that referenced this pull request Jul 22, 2024
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (#3875)

* fix: ensure player doesn't start when view is unmounted

* chore: fix app boot due to missing registered events

* chore: fix linter

* chore: fix build

* fix: handle code review feedbacks

* chore: revert previous change to handle only necessary fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Ios single video making or repeating multiple sound
2 participants