gpt4 book ai didi

javascript - 如何确定视频是否刚刚完成使用 expo.video? ReactNative/Expo.io

转载 作者:行者123 更新时间:2023-12-03 11:17:31 30 4
gpt4 key购买 nike

例如,如果我有组件:

import React, { Component } from 'react';
import { Video } from 'expo';
let styles = require('../stylesheet.js');
export default class Player extends Component {
render(){
return(
<Video
ref={this._handleVideoRef}
source={require(//file)}
rate={1.0}
volume={1.0}
muted={false}
useNativeControls
resizeMode="cover"
shouldPlay
style={styles.player} />
)
}
}

我在文档( https://docs.expo.io/versions/latest/sdk/av.html)中看到使用“playbackstatus.didJustFinish”和 onPlaybackStatusUpdate,但他们的示例对我来说没有多大意义。谁能告诉我如何使用我的代码确定视频是否已结束?

最佳答案

如果其他人来寻找答案,以下是 OP 和文档的组合(https://docs.expo.io/versions/latest/sdk/av.html):

import React, { Component } from 'react';
import { Video } from 'expo';

export default class Player extends Component {
_onPlaybackStatusUpdate = playbackStatus => {
if (playbackStatus.didJustFinish)
// The player has just finished playing and will stop.
};

render(){
return(
<Video
ref={this._handleVideoRef}
source={require(//file)}
onPlaybackStatusUpdate=
{(playbackStatus) => this._onPlaybackStatusUpdate(playbackStatus)}/>
resizeMode="cover"
style={styles.player}
);
}
}

关于javascript - 如何确定视频是否刚刚完成使用 expo.video? ReactNative/Expo.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45897748/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com