surmon-china / videojs-player

@videojs player component for @vuejs(3) and React.
https://github.surmon.me/videojs-player
MIT License
5.27k stars 1.13k forks source link

SOLVED: m3u8 streaming not working after build #143

Open silo opened 6 years ago

silo commented 6 years ago

Hi

It works perfectly when i am running: yarn dev, but when i build it, it won't work. Hope you guys can see what i do wrong, thanks in advance

console log on builded version

screen shot 2018-01-29 at 13 56 30

Versions:

"videojs-contrib-hls": "^5.12.2",
"vue": "^2.3.3",
"vue-video-player": "^5.0.1"

Build script from package.json

"build:mac": "node .electron-vue/build.js && electron-builder -m",

wepback.main.config.js

  module: {
    noParse: [/videojs-contrib-hls/],

video.vue

screen shot 2018-01-29 at 13 52 21
surmon-china commented 6 years ago

You can leave your text code, I tested locally.

surmon-china commented 6 years ago

@silo Sorry, I did not find the source of these two errors after my test, but I can be sure they are related to webpack compression plugin, you can refer to the discussion here, if the problem is solved, please leave your solution here Program, good luck!

silo commented 6 years ago

@surmon-china i havn't figured it out yet. i still have the problem after i run yarn build:mac. I will write here when/if i found a solution.

godIsAProgrammer commented 6 years ago

you can write noParse: [/videojs-contrib-hls/] in webpack.base.config.js . like this default

silo commented 6 years ago

Hi @godIsAProgrammer , i have tried that. didn't work. I get the same error when i run yarn build:web and running it in a chrome browser. BUT it works in safari. Hmmm... Could it be something with the chrome browser engine or something?

surmon-china commented 6 years ago

@silo I guess, this is due to the packaged code, in strict mode, and different browsers for different modes of handling different, the corresponding answer to this link should be helpful to you. https://github.com/videojs/videojs-contrib-hls/issues/600

silo commented 6 years ago

i solved it by using this : https://github.com/Peer5/videojs-contrib-hls.js

Jayant-Purohit commented 6 years ago

@silo please provide specific details on how you solve this by https://github.com/Peer5/videojs-contrib-hls.js

facing the same problem with the same error message you posted

silo commented 6 years ago

@Jayant-Purohit i have installed these packages:

"videojs-contrib-hls": "^5.12.2", "vue-video-player": "^5.0.1", <-- i don't think this is involved in the solution

in my Video.vue file:

<script>
import videojs from 'video.js'
window.videojs = videojs
require('videojs-contrib-hls/dist/videojs-contrib-hls.js')

export default {
  name: 'VideoPage',
  data () {
    return {
      selected: '',
      tvList: {
        'TV 2': 'http://tv2danmark-tv2nord-live.hls.adaptive.level3.net/tv2danmark/tv2nord/master3200kbps.m3u8',
        'Folketinget': 'http://httpcache1.dna.qbrick.com/90042-httpcache2/smil:FT_stream_high/playlist.m3u8'
      },
      playerOptions: {
        autoplay: false,
        fluid: true,
        preload: 'auto',
        sources: [{
          withCredentials: false,
          type: 'application/x-mpegURL',
          src: this.tvUrl
        }],
        controlBar: {
          timeDivider: false,
          durationDisplay: false
        },
        flash: {hls: { withCredentials: false }},
        html5: {hls: { withCredentials: true }}
      }
    }
  },
  methods: {
    playerReadied (player) {
      var hls = player.tech({ IWillNotUseThisInPlugins: false }).hls
      console.log(hls)
      player.tech_.hls.xhr.beforeRequest = function (options) {
        // console.log(options)
        return options
      }
    },
    onChange () {
      console.log(this.selectedTv)
      this.src = this.selectedTv
    }
  },
  beforeCreate: function () {
    this.tvUrl = 'http://tv2danmark-tv2nord-live.hls.adaptive.level3.net/tv2danmark/tv2nord/master3200kbps.m3u8'
  }
}
</script>

I hope this helps