react项目中使用阿里播放器播放视频,包括切换视频,播放定时跳转(兼容ios和andro),播放完成
1.index.html引入阿里播放器的cdn
<link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css" />
2.创建播放器组件
需要播放器其他方法的可以参考阿里播放器SDK
阿里播放器SDK
import React from 'react';
import './style.less'
import { Tabs, Toast } from 'antd-mobile'
export default class H5Video extends React.Component {
constructor(props) {
super(props);
this.isLiving = false;
}
componentDidUpdate(prevProps) {//写在update是因为父组件切换视频时更新子组件
if (!this.player) {
this.setupPlayer();
} else {
// let isLiving = (this.props.liveInfo.liveStatus == 1);
// if (this.isLiving == isLiving) {
// this.player.loadByU