In realtà, sono riuscito a far funzionare correttamente il codice di Trevor nel mio progetto. Ho dovuto aggiungere un tag di chiusura all'elemento source, in questo modo.
<video id="background-video" loop autoPlay>
<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4" />
<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg" />
Your browser does not support the video tag.
</video>
Si noti inoltre che 'autoplay' deve essere modificato in 'autoPlay' o reagire getterà un avvertimento a voi e non auto riprodurre il video. Al di fuori di questi due cambiamenti, copiare e incollare il codice dovrebbe funzionare bene.
ES6/Babel esempio:
'use strict';
import React, {Component} from 'react';
class Example extends Component {
constructor (props) {
super(props);
this.state = {
videoURL: 'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4'
}
}
render() {
return (
<video id="background-video" loop autoPlay>
<source src={this.state.videoURL} type="video/mp4" />
<source src={this.state.videoURL} type="video/ogg" />
Your browser does not support the video tag.
</video>
)
}
};
export default Example;
fonte
2016-03-26 04:57:09
Grazie mille per la risposta. Temo che questo non sia il rendering nel mio componente React, solo perché sembra che non sappia cos'è un tag
LOL scusa non ho visto che hai usato reagire –
Non sono sicuro di come reagire ... Scusa –