kas*_*kas 6 flutter flutter-video-player
是否可以使用 flutter video_player 跳转到某个时间戳并显示帧而不启动视频?
只有当我在seekTo之后立即调用play时,我才能更改帧。
_videoPlayerController.seekTo(Duration(milliseconds: value));
_videoPlayerController.play();
Run Code Online (Sandbox Code Playgroud)
我也尝试过
_videoPlayerController.seekTo(Duration(milliseconds: value));
_videoPlayerController.play();
_videoPlayerController.pause();
Run Code Online (Sandbox Code Playgroud)
但它不会改变视频的显示帧。
小智 0
这个答案可能来得有点晚了,完全是一个黑客它不应该被真正使用,但它允许我有类似的行为
据我所知,VideoPlayerController 没有任何方式与有关帧的视频进行交互,只有使用seekTo您使用的方法的时间戳。您只需要在操作之间稍微延迟play一下pause,并将其包装在异步函数中,以便您可以等待操作完成,本质上是这样的:
void moveOneFrameForward() async {
//Gets the current time point at where the video is at in a "Duration" type object
var currentTime = await _videoPlayerController.position;
//Seeks to the current time + an interval, in this case 100ms
await _videoPlayerController.seekTo(
Duration(milliseconds: currentTime!.inMilliseconds + 100),
);
//Plays the video so to render a frame
await _videoPlayerController.play();
//Delay so that the frame is rendered
await Future.delayed(Duration(milliseconds: 10));
//Video is paused to display the frame
await _videoPlayerController.pause();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
978 次 |
| 最近记录: |