Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

videojs-contrib-media-sources

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-contrib-media-sources - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

2

package.json
{
"name": "videojs-contrib-media-sources",
"version": "0.3.1",
"version": "0.3.2",
"description": "A Media Source Extensions plugin for video.js",

@@ -5,0 +5,0 @@ "main": "videojs-media-sources.js",

@@ -104,3 +104,2 @@ (function(window){

videojs.MediaSource.prototype.endOfStream = function(){
this.swfObj.vjs_endOfStream();
this.readyState = 'ended';

@@ -180,9 +179,2 @@ };

// schedule another append if necessary
if (bufferSize !== 0) {
scheduleTick(append);
} else {
self.trigger({ type: 'updateend' });
}
// base64 encode the bytes

@@ -195,3 +187,3 @@ for (i = 0, length = payload.byteLength; i < length; i++) {

// bypass normal ExternalInterface calls and pass xml directly
// EI can be slow by default
// IE can be slow by default
self.source.swfObj.CallFunction('<invoke name="vjs_appendBuffer"' +

@@ -201,4 +193,11 @@ 'returntype="javascript"><arguments><string>' +

'</string></arguments></invoke>');
};
// schedule another append if necessary
if (bufferSize !== 0) {
scheduleTick(append);
} else if (self.source.readyState === 'ended') {
self.source.swfObj.vjs_endOfStream();
}
};
videojs.SourceBuffer.prototype.init.call(this);

@@ -213,2 +212,3 @@ this.source = source;

this.source.readyState = 'open';
this.trigger({ type: 'update' });

@@ -215,0 +215,0 @@

@@ -121,2 +121,72 @@ (function(window, document, videojs) {

test('calls endOfStream on the swf after the last append', function() {
var
sourceBuffer = mediaSource.addSourceBuffer('video/flv');
videojs.MediaSource.BYTES_PER_SECOND_GOAL = 60;
mediaSource.swfObj.vjs_endOfStream = function() {
swfCalls.push('endOfStream');
};
sourceBuffer.appendBuffer(new Uint8Array([0,1]));
//ready state is ended when the last segment has been appended
//to the mediaSource
sourceBuffer.source.readyState = 'ended';
timers.pop()();
strictEqual(swfCalls.length, 1, 'made one append');
ok(swfCalls.pop().indexOf(window.btoa(String.fromCharCode(0))) > 0,
'contains the first byte');
timers.pop()();
strictEqual(swfCalls.length, 2, 'two calls should have been made');
ok(swfCalls.shift().indexOf(window.btoa(String.fromCharCode(1))) > 0,
'the first call should contain the second byte');
ok(swfCalls.shift().indexOf('endOfStream') === 0,
'the second call should be for the updateend');
strictEqual(timers.length, 0, 'no more appends are scheduled');
});
test('opens the stream on sourceBuffer.appendBuffer after endOfStream', function() {
var
sourceBuffer = mediaSource.addSourceBuffer('video/flv');
videojs.MediaSource.BYTES_PER_SECOND_GOAL = 60;
mediaSource.swfObj.vjs_endOfStream = function() {
swfCalls.push('endOfStream');
};
sourceBuffer.appendBuffer(new Uint8Array([0,1]));
//ready state is ended when the last segment has been appended
//to the mediaSource
sourceBuffer.source.readyState = 'ended';
timers.pop()();
strictEqual(swfCalls.length, 1, 'made one append');
ok(swfCalls.pop().indexOf(window.btoa(String.fromCharCode(0))) > 0,
'contains the first byte');
timers.pop()();
strictEqual(swfCalls.length, 2, 'two calls should have been made');
ok(swfCalls.shift().indexOf(window.btoa(String.fromCharCode(1))) > 0,
'the first call should contain the second byte');
ok(swfCalls.shift().indexOf('endOfStream') === 0,
'the second call should be for the updateend');
sourceBuffer.appendBuffer(new Uint8Array([2]));
timers.pop()();
strictEqual(swfCalls.length, 1, 'made one append');
ok(swfCalls.pop().indexOf(window.btoa(String.fromCharCode(2))) > 0,
'contains the third byte');
strictEqual(sourceBuffer.source.readyState, 'open',
'The streams should be open if more bytes are appended to an "ended" stream');
strictEqual(timers.length, 0, 'no more appends are scheduled');
});
test('abort() clears any buffered input', function() {

@@ -123,0 +193,0 @@ var sourceBuffer = mediaSource.addSourceBuffer('video/flv');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc