Var audio = document.createElement('audio') audio.src = 'audio.oga' ntrols = true (audio) Var video = document.createElement('video') video.src = 'video.ogv' ntrols = true (video) Here's how to create a video element and insert it as the last child of body: An audio element doesn't need to be in the document to play sound, but it does if you want to show the browser's controls. For a video to render anything, you also need to insert it in the document. You can also create video and audio elements with script. The audio element works much the same as the video element, except it doesn't show any video, and some features that only makes sense for videos are missing. While you're at it you could add video/mp4 for mp4 extensions. That sets the right type for Ogg audio as well. Here's how to fix this for Apache servers add the following lines to your. So if it doesn't play, your server might not know about the ogv file extension and serve the video as text/plain, which Opera refuses to play. Current Opera requires that your video file is served as video/ogg (or audio/ogg, or application/ogg, or audio/wav.) for it to play. The text "video not supported" will be shown if the browser doesn't support the video element you could replace this with a link to the video file itself, or maybe an object element to display an alternative version with a plugin, eg Flash.ĭepending on how your server is configured, the video might or might not actually play. The browser's controls can still be enabled by the user from the context menu in Opera, and when scripting is disabled, Opera's controls are present regardless of the controls attribute. If you want to write your own controls with JavaScript, you just leave out the controls attribute. The controls attribute instructs the browser to provide its own controls. So now you have a video lying around on your server (or your local disk), and you want to play it in HTML. You can use Miro or another program of choice to do this. If you have a video that you want to play but it's not in Ogg/WebM, you need to convert it. Opera currently supports Ogg/WebM, which is also supported by Firefox and Chrome. So, how do we get a video to play in HTML? First you need an actual video in the right format. playbackRate and defaultPlaybackRate don't affect playback speed or direction.Ĭurrently Opera supports the WebM container format with the VP8 and Vorbis codecs, the Ogg container format with the Theora and Vorbis codecs, and the WAVE container format and PCM codec.The buffered, seekable and played IDL attributes always return empty TimeRanges objects.( autobuffer was changed to preload in the spec Opera has autobuffer in the DOM but it doesn't do anything.) The preload attribute is not supported.Opera supports everything in the HTML5 video spec with the following exceptions: This article aims to provide all the nitty-gritty details of HTML5 media, the DOM API, events, and so forth, so you can implement your own HTML5 player with fallback for older browsers.Įditor's note: This article was originally published on the Opera Core Concerns blog, but we liked it so much that we convinced Simon to let us publish it here as well. Accessible HTML5 Video with JavaScripted captions shows how captions can be implemented until the spec gains proper support for captions and (re-)Introducing has some information on Opera's implementation. But how do you use them? Introduction to HTML5 video is a great general introduction but doesn't go deep into the details. The latest version of Opera supports the HTML5 video and audio elements.
0 Comments
Leave a Reply. |