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/addSourceBuffer below:

addSourceBuffer · WebPlatform Docs

addSourceBuffer Summary

Creates a new SourceBuffer and adds it to the SourceBuffers property of the MediaSource.

Method of apis/media_source_extensions/MediaSourceapis/media_source_extensions/MediaSource

Syntax
var sourcebuffer = MediaSource.addSourceBuffer(MIME type);
Parameters MIME type
Data-type
String

The MIME type. This is expressed typically as ‘video/mp4’ or optionally as a MIME type and a codec: 'video/mp4;codecs=avc1.4d0020,mp4a.40.2’. Internet Explorer accepts both formats, though other browsers may require the codec be included.

Return Value

Returns an object of type ObjectObject

Type: SourceBuffer The media source buffer.

Examples

This example gets a video object, creates a new MediaSource object, and assigns the MediaSource object to the src (source) of the video object. It then waits for the sourceopen event to fire, and then creates a video SourceBuffer using addSourceBuffer.




function setupVideo() {
  clearLog(); 

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

  
  
  mediaSource.addEventListener('sourceopen', function (e) {
    try {
      videoSource = mediaSource.addSourceBuffer('video/mp4');
      initVideo(initialization, file);
    } catch (e) {
      log('Exception calling addSourceBuffer for video', e);
      return;
    }
  },false);
}
Usage
 Exceptions:

INVALID_ACCESS_ERR If type is null or an empty string.

NOT_SUPPORTED_ERR If type contains a MIME type that’s not supported or a MIME type that’s not supported by SourceBuffer.

QUOTA_EXCEEDED_ERR If the mediaSource can’t handle any more SourceBuffer objects.

Related specifications
Media Source Extensions
W3C Candidate Recommendation
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