easyPlayer.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div id="easyplayer" ></div>
  3. </template>
  4. <script>
  5. export default {
  6. name: 'player',
  7. data() {
  8. return {
  9. easyPlayer: null
  10. };
  11. },
  12. props: ['videoUrl', 'error', 'hasaudio', 'height'],
  13. mounted () {
  14. let paramUrl = decodeURIComponent(this.$route.params.url)
  15. this.$nextTick(() =>{
  16. if (typeof (this.videoUrl) == "undefined") {
  17. this.videoUrl = paramUrl;
  18. }
  19. console.log("初始化时的地址为: " + this.videoUrl)
  20. this.play(this.videoUrl)
  21. })
  22. },
  23. watch:{
  24. videoUrl(newData, oldData){
  25. this.play(newData)
  26. },
  27. immediate:true
  28. },
  29. methods: {
  30. play: function (url) {
  31. console.log(this.height)
  32. if (this.easyPlayer != null) {
  33. this.easyPlayer.destroy();
  34. }
  35. if (typeof (this.height) == "undefined") {
  36. this.height = false
  37. }
  38. this.easyPlayer = new WasmPlayer(null, 'easyplayer', this.eventcallbacK, {Height: this.height})
  39. this.easyPlayer.play(url, 1)
  40. },
  41. pause: function () {
  42. this.easyPlayer.destroy();
  43. this.easyPlayer = null
  44. },
  45. eventcallbacK: function(type, message) {
  46. // console.log("player 事件回调")
  47. // console.log(type)
  48. // console.log(message)
  49. }
  50. },
  51. destroyed() {
  52. this.easyPlayer.destroy();
  53. },
  54. }
  55. </script>
  56. <style>
  57. .LodingTitle {
  58. min-width: 70px;
  59. }
  60. /* 隐藏logo */
  61. .iconqingxiLOGO {
  62. display: none !important;
  63. }
  64. </style>