方法参数说明
    play播放
    pause暂停
    seekposition跳转到指定位置,单位 s
    stop停止视频,仅微信小程序平台支持,
    sendDanmudanmu发送弹幕,danmu 包含两个属性 text, color
    playbackRaterate设置倍速播放,支持的倍率有 0.5/0.8/1.0/1.25/1.5
    requestFullScreen进入全屏,可传入{direction}参数,详见 video 组件文档
    exitFullScreen退出全屏
    showStatusBar显示状态栏,仅在iOS全屏下有效
    hideStatusBar隐藏状态栏,仅在iOS全屏下有效
    1. export default {
    2. data() {
    3. return {
    4. title: 'video',
    5. src: '',
    6. inputValue: '',
    7. danmuList: [{
    8. text: '第 1s 出现的弹幕',
    9. color: '#ff0000',
    10. time: 1
    11. },
    12. {
    13. text: '第 3s 出现的弹幕',
    14. color: '#ff00ff',
    15. time: 3
    16. }
    17. ]
    18. }
    19. onReady: function (res) {
    20. this.videoContext = uni.createVideoContext('myVideo')
    21. },
    22. methods: {
    23. bindInputBlur: function (e) {
    24. this.inputValue = e.target.value
    25. },
    26. bindButtonTap: function () {
    27. var that = this
    28. uni.chooseVideo({
    29. sourceType: ['album', 'camera'],
    30. maxDuration: 60,
    31. camera: ['front', 'back'],
    32. success: function (res) {
    33. this.src = res.tempFilePath
    34. }
    35. })
    36. },
    37. text: this.inputValue,
    38. color: this.getRandomColor()
    39. })
    40. },
    41. videoErrorCallback: function (e) {
    42. console.log('视频错误信息:')
    43. console.log(e.target.errMsg)
    44. },
    45. getRandomColor: function () {
    46. const rgb = []
    47. for (let i = 0; i < 3; ++i) {
    48. let color = Math.floor(Math.random() * 256).toString(16)
    49. color = color.length == 1 ? '0' + color : color
    50. rgb.push(color)
    51. }
    52. return '#' + rgb.join('')
    53. }
    54. }