首页 > 解决方案 > 当expo av本机控件被触发/调用时触发回调?

问题描述

我正在尝试使用 expo-av 在视频中实现 firebase 视频分析:https ://docs.expo.io/versions/latest/sdk/video/

我想要实现的是在调用本机控件时使用回调。eg: play, pause, next/prev 15 secs, 是用原生控件调用的吗?我不太确定要使用什么,我需要知道如何完成它,因为我无法真正看到周围的示例实现。帮助?

标签: react-nativeexpo

解决方案


你可能需要onPlaybackStatusUpdate 道具。

请参阅https://github.com/expo/playlist-example/blob/master/App.js#L510中的示例

          <Video
            ref={this._mountVideo}
            style={[
              styles.video,
              {
                opacity: this.state.showVideo ? 1.0 : 0.0,
                width: this.state.videoWidth,
                height: this.state.videoHeight
              }
            ]}
            resizeMode={Video.RESIZE_MODE_CONTAIN}
            onPlaybackStatusUpdate={this._onPlaybackStatusUpdate}
            onLoadStart={this._onLoadStart}
            onLoad={this._onLoad}
            onError={this._onError}
            onFullscreenUpdate={this._onFullscreenUpdate}
            onReadyForDisplay={this._onReadyForDisplay}
            useNativeControls={this.state.useNativeControls}
          />

推荐阅读