HTML5 video tag support muted parameter
I am unable to use muted parameter for <video autoplay muted loop>.. . Other parameters for video seems fine.
Appears to work fine for me: http://jsfiddle.net/314xxopf/
@cometta, which browser you are using?
you are right. i retested it. sorry. I proceed to close it.
Strangely enough, I ran into the same issue today, on different Chrome versions. I tested with the fiddle above and the muted attribute is unavailable:

I expanded a bit @jimfb's fiddle at http://jsfiddle.net/wmzjzjmm/ to check server rendering and tested in Safari as well. renderToString rendered both muted and controls attributes, despite only the controls attribute showing up when using render:

The video is muted despite the attribute not showing up, but I can only access the attribute when I'm resuming a server render.
@moret When I run the code in your fiddle, the video appears to be muted (no sound). That's the only thing that React guarantees; React is not required to set the attribute if it is not required.
When rendering on the client we'll use the property since it was determined that modifying the attribute didn't actually affect the video. We must set it as node.muted = true|false, so you don't see that reflected in the attribute.
@zpao makes sense, and that explains well the difference between the seemingly similar attributes. Thanks for the explanation!
@zpao ohai, and also it seems that Mobile Safari in iOS10 uses the video's muted attribute to determine if the video can autoplay: https://webkit.org/blog/6784/new-video-policies-for-ios; having video.muted == true isn't enough.
I'd argue this needs to be reopened. This breaks iOS10 autoplay support.
<video muted>elements will also be allowed to autoplay without a user gesture.
and
<video>elements will be allowed toplay()without a user gesture if their source media contains no audio tracks, or if theirmutedproperty is set totrue.
These conflicting statements lead me to believe we can (and probably should) continue using the property. We might just need to ensure that muted is set before autoplay.
Can somebody having an issue share the code they're having an issue with (hi @aza!) - I can't repro the problem but I could be looking at the wrong thing. Here's what I have:
ReactDOM.render(
<video width="100%" controls autoPlay muted playsInline>
<source src="http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4" type="video/mp4" />
</video>,
document.getElementById('container')
);
This is rendering the video and autoplaying inline without any issue (iOS 10.1 in the simulator with React 15.4). If I leave off muted then it will not autoplay.
I have the same issue: react 15.4.2 + SSR
I'm (begrudgingly) working around this issue by using dangerouslySetInnerHTML:
const VideoWorkaround = ({ src }) => (
<div dangerouslySetInnerHTML={{ __html: `
<video
muted
autoplay
playsinline
src="${src}"
/>
` }}
/>
);
This issue should absolutely be reopened.
this is quite odd.
With both the regular JSX syntax and the template-string version posted by @kohlmannj, I'm seeing the muted attribute stripped off of the node. All other attributes are kept in tact.
<video
muted
playsInline
preload
loop
autoPlay
>
<source src={this.state.src} type="video/mp4" />
</video>
Any ideas what is going on here? This seems to work ok in iOS10, however Android seems to drop the muted attribute and just not play.
if I try to invoke play ie this.elementRef.play(), I get the must be initiated as a result of user interaction error.
Emulated Pixel on Android 7, mobile Chrome v.51.0.02704.90
Has anyone gotten autoplay video to work on Android with React?
Seems to work on iOS 10 with playsInline + autoPlay but cannot get it to work consistently on Android. Is this limited by Android version?
This is still an issue. Here was my original code:
const Video = ({ src, onEnded }) => (
<video src={src} autoPlay playsInLine muted onEnded={onEnded} ref="video"/>
)
It would load videos but wouldn't play them on iOS.
I fixed it by doing this, but it produces a laggy experience because the video doesn't play immediately.
class Video extends Component {
componentDidMount() { this.update(); }
componentDidUpdate() { this.update(); }
update() {
this.refs.video.setAttribute('muted', '1');
this.refs.video.setAttribute('playsinline', '1');
this.refs.video.setAttribute('autoplay', '1');
}
render() {
const { src, onEnded } = this.props;
return (
<video src={src} autoPlay playsInLine muted onEnded={onEnded} ref="video"/>
)
}
};
You can see the difference by going here on both iOS and Desktop. I haven't tried on Android.
I made a package to render a video tag using dangerouslySetInnerHTML.
It's pretty specific to my use case of animated gif like videos but feel free to send a PR or open an issue if you want something else.
https://github.com/DylanVann/react-video-tag
I enabled autoplay on iOS and React 16 with the videoelement defaultMuted property: https://gist.github.com/diuis/fc1c2f0e255538cda397c5a6b669c9bf
Um. We need the muted attribute in the HTML.
No limitation on autoplay muted video https://medium.com/@sundaykuloksun/video-play-not-working-html5-autoplay-policy-beed81d64ca5
Thanks @kohlmannj that worked for me. This issue needs to be fixed though, it's well documented that muted is required for auto playback on iOS.