初始化视频

  1. this.player = player = plus.video.createVideoPlayer('videoplayer', {
  2. src:'http://cdn.zsdx.cn/wei/images/hire/home/home_video.mp4',
  3. top:'30px',
  4. left:'0px',
  5. width: 'auto',
  6. height: '250px',
  7. position: 'static'
  8. });
  9. plus.webview.currentWebview().append(player);

播放视频

  1. this.player.play();

监听视频播放

  1. this.player.addEventListener('play', (e)=> {
  2. uni.showToast({
  3. title: '开始播放',
  4. icon: 'none',
  5. dura tion: 3000
  6. });
  7. }, false)

监听播放进度

  1. this.player.addEventListener('timeupdate', (e)=> {
  2. self.timeupdate = e.detail.currentTime;
  3. }, false);

暂停播放

  1. this.player.pause();

停止播放

  1. this.player.stop();

监听播放结束

  1. this.player.addEventListener('ended', function(e){
  2. uni.showToast({
  3. title: '播放结束',
  4. icon: 'none',
  5. duration: 3000
  6. });
  7. }, false);

设置全屏/退出全屏

  1. 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
  2. this.player.requestFullScreen(-90);

显示播放控件

  1. this.player.show();

关闭播放控件

  1. this.player.close();

设置播放倍速

  1. data () {
  2. return {
  3. index: 0
  4. }
  5. }
  6. let option = ['0.5', '0.8', '1.0', '1.25', '1.5'];
  7. uni.showToast({
  8. title: `${option[this.index]}倍速`,
  9. icon: 'none',
  10. duration: 3000
  11. });
  12. this.player.playbackRate(option[this.index]);
  13. this.index ++;
  14. if (this.index == 5) {
  15. this.index = 0;
  16. }