videojs / videojs-youtube

YouTube playback technology for Video.js
1.12k stars 548 forks source link

How to play hls video #611

Open vanminhquangtri opened 11 months ago

vanminhquangtri commented 11 months ago

Hello, I have read the docs but the no guidance for play hls video, such is file m3u8. My website provide line channel stream as well as movies. My video url is same format with: https://some.domain/index.m3u8

Can you please give me an example how to run this? Thank you.

vanminhquangtri commented 11 months ago

I see this website use video-youtube for hls vod. But don't know how they do https://pops.vn/video/cam-y-chi-ha-tap-1-61721faa70b7b600556dfb4e

mister-ben commented 11 months ago

The videojs-youtbe tech is not used for HLS. The default build of Video.js includes HLS support. Just load a source specifying the type,

<source src="video/test.m3u8" type="application/x-mpegURL">

or

player.src({
  src: 'https://example.com/video.m3u8',
  type: 'applicaiton/x-mpegURL'
});
vanminhquangtri commented 11 months ago

@mister-ben thank you for your email. Yes I know with Videojs we can run hls. My main purpose is to make my hls video auto play without unmuted. Like the below webite do. https://pops.vn/video/cam-y-chi-ha-tap-1-61721faa70b7b600556dfb4e

As you can see, they use library videojs-youtube. They auto play video unmuted. I am trying to do this but not success.

mister-ben commented 11 months ago

I can't see what's happening on that website die to its geo restrictions, but there is no trickery in videojs-youtube to workaround autoplay restrictions, and having the videojs-youtube tech present when a non-Youtube source is used will do nothing. On Chrome, autoplay with sound is allowed if the user's Media Engagement Index for the website is above a threshold, so your experience might not be the same as others.