Search code examples
javascriptgoogle-cloud-storagefirebase-storagehttp-live-streamingexoplayer

m3u8 file which stored in Firebase storage does not play on web players


I have stored m3u8 file in firebase cloud storage and this is URL for m3u8 file

[https://firebasestorage.googleapis.com/v0/b/testing-musicoi.appspot.com/o/MediaContent%2F240p%2F240_out.m3u8?alt=media&token=0f81947b-1df0-4333-ae67-bdf21b4c49cc]

This URL works perfectly when I use VLC Player on my computer but when I try the same link with web players like this HLS media player it does not work. Moreover, I want to know This m3u8 URL would not work with Android Exoplayer?


Solution

  • The web player relies on Cross-Origin Resource Sharing, that allows scripts on one domain to access data from another domain. This fails, because your origin domain does not allow access from other domains.

    You need to configure the Access-Control-Allow-Origin header to allow bitmovin.com (and other domains) to access your files.

    Edit your firebase.json and add or change the hosting section:

    "hosting": {
      "headers": [ {
        "source": "**/*.*",
        "headers": [ {
          "key": "Access-Control-Allow-Origin",
          "value": "*"
        } ]
      } ]
    }
    

    See Firebase documentation.