Comments (9)
It looks like hls.js doesn't support iOS Safari, because iOS doesn't support media source extensions yet. Currently we are using hls.js as the only way of playing the video, so iOS isn't supported by this package.
from react-hls.
I was able achieve this by using the
.isSupported()
method from hls.js.Example React component as follows:
// Other imports import ReactHlsPlayer from 'react-hls-player'; import HlsJs from 'hls.js'; const Video = () => { let videoSource = VIDEO_SOURCE_MP4; // Safari browsers (iOS, ipadOS and macOS) have built in HLS support if (document.createElement('video').canPlayType('application/vnd.apple.mpegurl')) { videoSource = VIDEO_SOURCE_HLS; } return ( <div className="video"> {HlsJs.isSupported() ? ( <ReactHlsPlayer poster={VIDEO_POSTER} url={VIDEO_SOURCE_HLS} autoplay muted controls loop width="100%" /> ) : ( <video poster={VIDEO_POSTER} src={videoSource} autoPlay muted controls loop width="100%" /> )} </div> ); });Minor gripe that the casing of
autoPlay
between the video element andreact-hls-player
library and incompatible so you can't simply spread the common props.
Noted. I'll try to fix the props issue when I have a bit of extra time. I'll probably see about adding in this functionality as well to the library so it will do the checks of HLS compatibility and fallback to hls.js
from react-hls.
@toughdeveloper I've fixed the props issue in the latest version. The root level of the video player now supports all regular video element props with the proper casing. Another big change is the move from using url
to now using src
. This should make it easier to use all the common props that you'd expect from a video player. I haven't added the fallback to a regular video component yet when HLS is supported, but that's definitely on the agenda for something I'd like to do.
from react-hls.
Also doesn't worked in Chrome on IOS, so not a Safari issue. I guess what is really needed on IOS is a fallback to native player.
from react-hls.
Also doesn't worked in Chrome on IOS, so not a Safari issue. I guess what is really needed on IOS is a fallback to native player.
As far as I'm aware, all web browsers on iOS use the same engine that Safari uses. Apple doesn't allow custom web browsers. So even Google Chrome uses Safari's engine under the hood.
Unless something has changed recently
from react-hls.
I moved to react-player and now videos are playing on ios browsers
https://www.npmjs.com/package/react-player
from react-hls.
Thanks for sharing that @durgendra
from react-hls.
I was able achieve this by using the .isSupported()
method from hls.js.
Example React component as follows:
// Other imports
import ReactHlsPlayer from 'react-hls-player';
import HlsJs from 'hls.js';
const Video = () => {
let videoSource = VIDEO_SOURCE_MP4;
// Safari browsers (iOS, ipadOS and macOS) have built in HLS support
if (document.createElement('video').canPlayType('application/vnd.apple.mpegurl')) {
videoSource = VIDEO_SOURCE_HLS;
}
return (
<div className="video">
{HlsJs.isSupported() ? (
<ReactHlsPlayer
poster={VIDEO_POSTER}
url={VIDEO_SOURCE_HLS}
autoplay
muted
controls
loop
width="100%"
/>
) : (
<video
poster={VIDEO_POSTER}
src={videoSource}
autoPlay
muted
controls
loop
width="100%"
/>
)}
</div>
);
});
Minor gripe that the casing of autoPlay
between the video element and react-hls-player
library and incompatible so you can't simply spread the common props.
from react-hls.
Latest version works with Safari, using @toughdeveloper 's recommendation above. Closing this issue. Thank you for providing the solution to this.
from react-hls.
Related Issues (20)
- Player gets destroyed when interacting with components that use setState/state HOT 1
- TypeScript error - "playerRef" is required prop HOT 1
- this package is dead ? HOT 4
- react 17 support HOT 4
- Listen to video buffer data
- Use it in react native HOT 1
- Playback stalling at @59.598812 due to low buffer
- SSR error (Gatsby)
- How to start the player from a given location? HOT 1
- Multiple audio tracks not supported HOT 6
- use latest version of hls.js, and enable fetch loader? HOT 1
- Player start playing from start every time there is a state update with useSate HOT 1
- React-native app
- Stream is running in loop
- Open for contributors?
- NEW Package here: https://github.com/gumlet/react-hls-player HOT 4
- React 18 Support HOT 1
- HTTP “Content-Type” of “application/vnd.apple.mpegurl” is not supported. HOT 1
- Not able to play hls video in react-native-webview
- Seekbar is not working in IOS.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hls.