Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media streaming issues with Chrome #55

Open
gordonnl opened this issue May 18, 2020 · 6 comments
Open

Media streaming issues with Chrome #55

gordonnl opened this issue May 18, 2020 · 6 comments

Comments

@gordonnl
Copy link

Hey mate, I've been running into a couple issues with how Chrome handles media (audio/video):

  • Without the response header Content-Length, checking media.duration returns Infinity.

  • Without serving the requested chunk (Content-Range), changing media.currentTime just makes the file play from the beginning (as the whole file is returned).

In comparison, Firefox has neither issue.

I recall reading about this a long time ago, and found it weird how Chrome kept re-downloading the video assets with experiences that involve changing the currentTime, but I'm not sure how best to work streaming into Servor. Any ideas/thoughts?

Cheers.

@lukejacksonn
Copy link
Owner

Ahh interesting.. I don't have many projects that serve media so I haven't come across it. Happy to take a look though!

I wonder if just adding content-length will help 🤔 or if we have to go full content-range and streams. Is the reproduction just load a video in a video tab then try seek (change currentTime)?

@gordonnl
Copy link
Author

Yeah same, that's why I've only just noticed!

So the Content-Length is enough if you just need to check duration, but it doesn't solve the seeking issue.

To reproduce, just create an index.html with <audio controls src="music.mp3"></audio> as the content with any old audio file, and serve it. Then observe the inability to seek in Chrome.

@gordonnl
Copy link
Author

I managed to hack it to work using this as a guide.

The main changes I've found are that it needs the Content-Range header, and to be a readable stream using fs.createReadStream(uri, { start, end }).pipe(res) rather than res.write() and res.end().

@lukejacksonn
Copy link
Owner

Well, that sounds doable! Do you have it working in a fork of servor? If so I'd love to see a PR.

@gordonnl
Copy link
Author

I have a modified version of it - I just threw the main file up here for you to check!

@lukejacksonn
Copy link
Owner

Thanks 🙇 this will speed things up a lot but not 100% sure exactly when I will get around to implementing. Will leave this issue open in case anyone else wants to tackle it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants