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

@brightcove/videojs-flashls-source-handler

Package Overview
Dependencies
Maintainers
48
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brightcove/videojs-flashls-source-handler - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

test/playlists.test.js

58

dist/videojs-flashls-source-handler.js
/**
* @brightcove/videojs-flashls-source-handler
* @version 1.2.0
* @version 1.3.0
* @copyright 2017 Brightcove

@@ -1038,2 +1038,3 @@ * @license Apache-2.0

exports.__esModule = true;
exports.FlashlsHandler = undefined;

@@ -1224,3 +1225,3 @@ var _video = (typeof window !== "undefined" ? window['videojs'] : typeof global !== "undefined" ? global['videojs'] : null);

var FlashlsHandler = function () {
var FlashlsHandler = exports.FlashlsHandler = function () {
function FlashlsHandler(source, tech, options) {

@@ -1247,2 +1248,15 @@ var _this = this;

Object.defineProperties(this, {
stats: {
get: function get() {
return this.tech_.el_.vjs_getProperty('stats');
}
},
bandwidth: {
get: function get() {
return this.tech_.el_.vjs_getProperty('stats').bandwidth;
}
}
});
this.tech_ = tech;

@@ -1269,5 +1283,12 @@ this.metadataTrack_ = null;

this.tech_.on('captiondata', this.onCaptionData_);
this.tech_.on('levelswitch', this.onLevelSwitch_);
this.metadataStream_.on('data', this.onMetadataStreamData_);
this.cea608Stream_.on('data', this.onCea608StreamData_);
this.playlists = {
media: function media() {
return _this.media_();
}
};
}

@@ -1302,2 +1323,23 @@

FlashlsHandler.prototype.media_ = function media_() {
var levels = this.tech_.el_.vjs_getProperty('levels');
var level = this.tech_.el_.vjs_getProperty('level');
var media = void 0;
if (levels.length) {
media = {
resolvedUri: levels[level].url,
attributes: {
BANDWIDTH: levels[level].bitrate,
RESOLUTION: {
width: levels[level].width,
height: levels[level].height
}
}
};
}
return media;
};
/**

@@ -1322,4 +1364,2 @@ * Event listener for the loadedmetadata event. This sets up the representations api

this.tech_.on('levelswitch', this.onLevelSwitch_);
// update initial selected index

@@ -1355,3 +1395,6 @@ updateSelectedIndex(this.qualityLevels_, this.tech_.el_.vjs_getProperty('level') + '');

FlashlsHandler.prototype.onLevelSwitch_ = function onLevelSwitch_(event, level) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
if (this.qualityLevels_) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
}
this.tech_.trigger({ type: 'mediachange', bubbles: true });
};

@@ -1539,6 +1582,6 @@

this.tech_.audioTracks().off('change', this.onAudioTrackChanged);
this.tech_.off('levelswitch', this.onLevelSwitch_);
if (this.qualityLevels_) {
this.qualityLevels_.dispose();
this.tech_.off('levelswitch', this.onLevelSwitch_);
}

@@ -1608,3 +1651,2 @@ };

tech.hls = new FlashlsHandler(source, tech, options);
tech.hls.src(source);

@@ -1619,3 +1661,3 @@ return tech.hls;

// Include the version number.
FlashlsSourceHandler.VERSION = '1.2.0';
FlashlsSourceHandler.VERSION = '1.3.0';

@@ -1622,0 +1664,0 @@ exports.default = FlashlsSourceHandler;

2

dist/videojs-flashls-source-handler.min.js

@@ -1,1 +0,1 @@

!function t(e,a,i){function n(s,o){if(!a[s]){if(!e[s]){var d="function"==typeof require&&require;if(!o&&d)return d(s,!0);if(r)return r(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=a[s]={exports:{}};e[s][0].call(h.exports,function(t){var a=e[s][1][t];return n(a||t)},h,h.exports,t,e,a,i)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,a){(function(t){"use strict";a.__esModule=!0,a.setupAudioTracks=a.updateAudioTrack=void 0;var e="undefined"!=typeof window?window.videojs:void 0!==t?t.videojs:null,i=function(t){return t&&t.__esModule?t:{default:t}}(e);a.updateAudioTrack=function(t){for(var e=t.el_.vjs_getProperty("audioTracks"),a=t.audioTracks(),i=null,n=0;n<a.length;n++)if(a[n].enabled){i=a[n].id;break}if(null!==i)for(var r=0;r<e.length;r++)if(i===e[r].title)return void t.el_.vjs_setProperty("audioTrack",r)},a.setupAudioTracks=function(t){var e=t.el_.vjs_getProperty("altAudioTracks"),a=t.el_.vjs_getProperty("audioTracks"),n=t.el_.vjs_getProperty("audioTrack");a.forEach(function(a,r){var s=e[a.id];t.audioTracks().addTrack(new i.default.AudioTrack({id:s.name,enabled:n===r,language:s.lang,default:s.default_track,label:s.name}))})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,a){"use strict";a.__esModule=!0;var i=a.createRepresentation=function(t,e){var a={id:e.index+"",width:e.width,height:e.height,bandwidth:e.bitrate,isEnabled_:!0};return a.enabled=function(e){if(void 0===e)return a.isEnabled_;e!==a.isEnabled_&&(!0!==e&&!1!==e||(a.isEnabled_=e,t()))},a};a.createRepresentations=function(t){var e=null,a=function(){var a=e.filter(function(t){return t.enabled()});if(a.length===e.length||0===a.length)return t.el_.vjs_setProperty("autoLevelCapping",-1),void t.el_.vjs_setProperty("level",-1);if(1===a.length)return t.el_.vjs_setProperty("level",parseInt(a[0].id,10)),void t.el_.vjs_setProperty("autoLevelCapping",-1);var i=a[a.length-1].id;t.el_.vjs_setProperty("autoLevelCapping",parseInt(i,10)),t.el_.vjs_setProperty("level",-1)};return function(){if(!e){var n=t.el_.vjs_getProperty("levels");e=n.filter(function(t){return!t.audio}).map(i.bind(null,a))}return e}}},{}],3:[function(t,e,a){(function(t){var a;a="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=a}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,a){"use strict";var i=t(7),n=function(t){for(var e=0,a={payloadType:-1,payloadSize:0},i=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)i+=255,e++;for(i+=t[e++];255===t[e];)n+=255,e++;if(n+=t[e++],!a.payload&&4===i){a.payloadType=i,a.payloadSize=n,a.payload=t.subarray(e,e+n);break}e+=n,i=0,n=0}return a},r=function(t){return 181!==t.payload[0]?null:49!=(t.payload[1]<<8|t.payload[2])?null:"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])?null:3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},s=function(t,e){var a,i,n,r,s=[];if(!(64&e[0]))return s;for(i=31&e[0],a=0;a<i;a++)n=3*a,r={type:3&e[n+2],pts:t},4&e[n+2]&&(r.ccData=e[n+3]<<8|e[n+4],s.push(r));return s},o=function(){o.prototype.init.call(this),this.captionPackets_=[],this.field1_=new c,this.field1_.on("data",this.trigger.bind(this,"data")),this.field1_.on("done",this.trigger.bind(this,"done"))};o.prototype=new i,o.prototype.push=function(t){var e,a;"sei_rbsp"===t.nalUnitType&&(e=n(t.escapedRBSP),4===e.payloadType&&(a=r(e))&&(this.captionPackets_=this.captionPackets_.concat(s(t.pts,a))))},o.prototype.flush=function(){if(!this.captionPackets_.length)return void this.field1_.flush();this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(this.field1_.push,this.field1_),this.captionPackets_.length=0,this.field1_.flush()};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608},l=function(t){return null===t?"":(t=d[t]||t,String.fromCharCode(t))},h=function(){for(var t=[],e=15;e--;)t.push("");return t},c=function(){c.prototype.init.call(this),this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=h(),this.nonDisplayed_=h(),this.lastControlCode_=null,this.push=function(t){if(0===t.type){var e,a,i,n;if((e=32639&t.ccData)===this.lastControlCode_)return void(this.lastControlCode_=null);switch(this.lastControlCode_=4096==(61440&e)?e:null,e){case 0:break;case 5152:this.mode_="popOn";break;case 5167:this.flushDisplayed(t.pts),a=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=a,this.startPts_=t.pts;break;case 5157:this.topRow_=13,this.mode_="rollUp";break;case 5158:this.topRow_=12,this.mode_="rollUp";break;case 5159:this.topRow_=11,this.mode_="rollUp";break;case 5165:this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;break;case 5153:"popOn"===this.mode_?this.nonDisplayed_[14]=this.nonDisplayed_[14].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1);break;case 5164:this.flushDisplayed(t.pts),this.displayed_=h();break;case 5166:this.nonDisplayed_=h();break;default:if(i=e>>>8,n=255&e,i>=16&&i<=23&&n>=64&&n<=127&&(16!==i||n<96)&&(i=32,n=null),(17===i||25===i)&&n>=48&&n<=63&&(i=9834,n=""),16==(240&i))return;0===i&&(i=null),0===n&&(n=null),this[this.mode_](t.pts,i,n)}}}};c.prototype=new i,c.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){return t.trim()}).filter(function(t){return t.length}).join("\n");e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e})},c.prototype.popOn=function(t,e,a){var i=this.nonDisplayed_[14];i+=l(e),i+=l(a),this.nonDisplayed_[14]=i},c.prototype.rollUp=function(t,e,a){var i=this.displayed_[14];""===i&&(this.flushDisplayed(t),this.startPts_=t),i+=l(e),i+=l(a),this.displayed_[14]=i},c.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.topRow_;t<14;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[14]=""},e.exports={CaptionStream:o,Cea608Stream:c}},{}],5:[function(t,e,a){"use strict";var i,n=t(7),r=t(6),s=function(t,e,a){var i,n="";for(i=e;i<a;i++)n+="%"+("00"+t[i].toString(16)).slice(-2);return n},o=function(t,e,a){return decodeURIComponent(s(t,e,a))},d=function(t,e,a){return unescape(s(t,e,a))},l=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},h={TXXX:function(t){var e;if(3===t.data[0]){for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.value=o(t.data,e+1,t.data.length-1);break}t.data=t.value}},WXXX:function(t){var e;if(3===t.data[0])for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.url=o(t.data,e+1,t.data.length);break}},PRIV:function(t){var e;for(e=0;e<t.data.length;e++)if(0===t.data[e]){t.owner=d(t.data,0,e);break}t.privateData=t.data.subarray(e+1),t.data=t.privateData}};i=function(t){var e,a={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},n=0,s=[],o=0;if(i.prototype.init.call(this),this.dispatchType=r.METADATA_STREAM_TYPE.toString(16),a.descriptor)for(e=0;e<a.descriptor.length;e++)this.dispatchType+=("00"+a.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,i,r,d,c,u;if("timed-metadata"===t.type){if(t.dataAlignmentIndicator&&(o=0,s.length=0),0===s.length&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0)))return void(a.debug&&console.log("Skipping unrecognized metadata packet"));if(s.push(t),o+=t.data.byteLength,1===s.length&&(n=l(t.data.subarray(6,10)),n+=10),!(o<n)){for(e={data:new Uint8Array(n),frames:[],pts:s[0].pts,dts:s[0].dts},c=0;c<n;)e.data.set(s[0].data.subarray(0,n-c),c),c+=s[0].data.byteLength,o-=s[0].data.byteLength,s.shift();i=10,64&e.data[5]&&(i+=4,i+=l(e.data.subarray(10,14)),n-=l(e.data.subarray(16,20)));do{if((r=l(e.data.subarray(i+4,i+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(u=String.fromCharCode(e.data[i],e.data[i+1],e.data[i+2],e.data[i+3]),d={id:u,data:e.data.subarray(i+10,i+r+10)},d.key=d.id,h[d.id]&&(h[d.id](d),"com.apple.streaming.transportStreamTimestamp"===d.owner)){var p=d.data,f=(1&p[3])<<30|p[4]<<22|p[5]<<14|p[6]<<6|p[7]>>>2;f*=4,f+=3&p[7],d.timeStamp=f,void 0===e.pts&&void 0===e.dts&&(e.pts=d.timeStamp,e.dts=d.timeStamp),this.trigger("timestamp",d)}e.frames.push(d),i+=10,i+=r}while(i<n);this.trigger("data",e)}}}},i.prototype=new n,e.exports=i},{}],6:[function(t,e,a){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],7:[function(t,e,a){"use strict";var i=function(){this.init=function(){var t={};this.on=function(e,a){t[e]||(t[e]=[]),t[e]=t[e].concat(a)},this.off=function(e,a){var i;return!!t[e]&&(i=t[e].indexOf(a),t[e]=t[e].slice(),t[e].splice(i,1),i>-1)},this.trigger=function(e){var a,i,n,r;if(a=t[e])if(2===arguments.length)for(n=a.length,i=0;i<n;++i)a[i].call(this,arguments[1]);else{for(r=[],i=arguments.length,i=1;i<arguments.length;++i)r.push(arguments[i]);for(n=a.length,i=0;i<n;++i)a[i].apply(this,r)}},this.dispose=function(){t={}}}};i.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),t},i.prototype.push=function(t){this.trigger("data",t)},i.prototype.flush=function(t){this.trigger("done",t)},e.exports=i},{}],8:[function(t,e,a){(function(e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}a.__esModule=!0;var r="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,s=i(r),o=t(3),d=i(o),l=t(4),h=t(5),c=i(h),u=t(2),p=t(1),f=function(t){Object.defineProperties(t.frame,{id:{get:function(){return s.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return s.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return s.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},_=function(t,e,a){for(var i=t.remoteTextTracks()||[],n=0;n<i.length;n++){var r=i[n];r.kind===e&&r.label===a&&t.removeRemoteTextTrack(r)}},y=function(t){for(var e=new Uint8Array(t.length),a=0;a<t.length;a++)e[a]=t.charCodeAt(a);return e},v=function(t,e){var a=[],i=void 0,n=void 0,r=void 0,s=void 0;if(!(64&e[0]))return a;for(n=31&e[0],i=0;i<n;i++)r=3*i,s={type:3&e[r+2],pts:t},4&e[r+2]&&(s.ccData=e[r+3]<<8|e[r+4],a.push(s));return a},g=function(t,e,a){var i=void 0,n=void 0;if(a&&a.cues)for(i=a.cues.length;i--;)n=a.cues[i],n.startTime<=e&&n.endTime>=t&&a.removeCue(n)},m=function(t,e){t.length&&g(0,t.start(0),e)},T=function(t,e){for(var a=-1,i=0;i<t.length;i++)if(t[i].id===e){a=i;break}t.selectedIndex_=a,t.trigger({selectedIndex:a,type:"change"})},k=function(){function t(e,a,i){var r=this;if(n(this,t),a.options_&&a.options_.playerId){var o=(0,s.default)(a.options_.playerId);o.hasOwnProperty("hls")||Object.defineProperty(o,"hls",{get:function(){return s.default.log.warn("player.hls is deprecated. Use player.tech_.hls instead."),a.trigger({type:"usage",name:"flashls-player-access"}),r}})}this.tech_=a,this.metadataTrack_=null,this.inbandTextTrack_=null,this.metadataStream_=new c.default,this.cea608Stream_=new l.Cea608Stream,this.captionPackets_=[],this.onLoadedmetadata_=this.onLoadedmetadata_.bind(this),this.onSeeked_=this.onSeeked_.bind(this),this.onId3updated_=this.onId3updated_.bind(this),this.onCaptionData_=this.onCaptionData_.bind(this),this.onMetadataStreamData_=this.onMetadataStreamData_.bind(this),this.onCea608StreamData_=this.onCea608StreamData_.bind(this),this.onLevelSwitch_=this.onLevelSwitch_.bind(this),this.onAudioTrackChanged=this.onAudioTrackChanged.bind(this),this.tech_.on("loadedmetadata",this.onLoadedmetadata_),this.tech_.on("seeked",this.onSeeked_),this.tech_.on("id3updated",this.onId3updated_),this.tech_.on("captiondata",this.onCaptionData_),this.metadataStream_.on("data",this.onMetadataStreamData_),this.cea608Stream_.on("data",this.onCea608StreamData_)}return t.prototype.src=function(t){t&&this.tech_.setSrc(t.src)},t.prototype.seekable=function(){var t=this.tech_.el_.vjs_getProperty("seekableStart"),e=this.tech_.el_.vjs_getProperty("seekableEnd");return 0===e?s.default.createTimeRange():s.default.createTimeRange(t,e)},t.prototype.onLoadedmetadata_=function(){var t=this;this.representations=(0,u.createRepresentations)(this.tech_);var e=s.default.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.representations().forEach(function(e){t.qualityLevels_.addQualityLevel(e)}),this.tech_.on("levelswitch",this.onLevelSwitch_),T(this.qualityLevels_,this.tech_.el_.vjs_getProperty("level")+"")),(0,p.setupAudioTracks)(this.tech_),this.tech_.audioTracks().on("change",this.onAudioTrackChanged)},t.prototype.onAudioTrackChanged=function(){(0,p.updateAudioTrack)(this.tech_)},t.prototype.onLevelSwitch_=function(t,e){T(this.qualityLevels_,e[0].levelIndex+"")},t.prototype.onSeeked_=function(){g(0,1/0,this.metadataTrack_);var t=this.tech_.buffered();1===t.length?(g(0,t.start(0),this.inbandTextTrack_),g(t.end(0),1/0,this.inbandTextTrack_)):g(0,1/0,this.inbandTextTrack_)},t.prototype.onId3updated_=function(t,e){var a=d.default.atob(e[0]),i=y(a),n={type:"timed-metadata",dataAlignmentIndicator:!0,data:i};this.metadataStream_.push(n)},t.prototype.onMetadataStreamData_=function(t){var e=this;this.metadataTrack_||(this.metadataTrack_=this.tech_.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,this.metadataTrack_.inBandMetadataTrackDispatchType=""),m(this.tech_.buffered(),this.metadataTrack_);var a=this.tech_.currentTime();if(t.frames.forEach(function(t){var i=new d.default.VTTCue(a,a+.1,t.value||t.url||t.data||"");i.frame=t,i.value=t,f(i),e.metadataTrack_.addCue(i)}),this.metadataTrack_.cues&&this.metadataTrack_.cues.length){var i=this.metadataTrack_.cues,n=[],r=this.tech_.duration();(isNaN(r)||Math.abs(r)===1/0)&&(r=Number.MAX_VALUE);for(var s=0;s<i.length;s++)n.push(i[s]);n.sort(function(t,e){return t.startTime-e.startTime});for(var o=0;o<n.length-1;o++)n[o].endTime!==n[o+1].startTime&&(n[o].endTime=n[o+1].startTime);n[n.length-1].endTime=r}},t.prototype.onCaptionData_=function(t,e){var a=this;e[0].map(function(t){return{pts:9e4*t.pos,bytes:y(d.default.atob(t.data))}}).forEach(function(t){a.captionPackets_=a.captionPackets_.concat(v(t.pts,t.bytes))}),this.captionPackets_.length&&(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(this.cea608Stream_.push,this.cea608Stream_),this.captionPackets_.length=0,this.cea608Stream_.flush())},t.prototype.onCea608StreamData_=function(t){t&&(this.inbandTextTrack_||(_(this.tech_,"captions","cc1"),this.inbandTextTrack_=this.tech_.addRemoteTextTrack({kind:"captions",label:"cc1"},!1).track),m(this.tech_.buffered(),this.inbandTextTrack_),this.inbandTextTrack_.addCue(new d.default.VTTCue(t.startPts/9e4,t.endPts/9e4,t.text)))},t.prototype.dispose=function(){this.tech_.off("loadedmetadata",this.onLoadedmetadata_),this.tech_.off("seeked",this.onSeeked_),this.tech_.off("id3updated",this.onId3updated_),this.tech_.off("captiondata",this.onCaptionData_),this.tech_.audioTracks().off("change",this.onAudioTrackChanged),this.qualityLevels_&&(this.qualityLevels_.dispose(),this.tech_.off("levelswitch",this.onLevelSwitch_))},t}(),b={},w=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;b.canPlayType=function(t){return w.test(t)?"maybe":""},b.canHandleSource=function(t,e){return"maybe"===b.canPlayType(t.type)},b.handleSource=function(t,e,a){return e.hls=new k(t,e,a),e.hls.src(t),e.hls},s.default.getTech("Flash").registerSourceHandler(b,0),b.VERSION="1.2.0",a.default=b}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[8]);
!function t(e,a,i){function n(s,o){if(!a[s]){if(!e[s]){var d="function"==typeof require&&require;if(!o&&d)return d(s,!0);if(r)return r(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=a[s]={exports:{}};e[s][0].call(h.exports,function(t){var a=e[s][1][t];return n(a||t)},h,h.exports,t,e,a,i)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,a){(function(t){"use strict";a.__esModule=!0,a.setupAudioTracks=a.updateAudioTrack=void 0;var e="undefined"!=typeof window?window.videojs:void 0!==t?t.videojs:null,i=function(t){return t&&t.__esModule?t:{default:t}}(e);a.updateAudioTrack=function(t){for(var e=t.el_.vjs_getProperty("audioTracks"),a=t.audioTracks(),i=null,n=0;n<a.length;n++)if(a[n].enabled){i=a[n].id;break}if(null!==i)for(var r=0;r<e.length;r++)if(i===e[r].title)return void t.el_.vjs_setProperty("audioTrack",r)},a.setupAudioTracks=function(t){var e=t.el_.vjs_getProperty("altAudioTracks"),a=t.el_.vjs_getProperty("audioTracks"),n=t.el_.vjs_getProperty("audioTrack");a.forEach(function(a,r){var s=e[a.id];t.audioTracks().addTrack(new i.default.AudioTrack({id:s.name,enabled:n===r,language:s.lang,default:s.default_track,label:s.name}))})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,a){"use strict";a.__esModule=!0;var i=a.createRepresentation=function(t,e){var a={id:e.index+"",width:e.width,height:e.height,bandwidth:e.bitrate,isEnabled_:!0};return a.enabled=function(e){if(void 0===e)return a.isEnabled_;e!==a.isEnabled_&&(!0!==e&&!1!==e||(a.isEnabled_=e,t()))},a};a.createRepresentations=function(t){var e=null,a=function(){var a=e.filter(function(t){return t.enabled()});if(a.length===e.length||0===a.length)return t.el_.vjs_setProperty("autoLevelCapping",-1),void t.el_.vjs_setProperty("level",-1);if(1===a.length)return t.el_.vjs_setProperty("level",parseInt(a[0].id,10)),void t.el_.vjs_setProperty("autoLevelCapping",-1);var i=a[a.length-1].id;t.el_.vjs_setProperty("autoLevelCapping",parseInt(i,10)),t.el_.vjs_setProperty("level",-1)};return function(){if(!e){var n=t.el_.vjs_getProperty("levels");e=n.filter(function(t){return!t.audio}).map(i.bind(null,a))}return e}}},{}],3:[function(t,e,a){(function(t){var a;a="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=a}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,a){"use strict";var i=t(7),n=function(t){for(var e=0,a={payloadType:-1,payloadSize:0},i=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)i+=255,e++;for(i+=t[e++];255===t[e];)n+=255,e++;if(n+=t[e++],!a.payload&&4===i){a.payloadType=i,a.payloadSize=n,a.payload=t.subarray(e,e+n);break}e+=n,i=0,n=0}return a},r=function(t){return 181!==t.payload[0]?null:49!=(t.payload[1]<<8|t.payload[2])?null:"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])?null:3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},s=function(t,e){var a,i,n,r,s=[];if(!(64&e[0]))return s;for(i=31&e[0],a=0;a<i;a++)n=3*a,r={type:3&e[n+2],pts:t},4&e[n+2]&&(r.ccData=e[n+3]<<8|e[n+4],s.push(r));return s},o=function(){o.prototype.init.call(this),this.captionPackets_=[],this.field1_=new c,this.field1_.on("data",this.trigger.bind(this,"data")),this.field1_.on("done",this.trigger.bind(this,"done"))};o.prototype=new i,o.prototype.push=function(t){var e,a;"sei_rbsp"===t.nalUnitType&&(e=n(t.escapedRBSP),4===e.payloadType&&(a=r(e))&&(this.captionPackets_=this.captionPackets_.concat(s(t.pts,a))))},o.prototype.flush=function(){if(!this.captionPackets_.length)return void this.field1_.flush();this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(this.field1_.push,this.field1_),this.captionPackets_.length=0,this.field1_.flush()};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608},l=function(t){return null===t?"":(t=d[t]||t,String.fromCharCode(t))},h=function(){for(var t=[],e=15;e--;)t.push("");return t},c=function(){c.prototype.init.call(this),this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=h(),this.nonDisplayed_=h(),this.lastControlCode_=null,this.push=function(t){if(0===t.type){var e,a,i,n;if((e=32639&t.ccData)===this.lastControlCode_)return void(this.lastControlCode_=null);switch(this.lastControlCode_=4096==(61440&e)?e:null,e){case 0:break;case 5152:this.mode_="popOn";break;case 5167:this.flushDisplayed(t.pts),a=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=a,this.startPts_=t.pts;break;case 5157:this.topRow_=13,this.mode_="rollUp";break;case 5158:this.topRow_=12,this.mode_="rollUp";break;case 5159:this.topRow_=11,this.mode_="rollUp";break;case 5165:this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;break;case 5153:"popOn"===this.mode_?this.nonDisplayed_[14]=this.nonDisplayed_[14].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1);break;case 5164:this.flushDisplayed(t.pts),this.displayed_=h();break;case 5166:this.nonDisplayed_=h();break;default:if(i=e>>>8,n=255&e,i>=16&&i<=23&&n>=64&&n<=127&&(16!==i||n<96)&&(i=32,n=null),(17===i||25===i)&&n>=48&&n<=63&&(i=9834,n=""),16==(240&i))return;0===i&&(i=null),0===n&&(n=null),this[this.mode_](t.pts,i,n)}}}};c.prototype=new i,c.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){return t.trim()}).filter(function(t){return t.length}).join("\n");e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e})},c.prototype.popOn=function(t,e,a){var i=this.nonDisplayed_[14];i+=l(e),i+=l(a),this.nonDisplayed_[14]=i},c.prototype.rollUp=function(t,e,a){var i=this.displayed_[14];""===i&&(this.flushDisplayed(t),this.startPts_=t),i+=l(e),i+=l(a),this.displayed_[14]=i},c.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.topRow_;t<14;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[14]=""},e.exports={CaptionStream:o,Cea608Stream:c}},{}],5:[function(t,e,a){"use strict";var i,n=t(7),r=t(6),s=function(t,e,a){var i,n="";for(i=e;i<a;i++)n+="%"+("00"+t[i].toString(16)).slice(-2);return n},o=function(t,e,a){return decodeURIComponent(s(t,e,a))},d=function(t,e,a){return unescape(s(t,e,a))},l=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},h={TXXX:function(t){var e;if(3===t.data[0]){for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.value=o(t.data,e+1,t.data.length-1);break}t.data=t.value}},WXXX:function(t){var e;if(3===t.data[0])for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.url=o(t.data,e+1,t.data.length);break}},PRIV:function(t){var e;for(e=0;e<t.data.length;e++)if(0===t.data[e]){t.owner=d(t.data,0,e);break}t.privateData=t.data.subarray(e+1),t.data=t.privateData}};i=function(t){var e,a={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},n=0,s=[],o=0;if(i.prototype.init.call(this),this.dispatchType=r.METADATA_STREAM_TYPE.toString(16),a.descriptor)for(e=0;e<a.descriptor.length;e++)this.dispatchType+=("00"+a.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,i,r,d,c,u;if("timed-metadata"===t.type){if(t.dataAlignmentIndicator&&(o=0,s.length=0),0===s.length&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0)))return void(a.debug&&console.log("Skipping unrecognized metadata packet"));if(s.push(t),o+=t.data.byteLength,1===s.length&&(n=l(t.data.subarray(6,10)),n+=10),!(o<n)){for(e={data:new Uint8Array(n),frames:[],pts:s[0].pts,dts:s[0].dts},c=0;c<n;)e.data.set(s[0].data.subarray(0,n-c),c),c+=s[0].data.byteLength,o-=s[0].data.byteLength,s.shift();i=10,64&e.data[5]&&(i+=4,i+=l(e.data.subarray(10,14)),n-=l(e.data.subarray(16,20)));do{if((r=l(e.data.subarray(i+4,i+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(u=String.fromCharCode(e.data[i],e.data[i+1],e.data[i+2],e.data[i+3]),d={id:u,data:e.data.subarray(i+10,i+r+10)},d.key=d.id,h[d.id]&&(h[d.id](d),"com.apple.streaming.transportStreamTimestamp"===d.owner)){var p=d.data,f=(1&p[3])<<30|p[4]<<22|p[5]<<14|p[6]<<6|p[7]>>>2;f*=4,f+=3&p[7],d.timeStamp=f,void 0===e.pts&&void 0===e.dts&&(e.pts=d.timeStamp,e.dts=d.timeStamp),this.trigger("timestamp",d)}e.frames.push(d),i+=10,i+=r}while(i<n);this.trigger("data",e)}}}},i.prototype=new n,e.exports=i},{}],6:[function(t,e,a){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],7:[function(t,e,a){"use strict";var i=function(){this.init=function(){var t={};this.on=function(e,a){t[e]||(t[e]=[]),t[e]=t[e].concat(a)},this.off=function(e,a){var i;return!!t[e]&&(i=t[e].indexOf(a),t[e]=t[e].slice(),t[e].splice(i,1),i>-1)},this.trigger=function(e){var a,i,n,r;if(a=t[e])if(2===arguments.length)for(n=a.length,i=0;i<n;++i)a[i].call(this,arguments[1]);else{for(r=[],i=arguments.length,i=1;i<arguments.length;++i)r.push(arguments[i]);for(n=a.length,i=0;i<n;++i)a[i].apply(this,r)}},this.dispose=function(){t={}}}};i.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),t},i.prototype.push=function(t){this.trigger("data",t)},i.prototype.flush=function(t){this.trigger("done",t)},e.exports=i},{}],8:[function(t,e,a){(function(e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}a.__esModule=!0,a.FlashlsHandler=void 0;var r="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,s=i(r),o=t(3),d=i(o),l=t(4),h=t(5),c=i(h),u=t(2),p=t(1),f=function(t){Object.defineProperties(t.frame,{id:{get:function(){return s.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return s.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return s.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},_=function(t,e,a){for(var i=t.remoteTextTracks()||[],n=0;n<i.length;n++){var r=i[n];r.kind===e&&r.label===a&&t.removeRemoteTextTrack(r)}},y=function(t){for(var e=new Uint8Array(t.length),a=0;a<t.length;a++)e[a]=t.charCodeAt(a);return e},v=function(t,e){var a=[],i=void 0,n=void 0,r=void 0,s=void 0;if(!(64&e[0]))return a;for(n=31&e[0],i=0;i<n;i++)r=3*i,s={type:3&e[r+2],pts:t},4&e[r+2]&&(s.ccData=e[r+3]<<8|e[r+4],a.push(s));return a},g=function(t,e,a){var i=void 0,n=void 0;if(a&&a.cues)for(i=a.cues.length;i--;)n=a.cues[i],n.startTime<=e&&n.endTime>=t&&a.removeCue(n)},m=function(t,e){t.length&&g(0,t.start(0),e)},T=function(t,e){for(var a=-1,i=0;i<t.length;i++)if(t[i].id===e){a=i;break}t.selectedIndex_=a,t.trigger({selectedIndex:a,type:"change"})},k=a.FlashlsHandler=function(){function t(e,a,i){var r=this;if(n(this,t),a.options_&&a.options_.playerId){var o=(0,s.default)(a.options_.playerId);o.hasOwnProperty("hls")||Object.defineProperty(o,"hls",{get:function(){return s.default.log.warn("player.hls is deprecated. Use player.tech_.hls instead."),a.trigger({type:"usage",name:"flashls-player-access"}),r}})}Object.defineProperties(this,{stats:{get:function(){return this.tech_.el_.vjs_getProperty("stats")}},bandwidth:{get:function(){return this.tech_.el_.vjs_getProperty("stats").bandwidth}}}),this.tech_=a,this.metadataTrack_=null,this.inbandTextTrack_=null,this.metadataStream_=new c.default,this.cea608Stream_=new l.Cea608Stream,this.captionPackets_=[],this.onLoadedmetadata_=this.onLoadedmetadata_.bind(this),this.onSeeked_=this.onSeeked_.bind(this),this.onId3updated_=this.onId3updated_.bind(this),this.onCaptionData_=this.onCaptionData_.bind(this),this.onMetadataStreamData_=this.onMetadataStreamData_.bind(this),this.onCea608StreamData_=this.onCea608StreamData_.bind(this),this.onLevelSwitch_=this.onLevelSwitch_.bind(this),this.onAudioTrackChanged=this.onAudioTrackChanged.bind(this),this.tech_.on("loadedmetadata",this.onLoadedmetadata_),this.tech_.on("seeked",this.onSeeked_),this.tech_.on("id3updated",this.onId3updated_),this.tech_.on("captiondata",this.onCaptionData_),this.tech_.on("levelswitch",this.onLevelSwitch_),this.metadataStream_.on("data",this.onMetadataStreamData_),this.cea608Stream_.on("data",this.onCea608StreamData_),this.playlists={media:function(){return r.media_()}}}return t.prototype.src=function(t){t&&this.tech_.setSrc(t.src)},t.prototype.seekable=function(){var t=this.tech_.el_.vjs_getProperty("seekableStart"),e=this.tech_.el_.vjs_getProperty("seekableEnd");return 0===e?s.default.createTimeRange():s.default.createTimeRange(t,e)},t.prototype.media_=function(){var t=this.tech_.el_.vjs_getProperty("levels"),e=this.tech_.el_.vjs_getProperty("level"),a=void 0;return t.length&&(a={resolvedUri:t[e].url,attributes:{BANDWIDTH:t[e].bitrate,RESOLUTION:{width:t[e].width,height:t[e].height}}}),a},t.prototype.onLoadedmetadata_=function(){var t=this;this.representations=(0,u.createRepresentations)(this.tech_);var e=s.default.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.representations().forEach(function(e){t.qualityLevels_.addQualityLevel(e)}),T(this.qualityLevels_,this.tech_.el_.vjs_getProperty("level")+"")),(0,p.setupAudioTracks)(this.tech_),this.tech_.audioTracks().on("change",this.onAudioTrackChanged)},t.prototype.onAudioTrackChanged=function(){(0,p.updateAudioTrack)(this.tech_)},t.prototype.onLevelSwitch_=function(t,e){this.qualityLevels_&&T(this.qualityLevels_,e[0].levelIndex+""),this.tech_.trigger({type:"mediachange",bubbles:!0})},t.prototype.onSeeked_=function(){g(0,1/0,this.metadataTrack_);var t=this.tech_.buffered();1===t.length?(g(0,t.start(0),this.inbandTextTrack_),g(t.end(0),1/0,this.inbandTextTrack_)):g(0,1/0,this.inbandTextTrack_)},t.prototype.onId3updated_=function(t,e){var a=d.default.atob(e[0]),i=y(a),n={type:"timed-metadata",dataAlignmentIndicator:!0,data:i};this.metadataStream_.push(n)},t.prototype.onMetadataStreamData_=function(t){var e=this;this.metadataTrack_||(this.metadataTrack_=this.tech_.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,this.metadataTrack_.inBandMetadataTrackDispatchType=""),m(this.tech_.buffered(),this.metadataTrack_);var a=this.tech_.currentTime();if(t.frames.forEach(function(t){var i=new d.default.VTTCue(a,a+.1,t.value||t.url||t.data||"");i.frame=t,i.value=t,f(i),e.metadataTrack_.addCue(i)}),this.metadataTrack_.cues&&this.metadataTrack_.cues.length){var i=this.metadataTrack_.cues,n=[],r=this.tech_.duration();(isNaN(r)||Math.abs(r)===1/0)&&(r=Number.MAX_VALUE);for(var s=0;s<i.length;s++)n.push(i[s]);n.sort(function(t,e){return t.startTime-e.startTime});for(var o=0;o<n.length-1;o++)n[o].endTime!==n[o+1].startTime&&(n[o].endTime=n[o+1].startTime);n[n.length-1].endTime=r}},t.prototype.onCaptionData_=function(t,e){var a=this;e[0].map(function(t){return{pts:9e4*t.pos,bytes:y(d.default.atob(t.data))}}).forEach(function(t){a.captionPackets_=a.captionPackets_.concat(v(t.pts,t.bytes))}),this.captionPackets_.length&&(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(this.cea608Stream_.push,this.cea608Stream_),this.captionPackets_.length=0,this.cea608Stream_.flush())},t.prototype.onCea608StreamData_=function(t){t&&(this.inbandTextTrack_||(_(this.tech_,"captions","cc1"),this.inbandTextTrack_=this.tech_.addRemoteTextTrack({kind:"captions",label:"cc1"},!1).track),m(this.tech_.buffered(),this.inbandTextTrack_),this.inbandTextTrack_.addCue(new d.default.VTTCue(t.startPts/9e4,t.endPts/9e4,t.text)))},t.prototype.dispose=function(){this.tech_.off("loadedmetadata",this.onLoadedmetadata_),this.tech_.off("seeked",this.onSeeked_),this.tech_.off("id3updated",this.onId3updated_),this.tech_.off("captiondata",this.onCaptionData_),this.tech_.audioTracks().off("change",this.onAudioTrackChanged),this.tech_.off("levelswitch",this.onLevelSwitch_),this.qualityLevels_&&this.qualityLevels_.dispose()},t}(),b={},w=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;b.canPlayType=function(t){return w.test(t)?"maybe":""},b.canHandleSource=function(t,e){return"maybe"===b.canPlayType(t.type)},b.handleSource=function(t,e,a){return e.hls=new k(t,e,a),e.hls.src(t),e.hls},s.default.getTech("Flash").registerSourceHandler(b,0),b.VERSION="1.3.0",a.default=b}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[8]);
'use strict';
exports.__esModule = true;
exports.FlashlsHandler = undefined;

@@ -189,3 +190,3 @@ var _video = require('video.js');

var FlashlsHandler = function () {
var FlashlsHandler = exports.FlashlsHandler = function () {
function FlashlsHandler(source, tech, options) {

@@ -212,2 +213,15 @@ var _this = this;

Object.defineProperties(this, {
stats: {
get: function get() {
return this.tech_.el_.vjs_getProperty('stats');
}
},
bandwidth: {
get: function get() {
return this.tech_.el_.vjs_getProperty('stats').bandwidth;
}
}
});
this.tech_ = tech;

@@ -234,5 +248,12 @@ this.metadataTrack_ = null;

this.tech_.on('captiondata', this.onCaptionData_);
this.tech_.on('levelswitch', this.onLevelSwitch_);
this.metadataStream_.on('data', this.onMetadataStreamData_);
this.cea608Stream_.on('data', this.onCea608StreamData_);
this.playlists = {
media: function media() {
return _this.media_();
}
};
}

@@ -267,2 +288,23 @@

FlashlsHandler.prototype.media_ = function media_() {
var levels = this.tech_.el_.vjs_getProperty('levels');
var level = this.tech_.el_.vjs_getProperty('level');
var media = void 0;
if (levels.length) {
media = {
resolvedUri: levels[level].url,
attributes: {
BANDWIDTH: levels[level].bitrate,
RESOLUTION: {
width: levels[level].width,
height: levels[level].height
}
}
};
}
return media;
};
/**

@@ -287,4 +329,2 @@ * Event listener for the loadedmetadata event. This sets up the representations api

this.tech_.on('levelswitch', this.onLevelSwitch_);
// update initial selected index

@@ -320,3 +360,6 @@ updateSelectedIndex(this.qualityLevels_, this.tech_.el_.vjs_getProperty('level') + '');

FlashlsHandler.prototype.onLevelSwitch_ = function onLevelSwitch_(event, level) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
if (this.qualityLevels_) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
}
this.tech_.trigger({ type: 'mediachange', bubbles: true });
};

@@ -504,6 +547,6 @@

this.tech_.audioTracks().off('change', this.onAudioTrackChanged);
this.tech_.off('levelswitch', this.onLevelSwitch_);
if (this.qualityLevels_) {
this.qualityLevels_.dispose();
this.tech_.off('levelswitch', this.onLevelSwitch_);
}

@@ -573,3 +616,2 @@ };

tech.hls = new FlashlsHandler(source, tech, options);
tech.hls.src(source);

@@ -576,0 +618,0 @@ return tech.hls;

{
"name": "@brightcove/videojs-flashls-source-handler",
"version": "1.2.0",
"version": "1.3.0",
"description": "A source handler to integrate flashls with video.js",

@@ -75,7 +75,7 @@ "main": "es5/index.js",

"dependencies": {
"@brightcove/videojs-flashls-swf": "^6.1.0",
"browserify-versionify": "^1.0.6",
"global": "^4.3.0",
"mux.js": "^3.0.4",
"video.js": "^5.10.1",
"@brightcove/videojs-flashls-swf": "6.0.0"
"video.js": "^5.10.1"
},

@@ -82,0 +82,0 @@ "devDependencies": {

@@ -176,3 +176,3 @@ import videojs from 'video.js';

class FlashlsHandler {
export class FlashlsHandler {
constructor(source, tech, options) {

@@ -195,2 +195,15 @@ // tech.player() is deprecated but setup a reference to HLS for

Object.defineProperties(this, {
stats: {
get() {
return this.tech_.el_.vjs_getProperty('stats');
}
},
bandwidth: {
get() {
return this.tech_.el_.vjs_getProperty('stats').bandwidth;
}
}
});
this.tech_ = tech;

@@ -217,5 +230,10 @@ this.metadataTrack_ = null;

this.tech_.on('captiondata', this.onCaptionData_);
this.tech_.on('levelswitch', this.onLevelSwitch_);
this.metadataStream_.on('data', this.onMetadataStreamData_);
this.cea608Stream_.on('data', this.onCea608StreamData_);
this.playlists = {
media: () => this.media_()
};
}

@@ -248,2 +266,23 @@

media_() {
const levels = this.tech_.el_.vjs_getProperty('levels');
const level = this.tech_.el_.vjs_getProperty('level');
let media;
if (levels.length) {
media = {
resolvedUri: levels[level].url,
attributes: {
BANDWIDTH: levels[level].bitrate,
RESOLUTION: {
width: levels[level].width,
height: levels[level].height
}
}
};
}
return media;
}
/**

@@ -264,4 +303,2 @@ * Event listener for the loadedmetadata event. This sets up the representations api

this.tech_.on('levelswitch', this.onLevelSwitch_);
// update initial selected index

@@ -294,3 +331,6 @@ updateSelectedIndex(this.qualityLevels_,

onLevelSwitch_(event, level) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
if (this.qualityLevels_) {
updateSelectedIndex(this.qualityLevels_, level[0].levelIndex + '');
}
this.tech_.trigger({ type: 'mediachange', bubbles: true});
}

@@ -469,6 +509,6 @@

this.tech_.audioTracks().off('change', this.onAudioTrackChanged);
this.tech_.off('levelswitch', this.onLevelSwitch_);
if (this.qualityLevels_) {
this.qualityLevels_.dispose();
this.tech_.off('levelswitch', this.onLevelSwitch_);
}

@@ -534,3 +574,2 @@ }

tech.hls = new FlashlsHandler(source, tech, options);
tech.hls.src(source);

@@ -537,0 +576,0 @@ return tech.hls;

@@ -0,1 +1,3 @@

import videojs from 'video.js';
export const noop = () => {};

@@ -5,16 +7,17 @@

export const makeMochTech = (getters, setters) => {
return {
el_: {
vjs_getProperty(prop) {
const getProp = getters[prop] || noop;
const tech = new videojs.EventTarget();
return getProp();
},
vjs_setProperty(prop, value) {
const setProp = setters[prop] || noop;
tech.el_ = {
vjs_getProperty(prop) {
const getProp = getters[prop] || noop;
return setProp(value);
}
return getProp();
},
vjs_setProperty(prop, value) {
const setProp = setters[prop] || noop;
return setProp(value);
}
};
return tech;
};

@@ -21,0 +24,0 @@

@@ -1,3 +0,1 @@

import document from 'global/document';
import QUnit from 'qunit';

@@ -7,3 +5,4 @@ import sinon from 'sinon';

import handler from '../src/index';
import { default as FlashlsSourceHandler, FlashlsHandler } from '../src/index';
import { makeMochTech } from './util/util.js';

@@ -14,26 +13,25 @@ QUnit.test('the environment is sane', function(assert) {

assert.strictEqual(typeof videojs, 'function', 'videojs exists');
assert.strictEqual(typeof handler, 'object', 'handler is a function');
assert.strictEqual(typeof FlashlsSourceHandler, 'object', 'handler is a function');
});
QUnit.module('videojs-flashls-source-handler', {
QUnit.module('videojs-flashls-source-handler');
beforeEach() {
QUnit.test('can get stats from handler', function(assert) {
const stats = {
bandwidth: 100,
mediaRequests: 1,
mediaRequestsAborted: 2,
mediaRequestsTimedout: 3,
mediaRequestsErrored: 4,
mediaTransferDuration: 5,
mediaBytesTransferred: 6,
mediaSecondsLoaded: 7
};
// Mock the environment's timers because certain things - particularly
// player readiness - are asynchronous in video.js 5. This MUST come
// before any player is created; otherwise, timers could get created
// with the actual timer methods!
this.clock = sinon.useFakeTimers();
const tech = makeMochTech({ stats: () => stats });
const handler = new FlashlsHandler('src', tech, {});
this.fixture = document.getElementById('qunit-fixture');
this.video = document.createElement('video');
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
},
afterEach() {
this.player.dispose();
this.clock.restore();
}
assert.equal(handler.bandwidth, 100, 'can get hls.bandwidth');
assert.deepEqual(handler.stats, stats, 'can get hls.stats');
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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