next-offline icon indicating copy to clipboard operation
next-offline copied to clipboard

Video not playing on Safari

Open GozuPro opened this issue 5 years ago • 5 comments

Hello there,

Are you aware with next-offline, mp4 videos aren't playing in Safari? However, they play perfectly with incognito browser.

Screen_Shot_2019-10-22_at_3_55_55_PM

Apparently, I found this article which explains the reason behind it: https://philna.sh/blog/2018/10/23/service-workers-beware-safaris-range-request/.

I would be interested to know if you will have the time to come-up with a short-term and long-term solution? At the moment, I'm using next-offline out-the-box, without configuration and would like to exclude videos (.mp4) for being served from service worker to avoid the issue. I'm not sure how to handle that. Please let me know if that makes sense.

Ugo

GozuPro avatar Oct 22 '19 22:10 GozuPro

I'm still doing some QA but believe @xcv58 fixed the issue with the following PR: https://github.com/xcv58/next-offline-issue-77/pull/1/files

GozuPro avatar Oct 24 '19 18:10 GozuPro

If it still doesn't work for you on Safari, probably caused by https://stackoverflow.com/a/14018708

https://stackoverflow.com/a/41831848

xcv58 avatar Oct 24 '19 18:10 xcv58

If you guys land on a good fix, I'd be more then happy to merge it if you send a PR my way!

hanford avatar Oct 25 '19 00:10 hanford

I'm still doing some QA but believe @xcv58 fixed the issue with the following PR: https://github.com/xcv58/next-offline-issue-77/pull/1/files

any update on this?

joeynelsonFF avatar Mar 17 '20 20:03 joeynelsonFF

I just hit the problem of video not playing on Safari: https://philna.sh/blog/2018/10/23/service-workers-beware-safaris-range-request/

I see this fix referenced above...

workbox.routing.registerRoute(
  /.mp4$/,
  workbox.strategies.cacheFirst({ plugins: [ new workbox.rangeRequests.Plugin() ] }), 'GET'
);

...but I am loading my content from a cdn so service worker doesn't respect /.mp4$/ from anywhere other than path in the browser. It needs to be something like https:\/\/cdn\.example\.com\/.*\.mp4$/ in my case.

So I think the question is, is it possible to pass plugins: [ new workbox.rangeRequests.Plugin() ] to runtimeCaching? So that something like:

runtimeCaching: [
    {
      urlPattern: /https:\/\/cdn\.example\.com\/.*\.mp4$/,
      handler: 'CacheFirst',
      options: {
        plugins: [ new workbox.rangeRequests.Plugin() ]
      }
    }
  ]

ends up creating:

workbox.routing.registerRoute(
  /https:\/\/cdn\.example\.com\/.*\.mp4$/,
  workbox.strategies.cacheFirst({ plugins: [ new workbox.rangeRequests.Plugin() ] }), 'GET'
);

nodabladam avatar May 09 '20 00:05 nodabladam