|
@@ -11,6 +11,7 @@ import {
|
|
|
} from "react-native";
|
|
|
import { createStackNavigator, createAppContainer } from "react-navigation";
|
|
|
import Video from "react-native-video";
|
|
|
+import SeekBar from "../components/SeekBar";
|
|
|
const instructions = Platform.select({
|
|
|
ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
|
|
|
android:
|
|
@@ -45,6 +46,7 @@ export default class CusVideo extends React.Component {
|
|
|
// poster={this.props.poster}
|
|
|
resizeMode={this.state.resizeMode}
|
|
|
// posterResizeMode={this.state.resizeMode}
|
|
|
+ onBuffer={this.onBuffer}
|
|
|
rate={this.state.rate} //播放速率
|
|
|
paused={this.state.paused} //暂停
|
|
|
volume={this.state.volume} //调节音量
|
|
@@ -93,20 +95,16 @@ export default class CusVideo extends React.Component {
|
|
|
<View
|
|
|
style={{
|
|
|
flex: 7,
|
|
|
- backgroundColor: "yellow"
|
|
|
+ overflow: "hidden"
|
|
|
}}
|
|
|
>
|
|
|
{/* //中间进度条 */}
|
|
|
- {/* <SeekBar
|
|
|
- style={{
|
|
|
- flex: 1,
|
|
|
- alignItems: "center",
|
|
|
- justifyContent: "center",
|
|
|
- width: "100%"
|
|
|
- }}
|
|
|
- max={this.state.duration}
|
|
|
- progress={this.state.currentTime}
|
|
|
- /> */}
|
|
|
+ <SeekBar
|
|
|
+ style={{ flex: 1 }}
|
|
|
+ ref={view => (this.seekbar = view)}
|
|
|
+ //必须带此方法,作为滑动之后抬起的回调
|
|
|
+ touchUpCallBack={this.touch_up_callback.bind(this)}
|
|
|
+ />
|
|
|
</View>
|
|
|
<View style={{ flex: 3 }}>
|
|
|
{/* //右侧总时长 */}
|
|
@@ -131,14 +129,20 @@ export default class CusVideo extends React.Component {
|
|
|
loadStart() {
|
|
|
// alert("loadStart");
|
|
|
}
|
|
|
+ onBuffer({ isBuffering }: { isBuffering: boolean }) {
|
|
|
+ //true为正在加载,false为没有加载,此处给loading提示
|
|
|
+ console.log("isBuffering:" + isBuffering);
|
|
|
+ }
|
|
|
onLoad = data => {
|
|
|
//获取的是秒数
|
|
|
this.setState({ duration: data.duration });
|
|
|
+ this.seekbar.setMax(data.duration);
|
|
|
};
|
|
|
onProgress = data => {
|
|
|
this.setState({
|
|
|
currentTime: data.currentTime
|
|
|
});
|
|
|
+ this.seekbar.setProgress(this.state.currentTime);
|
|
|
};
|
|
|
|
|
|
onError() {
|
|
@@ -166,10 +170,23 @@ export default class CusVideo extends React.Component {
|
|
|
// ToastExample.message(params);
|
|
|
ToastExample.show(params, ToastExample.SHORT);
|
|
|
}
|
|
|
+ seekTo(progress) {
|
|
|
+ this.player.seek(progress);
|
|
|
+ }
|
|
|
presentFullscreenPlayer() {
|
|
|
// alert("点击调用全屏");
|
|
|
this.props.videofullScreenPlayer();
|
|
|
- // this.player.presentFullscreenPlayer();
|
|
|
+ console.log("currentTime:" + this.state.currentTime);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.seekbar.setProgress(this.state.currentTime);
|
|
|
+ }, 10);
|
|
|
+ }
|
|
|
+ touch_up_callback(progress) {
|
|
|
+ //抬起之后,获取算出来的progress
|
|
|
+ this.setState({
|
|
|
+ currentTime: progress
|
|
|
+ });
|
|
|
+ this.seekTo(progress);
|
|
|
}
|
|
|
|
|
|
refreshVideo() {
|