-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat: implement capture method #3577
feat: implement capture method #3577
Conversation
@@ -68,6 +68,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |||
private var _presentingViewController: UIViewController? | |||
private var _pictureInPictureEnabled = false | |||
private var _startPosition: Float64 = -1 | |||
private var _playerOutput: AVPlayerItemVideoOutput? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it increase memory usage significantly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know, it depends on resolution or bitrate
8c5e4da
to
a7feb7e
Compare
@@ -265,6 +266,13 @@ const Video = forwardRef<VideoRef, ReactVideoProps>( | |||
return VideoManager.setPlayerPauseState(false, getReactTag(nativeRef)); | |||
}, []); | |||
|
|||
const capture = useCallback(() => { | |||
if (drm) { | |||
throw Error('"capture" method can not be called with "drm" prop'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throwing an exception is a bit violent ? console.warn should be enough ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And BTW, you may defined an empty object in drm... I think you can just remove the test and handle it correctly in native code !
|
||
<PlatformsList types={['iOS', 'Android']} /> | ||
|
||
`capture(): Promise<void>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to manage the generate file here ?
2 solutions:
- allows to give a path / file path in parameters
- give the generated file path in promise result
Because, here, I cannot know where the file is generated
import android.view.SurfaceView | ||
import android.view.TextureView | ||
import android.view.View | ||
import androidx.media3.common.util.Util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import should not be in common folder : import androidx.media3.common.util.Util
Any way to remove it ?
@freeboub @KrzysztofMoch |
Summary
Implement capture method
Motivation
Actually this feature(save image file) doesn't related player feature, but it is so much hard to implement within JS side or other native module. so I create this PR.
(If it doesn't fit your development plan, please close it.)
Changes
add method named
capture
Test plan
just call
await videoRef.current.capture()
without below propsand check below setup