A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/media_source_extensions/MediaSource below:

MediaSource ยท WebPlatform Docs

MediaSource Summary

Represents a source of media data (audio or video) for a media element.

Overview

Provides a buffer based source for a media object. The app creates a MediaSource object and adds it to the media (audio or video) object as a source for the src object. SourceBuffers are then added to the MediaSource object and media content is then appended to the buffers to provide streaming or multi-source playback.

var mediaSource = new MediaSource();

Properties

No properties.

Methods
addSourceBuffer
Creates a new SourceBuffer and adds it to the SourceBuffers property of the MediaSource.
appendBuffer
Appends the specified media segment to the SourceBuffer.
endOfStream
Used to indicate that the end of the stream has been reached.
Events

No events.

Examples

This example creates a new MediaSource object and adds it to a video object. It then adds a sourceBuffer and calls to start loading content.

The live sample only runs on a browser that support the W3C syntax and MP4 files.


function setupVideo() {
  
  if (window.MediaSource) {
    mediaSource = new window.MediaSource();
  } else {
    log("mediasource or syntax not supported");
    return;
  }
  var url = URL.createObjectURL(mediaSource);
  videoElement.src = url;

  
  
  mediaSource.addEventListener('sourceopen', function (e) {
    try {
      videoSource = mediaSource.addSourceBuffer('video/mp4');
      
    } catch (e) {
      
      return;
    }
  });
}

View live example

Related specifications
Media Source Extensions
W3C Candidate Recommendation
See also Related articles Multimedia

}

}

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4