@brightcove/videojs-flashls-source-handler
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -7,3 +7,3 @@ # CONTRIBUTING | ||
Make sure you have NodeJS 0.10 or higher and npm installed. | ||
Make sure you have Node.js 4.8 or higher and npm installed. | ||
@@ -16,3 +16,3 @@ 1. Fork this repository and clone your fork | ||
Refer to the [video.js plugin standards][standards] for more detail on best practices and tooling for video.js plugin authorship. | ||
Refer to the [video.js plugin conventions][conventions] for more detail on best practices and tooling for video.js plugin authorship. | ||
@@ -32,2 +32,2 @@ When you've made your changes, push your commit(s) to your fork and issue a pull request against the original repository. | ||
[local]: http://localhost:9999/test/ | ||
[standards]: https://github.com/videojs/generator-videojs-plugin/docs/standards.md | ||
[conventions]: https://github.com/videojs/generator-videojs-plugin/blob/master/docs/conventions.md |
@@ -1,1 +0,2 @@ | ||
!function t(e,i,a){function n(o,r){if(!i[o]){if(!e[o]){var d="function"==typeof require&&require;if(!r&&d)return d(o,!0);if(s)return s(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var l=i[o]={exports:{}};e[o][0].call(l.exports,function(t){var i=e[o][1][t];return n(i||t)},l,l.exports,t,e,i,a)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<a.length;o++)n(a[o]);return n}({1:[function(t,e,i){(function(t){"use strict";i.__esModule=!0,i.setupAudioTracks=i.updateAudioTrack=void 0;var e="undefined"!=typeof window?window.videojs:void 0!==t?t.videojs:null,a=function(t){return t&&t.__esModule?t:{default:t}}(e);i.updateAudioTrack=function(t){for(var e=t.el_.vjs_getProperty("audioTracks"),i=t.audioTracks(),a=null,n=0;n<i.length;n++)if(i[n].enabled){a=i[n].id;break}if(null!==a)for(var s=0;s<e.length;s++)if(a===e[s].title)return void t.el_.vjs_setProperty("audioTrack",s)},i.setupAudioTracks=function(t){var e=t.el_.vjs_getProperty("altAudioTracks"),i=t.el_.vjs_getProperty("audioTracks"),n=t.el_.vjs_getProperty("audioTrack");i.forEach(function(i,s){var o=e[i.id];t.audioTracks().addTrack(new a.default.AudioTrack({id:o.name,enabled:n===s,language:o.lang,default:o.default_track,label:o.name}))})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,i){"use strict";i.__esModule=!0;var a=i.createRepresentation=function(t,e){var i={id:e.index+"",width:e.width,height:e.height,bandwidth:e.bitrate,isEnabled_:!0};return i.enabled=function(e){if(void 0===e)return i.isEnabled_;e!==i.isEnabled_&&(!0!==e&&!1!==e||(i.isEnabled_=e,t()))},i};i.createRepresentations=function(t){var e=null,i=function(){var i=e.filter(function(t){return t.enabled()});if(i.length===e.length||0===i.length)return t.el_.vjs_setProperty("autoLevelCapping",-1),void t.el_.vjs_setProperty("level",-1);if(1===i.length)return t.el_.vjs_setProperty("level",parseInt(i[0].id,10)),void t.el_.vjs_setProperty("autoLevelCapping",-1);var a=i[i.length-1].id;t.el_.vjs_setProperty("autoLevelCapping",parseInt(a,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(a.bind(null,i))}return e}}},{}],3:[function(t,e,i){(function(t){var i;i="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,i){"use strict";var a=t(7),n=function(t){for(var e=0,i={payloadType:-1,payloadSize:0},a=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)a+=255,e++;for(a+=t[e++];255===t[e];)n+=255,e++;if(n+=t[e++],!i.payload&&4===a){i.payloadType=a,i.payloadSize=n,i.payload=t.subarray(e,e+n);break}e+=n,a=0,n=0}return i},s=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)},o=function(t,e){var i,a,n,s,o=[];if(!(64&e[0]))return o;for(a=31&e[0],i=0;i<a;i++)n=3*i,s={type:3&e[n+2],pts:t},4&e[n+2]&&(s.ccData=e[n+3]<<8|e[n+4],o.push(s));return o},r=function(){r.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new u(0,0),new u(0,1),new u(1,0),new u(1,1)],this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("done",this.trigger.bind(this,"done"))},this)};r.prototype=new a,r.prototype.push=function(t){var e,i;if("sei_rbsp"===t.nalUnitType&&(e=n(t.escapedRBSP),4===e.payloadType&&(i=s(e)))){if(t.dts<this.latestDts_)return void(this.ignoreNextEqualDts_=!0);if(t.dts===this.latestDts_&&this.ignoreNextEqualDts_)return void(this.ignoreNextEqualDts_=!1);this.captionPackets_=this.captionPackets_.concat(o(t.pts,i)),this.latestDts_=t.dts}},r.prototype.flush=function(){if(!this.captionPackets_.length)return void this.ccStreams_.forEach(function(t){t.flush()},this);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(function(t){t.type<2&&this.dispatchCea608Packet(t)},this),this.captionPackets_.length=0,this.ccStreams_.forEach(function(t){t.flush()},this)},r.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},r.prototype.dispatchCea608Packet=function(t){this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},r.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},r.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},h=function(t){return null===t?"":(t=d[t]||t,String.fromCharCode(t))},l=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],c=function(){for(var t=[],e=15;e--;)t.push("");return t},u=function(t,e){u.prototype.init.call(this),this.field_=t||0,this.dataChannel_=e||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,a,n,s;if((e=32639&t.ccData)===this.lastControlCode_)return void(this.lastControlCode_=null);if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),a=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.topRow_=13,this.mode_="rollUp";else if(e===this.ROLL_UP_3_ROWS_)this.topRow_=12,this.mode_="rollUp";else if(e===this.ROLL_UP_4_ROWS_)this.topRow_=11,this.mode_="rollUp";else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[14]=this.nonDisplayed_[14].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=c();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=c();else if(e===this.RESUME_DIRECT_CAPTIONING_)this.mode_="paintOn";else if(this.isSpecialCharacter(a,n))a=(3&a)<<8,s=h(a|n),this[this.mode_](t.pts,s),this.column_++;else if(this.isExtCharacter(a,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1),a=(3&a)<<8,s=h(a|n),this[this.mode_](t.pts,s),this.column_++;else if(this.isMidRowCode(a,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14==(14&n)&&this.addFormatting(t.pts,["i"]),1==(1&n)&&this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(a,n))this.column_+=3&n;else if(this.isPAC(a,n)){var o=l.indexOf(7968&e);o!==this.row_&&(this.clearFormatting(t.pts),this.row_=o),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16==(16&e)&&(this.column_=4*((14&e)>>1)),this.isColorPAC(n)&&14==(14&n)&&this.addFormatting(t.pts,["i"])}else this.isNormalChar(a)&&(0===n&&(n=null),s=h(a),s+=h(n),this[this.mode_](t.pts,s),this.column_+=s.length)}};u.prototype=new a,u.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){return t.trim()}).join("\n").replace(/^\n+|\n+$/g,"");e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e,stream:this.name_})},u.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=c(),this.nonDisplayed_=c(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.formatting_=[]},u.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},u.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},u.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},u.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},u.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=33&&e<=35},u.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},u.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},u.prototype.isNormalChar=function(t){return t>=32&&t<=127},u.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},u.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},u.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},u.prototype.rollUp=function(t,e){var i=this.displayed_[14];i+=e,this.displayed_[14]=i},u.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]=""},u.prototype.paintOn=function(){},e.exports={CaptionStream:r,Cea608Stream:u}},{}],5:[function(t,e,i){"use strict";var a,n=t(7),s=t(6),o=function(t,e,i){var a,n="";for(a=e;a<i;a++)n+="%"+("00"+t[a].toString(16)).slice(-2);return n},r=function(t,e,i){return decodeURIComponent(o(t,e,i))},d=function(t,e,i){return unescape(o(t,e,i))},h=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},l={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=r(t.data,1,e),t.value=r(t.data,e+1,t.data.length).replace(/\0*$/,"");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=r(t.data,1,e),t.url=r(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}};a=function(t){var e,i={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},n=0,o=[],r=0;if(a.prototype.init.call(this),this.dispatchType=s.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(e=0;e<i.descriptor.length;e++)this.dispatchType+=("00"+i.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,a,s,d,c,u;if("timed-metadata"===t.type){if(t.dataAlignmentIndicator&&(r=0,o.length=0),0===o.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(i.debug&&console.log("Skipping unrecognized metadata packet"));if(o.push(t),r+=t.data.byteLength,1===o.length&&(n=h(t.data.subarray(6,10)),n+=10),!(r<n)){for(e={data:new Uint8Array(n),frames:[],pts:o[0].pts,dts:o[0].dts},c=0;c<n;)e.data.set(o[0].data.subarray(0,n-c),c),c+=o[0].data.byteLength,r-=o[0].data.byteLength,o.shift();a=10,64&e.data[5]&&(a+=4,a+=h(e.data.subarray(10,14)),n-=h(e.data.subarray(16,20)));do{if((s=h(e.data.subarray(a+4,a+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(u=String.fromCharCode(e.data[a],e.data[a+1],e.data[a+2],e.data[a+3]),d={id:u,data:e.data.subarray(a+10,a+s+10)},d.key=d.id,l[d.id]&&(l[d.id](d),"com.apple.streaming.transportStreamTimestamp"===d.owner)){var p=d.data,_=(1&p[3])<<30|p[4]<<22|p[5]<<14|p[6]<<6|p[7]>>>2;_*=4,_+=3&p[7],d.timeStamp=_,void 0===e.pts&&void 0===e.dts&&(e.pts=d.timeStamp,e.dts=d.timeStamp),this.trigger("timestamp",d)}e.frames.push(d),a+=10,a+=s}while(a<n);this.trigger("data",e)}}}},a.prototype=new n,e.exports=a},{}],6:[function(t,e,i){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],7:[function(t,e,i){"use strict";var a=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var a;return!!t[e]&&(a=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(a,1),a>-1)},this.trigger=function(e){var i,a,n,s;if(i=t[e])if(2===arguments.length)for(n=i.length,a=0;a<n;++a)i[a].call(this,arguments[1]);else{for(s=[],a=arguments.length,a=1;a<arguments.length;++a)s.push(arguments[a]);for(n=i.length,a=0;a<n;++a)i[a].apply(this,s)}},this.dispose=function(){t={}}}};a.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),t},a.prototype.push=function(t){this.trigger("data",t)},a.prototype.flush=function(t){this.trigger("done",t)},e.exports=a},{}],8:[function(t,e,i){(function(e){"use strict";function a(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")}i.__esModule=!0,i.FlashlsHandler=void 0;var s="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,o=a(s),r=t(3),d=a(r),h=t(4),l=t(5),c=a(l),u=t(2),p=t(1),_=function(t){Object.defineProperties(t.frame,{id:{get:function(){return o.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return o.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return o.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},f=function(t,e,i){for(var a=t.remoteTextTracks()||[],n=0;n<a.length;n++){var s=a[n];s.kind===e&&s.label===i&&t.removeRemoteTextTrack(s)}},y=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e},g=function(t,e,i){var a=void 0,n=void 0;if(i&&i.cues)for(a=i.cues.length;a--;)n=i.cues[a],n.startTime<=e&&n.endTime>=t&&i.removeCue(n)},m=function(t,e){t.length&&g(0,t.start(0),e)},v=function(t,e){for(var i=-1,a=0;a<t.length;a++)if(t[a].id===e){i=a;break}t.selectedIndex_=i,t.trigger({selectedIndex:i,type:"change"})},T=function(t,e){var i=[];if(t&&t.length)for(var a=0;a<t.length;a++)e(t.start(a),t.end(a))&&i.push([t.start(a),t.end(a)]);return o.default.createTimeRanges(i)},C=function(t,e){return T(t,function(t,i){return t-1/30<=e&&i+1/30>=e})},S=i.FlashlsHandler=function(){function t(e,i,a){var s=this;if(n(this,t),i.options_&&i.options_.playerId){var r=(0,o.default)(i.options_.playerId);r.hasOwnProperty("hls")||Object.defineProperty(r,"hls",{get:function(){return o.default.log.warn("player.hls is deprecated. Use player.tech_.hls instead."),i.trigger({type:"usage",name:"flashls-player-access"}),s}})}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_=i,this.metadataTrack_=null,this.inbandTextTracks_={},this.metadataStream_=new c.default,this.captionStream_=new h.CaptionStream,this.onLoadedmetadata_=this.onLoadedmetadata_.bind(this),this.onSeeking_=this.onSeeking_.bind(this),this.onId3updated_=this.onId3updated_.bind(this),this.onCaptionData_=this.onCaptionData_.bind(this),this.onMetadataStreamData_=this.onMetadataStreamData_.bind(this),this.onCaptionStreamData_=this.onCaptionStreamData_.bind(this),this.onLevelSwitch_=this.onLevelSwitch_.bind(this),this.onLevelLoaded_=this.onLevelLoaded_.bind(this),this.onFragmentLoaded_=this.onFragmentLoaded_.bind(this),this.onAudioTrackChanged=this.onAudioTrackChanged.bind(this),this.tech_.on("loadedmetadata",this.onLoadedmetadata_),this.tech_.on("seeking",this.onSeeking_),this.tech_.on("id3updated",this.onId3updated_),this.tech_.on("captiondata",this.onCaptionData_),this.tech_.on("levelswitch",this.onLevelSwitch_),this.tech_.on("levelloaded",this.onLevelLoaded_),this.tech_.on("fragmentloaded",this.onFragmentLoaded_),this.metadataStream_.on("data",this.onMetadataStreamData_),this.captionStream_.on("data",this.onCaptionStreamData_),this.playlists=new o.default.EventTarget,this.playlists.media=function(){return s.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?o.default.createTimeRange():o.default.createTimeRange(t,e)},t.prototype.media_=function(){var t=this.tech_.el_.vjs_getProperty("levels"),e=this.tech_.el_.vjs_getProperty("level"),i=void 0;return t.length&&(i={resolvedUri:t[e].url,attributes:{BANDWIDTH:t[e].bitrate,RESOLUTION:{width:t[e].width,height:t[e].height}}}),i},t.prototype.onLoadedmetadata_=function(){var t=this;this.representations=(0,u.createRepresentations)(this.tech_);var e=o.default.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.representations().forEach(function(e){t.qualityLevels_.addQualityLevel(e)}),v(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_&&v(this.qualityLevels_,e[0].levelIndex+""),this.playlists.trigger("mediachange"),this.tech_.trigger({type:"mediachange",bubbles:!0})},t.prototype.onLevelLoaded_=function(){this.playlists.trigger("loadedplaylist")},t.prototype.onFragmentLoaded_=function(){this.tech_.trigger("bandwidthupdate"),this.captionStream_.flush()},t.prototype.onSeeking_=function(){var t=this;g(0,1/0,this.metadataTrack_),C(this.tech_.buffered(),this.tech_.currentTime()).length||(Object.keys(this.inbandTextTracks_).forEach(function(e){g(0,1/0,t.inbandTextTracks_[e])}),this.captionStream_.reset())},t.prototype.onId3updated_=function(t,e){var i=d.default.atob(e[0]),a=y(i),n={type:"timed-metadata",dataAlignmentIndicator:!0,data:a};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 i=this.tech_.currentTime();if(t.frames.forEach(function(t){var a=new d.default.VTTCue(i,i+.1,t.value||t.url||t.data||"");a.frame=t,a.value=t,_(a),e.metadataTrack_.addCue(a)}),this.metadataTrack_.cues&&this.metadataTrack_.cues.length){var a=this.metadataTrack_.cues,n=[],s=this.tech_.duration();(isNaN(s)||Math.abs(s)===1/0)&&(s=Number.MAX_VALUE);for(var o=0;o<a.length;o++)n.push(a[o]);n.sort(function(t,e){return t.startTime-e.startTime});for(var r=0;r<n.length-1;r++)n[r].endTime!==n[r+1].startTime&&(n[r].endTime=n[r+1].startTime);n[n.length-1].endTime=s}},t.prototype.onCaptionData_=function(t,e){var i=this;e[0].forEach(function(t){i.captionStream_.push({pts:9e4*t.pos,dts:9e4*t.dts,escapedRBSP:y(d.default.atob(t.data)),nalUnitType:"sei_rbsp"})})},t.prototype.onCaptionStreamData_=function(t){t&&(this.inbandTextTracks_[t.stream]||(f(this.tech_,"captions",t.stream),this.inbandTextTracks_[t.stream]=this.tech_.addRemoteTextTrack({kind:"captions",label:t.stream,id:t.stream},!1).track),m(this.tech_.buffered(),this.inbandTextTracks_[t.stream]),this.inbandTextTracks_[t.stream].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.onSeeking_),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.tech_.off("levelloaded",this.onLevelLoaded_),this.tech_.off("fragmentloaded",this.onFragmentLoaded_),this.qualityLevels_&&this.qualityLevels_.dispose()},t}(),b={},E=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;b.canPlayType=function(t){return E.test(t)?"maybe":""},b.canHandleSource=function(t,e){return"maybe"===b.canPlayType(t.type)},b.handleSource=function(t,e,i){return e.hls=new S(t,e,i),e.hls.src(t),e.hls},o.default.getTech("Flash").registerSourceHandler(b,0),b.VERSION="1.4.4",i.default=b}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[8]); | ||
/*! @name @brightcove/videojs-flashls-source-handler @version 1.4.5 @license Apache-2.0 */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("video.js"),require("global/window")):"function"==typeof define&&define.amd?define(["exports","video.js","global/window"],e):e(t.videojsFlashlsSourceHandler={},t.videojs,t.window)}(this,function(t,e,i){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,i=i&&i.hasOwnProperty("default")?i.default:i;var a=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var a;return!!t[e]&&(a=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(a,1),a>-1)},this.trigger=function(e){var i,a,s,n;if(i=t[e])if(2===arguments.length)for(s=i.length,a=0;a<s;++a)i[a].call(this,arguments[1]);else{for(n=[],a=arguments.length,a=1;a<arguments.length;++a)n.push(arguments[a]);for(s=i.length,a=0;a<s;++a)i[a].apply(this,n)}},this.dispose=function(){t={}}}};a.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),t},a.prototype.push=function(t){this.trigger("data",t)},a.prototype.flush=function(t){this.trigger("done",t)};var s=a,n=function(t){for(var e=0,i={payloadType:-1,payloadSize:0},a=0,s=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)a+=255,e++;for(a+=t[e++];255===t[e];)s+=255,e++;if(s+=t[e++],!i.payload&&4===a){i.payloadType=a,i.payloadSize=s,i.payload=t.subarray(e,e+s);break}e+=s,a=0,s=0}return i},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)},o=function(t,e){var i,a,s,n,r=[];if(!(64&e[0]))return r;for(a=31&e[0],i=0;i<a;i++)n={type:3&e[2+(s=3*i)],pts:t},4&e[s+2]&&(n.ccData=e[s+3]<<8|e[s+4],r.push(n));return r},h=4,d=function(){d.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new u(0,0),new u(0,1),new u(1,0),new u(1,1)],this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("done",this.trigger.bind(this,"done"))},this)};d.prototype=new s,d.prototype.push=function(t){var e,i,a;if("sei_rbsp"===t.nalUnitType&&(e=n(t.escapedRBSP)).payloadType===h&&(i=r(e)))if(t.dts<this.latestDts_)this.ignoreNextEqualDts_=!0;else{if(t.dts===this.latestDts_&&this.ignoreNextEqualDts_)return this.numSameDts_--,void(this.numSameDts_||(this.ignoreNextEqualDts_=!1));a=o(t.pts,i),this.captionPackets_=this.captionPackets_.concat(a),this.latestDts_!==t.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=t.dts}},d.prototype.flush=function(){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(function(t){t.type<2&&this.dispatchCea608Packet(t)},this),this.captionPackets_.length=0,this.ccStreams_.forEach(function(t){t.flush()},this)):this.ccStreams_.forEach(function(t){t.flush()},this)},d.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},d.prototype.dispatchCea608Packet=function(t){this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},d.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},d.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)};var l={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},_=function(t){return null===t?"":(t=l[t]||t,String.fromCharCode(t))},c=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],p=function(){for(var t=[],e=15;e--;)t.push("");return t},u=function(t,e){u.prototype.init.call(this),this.field_=t||0,this.dataChannel_=e||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,a,s,n;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),a=e>>>8,s=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=p();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=p();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=p()),this.mode_="paintOn",this.startPts_=t.pts;else if(this.isSpecialCharacter(a,s))n=_((a=(3&a)<<8)|s),this[this.mode_](t.pts,n),this.column_++;else if(this.isExtCharacter(a,s))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),n=_((a=(3&a)<<8)|s),this[this.mode_](t.pts,n),this.column_++;else if(this.isMidRowCode(a,s))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14==(14&s)&&this.addFormatting(t.pts,["i"]),1==(1&s)&&this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(a,s))this.column_+=3&s;else if(this.isPAC(a,s)){var r=c.indexOf(7968&e);"rollUp"===this.mode_&&this.setRollUp(t.pts,r),r!==this.row_&&(this.clearFormatting(t.pts),this.row_=r),1&s&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16==(16&e)&&(this.column_=4*((14&e)>>1)),this.isColorPAC(s)&&14==(14&s)&&this.addFormatting(t.pts,["i"])}else this.isNormalChar(a)&&(0===s&&(s=null),n=_(a),n+=_(s),this[this.mode_](t.pts,n),this.column_+=n.length)}else this.lastControlCode_=null}};u.prototype=new s,u.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){return t.trim()}).join("\n").replace(/^\n+|\n+$/g,"");e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e,stream:this.name_})},u.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=p(),this.nonDisplayed_=p(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},u.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},u.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},u.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},u.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},u.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=33&&e<=35},u.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},u.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},u.prototype.isNormalChar=function(t){return t>=32&&t<=127},u.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=p(),this.displayed_=p()),void 0!==e&&e!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[e-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===e&&(e=this.row_),this.topRow_=e-this.rollUpRows_+1},u.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},u.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},u.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},u.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},u.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},u.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i};var f,y={CaptionStream:d,Cea608Stream:u}.CaptionStream,m={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},g=function(t,e,i){var a,s="";for(a=e;a<i;a++)s+="%"+("00"+t[a].toString(16)).slice(-2);return s},v=function(t,e,i){return decodeURIComponent(g(t,e,i))},T=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},C={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=v(t.data,1,e),t.value=v(t.data,e+1,t.data.length).replace(/\0*$/,"");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=v(t.data,1,e),t.url=v(t.data,e+1,t.data.length);break}},PRIV:function(t){var e,i;for(e=0;e<t.data.length;e++)if(0===t.data[e]){t.owner=(i=t.data,unescape(g(i,0,e)));break}t.privateData=t.data.subarray(e+1),t.data=t.privateData}};(f=function(t){var e,i={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},a=0,s=[],n=0;if(f.prototype.init.call(this),this.dispatchType=m.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(e=0;e<i.descriptor.length;e++)this.dispatchType+=("00"+i.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,r,o,h,d;if("timed-metadata"===t.type)if(t.dataAlignmentIndicator&&(n=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)))i.debug&&console.log("Skipping unrecognized metadata packet");else if(s.push(t),n+=t.data.byteLength,1===s.length&&(a=T(t.data.subarray(6,10)),a+=10),!(n<a)){for(e={data:new Uint8Array(a),frames:[],pts:s[0].pts,dts:s[0].dts},d=0;d<a;)e.data.set(s[0].data.subarray(0,a-d),d),d+=s[0].data.byteLength,n-=s[0].data.byteLength,s.shift();r=10,64&e.data[5]&&(r+=4,r+=T(e.data.subarray(10,14)),a-=T(e.data.subarray(16,20)));do{if((o=T(e.data.subarray(r+4,r+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if((h={id:String.fromCharCode(e.data[r],e.data[r+1],e.data[r+2],e.data[r+3]),data:e.data.subarray(r+10,r+o+10)}).key=h.id,C[h.id]&&(C[h.id](h),"com.apple.streaming.transportStreamTimestamp"===h.owner)){var l=h.data,_=(1&l[3])<<30|l[4]<<22|l[5]<<14|l[6]<<6|l[7]>>>2;_*=4,_+=3&l[7],h.timeStamp=_,void 0===e.pts&&void 0===e.dts&&(e.pts=h.timeStamp,e.dts=h.timeStamp),this.trigger("timestamp",h)}e.frames.push(h),r+=10,r+=o}while(r<a);this.trigger("data",e)}}}).prototype=new s;var S=f,b=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e},w=function(t,e,i){var a,s;if(i&&i.cues)for(a=i.cues.length;a--;)(s=i.cues[a]).startTime<=e&&s.endTime>=t&&i.removeCue(s)},P=function(t,e){t.length&&w(0,t.start(0),e)},E=function(t,e){for(var i=-1,a=0;a<t.length;a++)if(t[a].id===e){i=a;break}t.selectedIndex_=i,t.trigger({selectedIndex:i,type:"change"})},R=function(t,i){return function(t,i){var a=[];if(t&&t.length)for(var s=0;s<t.length;s++)i(t.start(s),t.end(s))&&a.push([t.start(s),t.end(s)]);return e.createTimeRanges(a)}(t,function(t,e){return t-1/30<=i&&e+1/30>=i})},D=function(){function t(t,i,a){var s=this;if(i.options_&&i.options_.playerId){var n=e(i.options_.playerId);n.hasOwnProperty("hls")||Object.defineProperty(n,"hls",{get:function(){return e.log.warn("player.hls is deprecated. Use player.tech_.hls instead."),i.trigger({type:"usage",name:"flashls-player-access"}),s}})}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_=i,this.metadataTrack_=null,this.inbandTextTracks_={},this.metadataStream_=new S,this.captionStream_=new y,this.onLoadedmetadata_=this.onLoadedmetadata_.bind(this),this.onSeeking_=this.onSeeking_.bind(this),this.onId3updated_=this.onId3updated_.bind(this),this.onCaptionData_=this.onCaptionData_.bind(this),this.onMetadataStreamData_=this.onMetadataStreamData_.bind(this),this.onCaptionStreamData_=this.onCaptionStreamData_.bind(this),this.onLevelSwitch_=this.onLevelSwitch_.bind(this),this.onLevelLoaded_=this.onLevelLoaded_.bind(this),this.onFragmentLoaded_=this.onFragmentLoaded_.bind(this),this.onAudioTrackChanged=this.onAudioTrackChanged.bind(this),this.onPlay_=this.onPlay_.bind(this),this.tech_.on("loadedmetadata",this.onLoadedmetadata_),this.tech_.on("seeking",this.onSeeking_),this.tech_.on("id3updated",this.onId3updated_),this.tech_.on("captiondata",this.onCaptionData_),this.tech_.on("levelswitch",this.onLevelSwitch_),this.tech_.on("levelloaded",this.onLevelLoaded_),this.tech_.on("fragmentloaded",this.onFragmentLoaded_),this.tech_.on("play",this.onPlay_),this.metadataStream_.on("data",this.onMetadataStreamData_),this.captionStream_.on("data",this.onCaptionStreamData_),this.playlists=new e.EventTarget,this.playlists.media=function(){return s.media_()}}var a=t.prototype;return a.src=function(t){t&&this.tech_.setSrc(t.src)},a.onPlay_=function(){if(this.tech_.duration()===1/0){var t=this.seekable();if(this.tech_.currentTime()<t.start(0))return this.tech_.setCurrentTime(t.end(t.length-1))}},a.seekable=function(){var t=this.tech_.el_.vjs_getProperty("seekableStart"),i=this.tech_.el_.vjs_getProperty("seekableEnd");return 0===i?e.createTimeRange():e.createTimeRange(t,i)},a.media_=function(){var t,e=this.tech_.el_.vjs_getProperty("levels"),i=this.tech_.el_.vjs_getProperty("level");return e.length&&(t={resolvedUri:e[i].url,attributes:{BANDWIDTH:e[i].bitrate,RESOLUTION:{width:e[i].width,height:e[i].height}}}),t},a.onLoadedmetadata_=function(){var t,i,a,s=this;this.representations=(t=this.tech_,i=null,a=function(){var e=i.filter(function(t){return t.enabled()});if(e.length===i.length||0===e.length)return t.el_.vjs_setProperty("autoLevelCapping",-1),void t.el_.vjs_setProperty("level",-1);if(1===e.length)return t.el_.vjs_setProperty("level",parseInt(e[0].id,10)),void t.el_.vjs_setProperty("autoLevelCapping",-1);var a=e[e.length-1].id;t.el_.vjs_setProperty("autoLevelCapping",parseInt(a,10)),t.el_.vjs_setProperty("level",-1)},function(){if(!i){var e=t.el_.vjs_getProperty("levels");i=e.filter(function(t){return!t.audio}).map(function(t,e){var i={id:e.index+"",width:e.width,height:e.height,bandwidth:e.bitrate,isEnabled_:!0,enabled:function(e){if(void 0===e)return i.isEnabled_;e!==i.isEnabled_&&(!0!==e&&!1!==e||(i.isEnabled_=e,t()))}};return i}.bind(null,a))}return i});var n=e.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.representations().forEach(function(t){s.qualityLevels_.addQualityLevel(t)}),E(this.qualityLevels_,this.tech_.el_.vjs_getProperty("level")+"")),function(t){var i=t.el_.vjs_getProperty("altAudioTracks"),a=t.el_.vjs_getProperty("audioTracks"),s=t.el_.vjs_getProperty("audioTrack");a.forEach(function(a,n){var r=i[a.id];t.audioTracks().addTrack(new e.AudioTrack({id:r.name,enabled:s===n,language:r.lang,default:r.default_track,label:r.name}))})}(this.tech_),this.tech_.audioTracks().on("change",this.onAudioTrackChanged)},a.onAudioTrackChanged=function(){!function(t){for(var e=t.el_.vjs_getProperty("audioTracks"),i=t.audioTracks(),a=null,s=0;s<i.length;s++)if(i[s].enabled){a=i[s].id;break}if(null!==a)for(var n=0;n<e.length;n++)if(a===e[n].title)return void t.el_.vjs_setProperty("audioTrack",n)}(this.tech_)},a.onLevelSwitch_=function(t,e){this.qualityLevels_&&E(this.qualityLevels_,e[0].levelIndex+""),this.playlists.trigger("mediachange"),this.tech_.trigger({type:"mediachange",bubbles:!0})},a.onLevelLoaded_=function(){this.playlists.trigger("loadedplaylist")},a.onFragmentLoaded_=function(){this.tech_.trigger("bandwidthupdate"),this.captionStream_.flush()},a.onSeeking_=function(){var t=this;w(0,1/0,this.metadataTrack_),R(this.tech_.buffered(),this.tech_.currentTime()).length||(Object.keys(this.inbandTextTracks_).forEach(function(e){w(0,1/0,t.inbandTextTracks_[e])}),this.captionStream_.reset())},a.onId3updated_=function(t,e){var a=i.atob(e[0]),s={type:"timed-metadata",dataAlignmentIndicator:!0,data:b(a)};this.metadataStream_.push(s)},a.onMetadataStreamData_=function(t){var a=this;this.metadataTrack_||(this.metadataTrack_=this.tech_.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,this.metadataTrack_.inBandMetadataTrackDispatchType=""),P(this.tech_.buffered(),this.metadataTrack_);var s=this.tech_.currentTime();if(t.frames.forEach(function(t){var n=new i.VTTCue(s,s+.1,t.value||t.url||t.data||"");n.frame=t,n.value=t,function(t){Object.defineProperties(t.frame,{id:{get:function(){return e.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return e.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return e.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})}(n),a.metadataTrack_.addCue(n)}),this.metadataTrack_.cues&&this.metadataTrack_.cues.length){var n=this.metadataTrack_.cues,r=[],o=this.tech_.duration();(isNaN(o)||Math.abs(o)===1/0)&&(o=Number.MAX_VALUE);for(var h=0;h<n.length;h++)r.push(n[h]);r.sort(function(t,e){return t.startTime-e.startTime});for(var d=0;d<r.length-1;d++)r[d].endTime!==r[d+1].startTime&&(r[d].endTime=r[d+1].startTime);r[r.length-1].endTime=o}},a.onCaptionData_=function(t,e){var a=this;e[0].forEach(function(t){a.captionStream_.push({pts:9e4*t.pos,dts:9e4*t.dts,escapedRBSP:b(i.atob(t.data)),nalUnitType:"sei_rbsp"})})},a.onCaptionStreamData_=function(t){t&&(this.inbandTextTracks_[t.stream]||(!function(t,e,i){for(var a=t.remoteTextTracks()||[],s=0;s<a.length;s++){var n=a[s];n.kind===e&&n.label===i&&t.removeRemoteTextTrack(n)}}(this.tech_,"captions",t.stream),this.inbandTextTracks_[t.stream]=this.tech_.addRemoteTextTrack({kind:"captions",label:t.stream,id:t.stream},!1).track),P(this.tech_.buffered(),this.inbandTextTracks_[t.stream]),this.inbandTextTracks_[t.stream].addCue(new i.VTTCue(t.startPts/9e4,t.endPts/9e4,t.text)))},a.dispose=function(){this.tech_.off("loadedmetadata",this.onLoadedmetadata_),this.tech_.off("seeked",this.onSeeking_),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.tech_.off("levelloaded",this.onLevelLoaded_),this.tech_.off("fragmentloaded",this.onFragmentLoaded_),this.tech_.off("play",this.onPlay_),this.qualityLevels_&&this.qualityLevels_.dispose()},t}(),O={},k=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;O.canPlayType=function(t){return k.test(t)?"maybe":""},O.canHandleSource=function(t,e){return"maybe"===O.canPlayType(t.type)},O.handleSource=function(t,e,i){return e.hls=new D(t,e,i),e.hls.src(t),e.hls},e.getTech("Flash").registerSourceHandler(O,0),O.VERSION="1.4.5",t.FlashlsHandler=D,t.default=O,Object.defineProperty(t,"__esModule",{value:!0})}); |
132
package.json
{ | ||
"name": "@brightcove/videojs-flashls-source-handler", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "A source handler to integrate flashls with video.js", | ||
"main": "es5/index.js", | ||
"main": "dist/videojs-flashls-source-handler.cjs.js", | ||
"generator-videojs-plugin": { | ||
"version": "2.2.0" | ||
"version": "7.3.2" | ||
}, | ||
@@ -12,42 +12,30 @@ "scripts": { | ||
"build": "npm-run-all -p build:*", | ||
"build:js": "npm-run-all build:js:babel build:js:browserify build:js:bannerize build:js:collapse build:js:uglify", | ||
"build:js:babel": "babel src -d es5", | ||
"build:js:bannerize": "bannerize dist/videojs-flashls-source-handler.js --banner=scripts/banner.ejs", | ||
"build:js:browserify": "browserify . -g browserify-shim -s videojs-flashls-source-handler -o dist/videojs-flashls-source-handler.js", | ||
"build:js:collapse": "bundle-collapser dist/videojs-flashls-source-handler.js -o dist/videojs-flashls-source-handler.min.js", | ||
"build:js:uglify": "uglifyjs dist/videojs-flashls-source-handler.min.js --comments --mangle --compress -o dist/videojs-flashls-source-handler.min.js", | ||
"build:test": "babel-node scripts/build-test.js", | ||
"build:swf": "cp node_modules/@brightcove/videojs-flashls-swf/dist/video-js.swf dist/", | ||
"clean": "rimraf dist test/dist es5 && mkdirp dist test/dist es5", | ||
"build:js": "rollup -c scripts/rollup.config.js", | ||
"build:swf": "shx cp node_modules/@brightcove/videojs-flashls-swf/dist/video-js.swf dist/", | ||
"clean": "shx rm -rf ./dist ./test/dist", | ||
"postclean": "shx mkdir -p ./dist ./test/dist", | ||
"docs": "npm-run-all docs:*", | ||
"docs:api": "jsdoc src -g plugins/markdown -r -d docs/api", | ||
"docs:toc": "doctoc README.md", | ||
"lint": "vjsstandard", | ||
"start": "babel-node scripts/server.js", | ||
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch", | ||
"start": "npm-run-all -p server watch", | ||
"pretest": "npm-run-all lint build", | ||
"test": "karma start test/karma.conf.js", | ||
"test:chrome": "npm run pretest && karma start test/karma.conf.js --browsers Chrome", | ||
"test:firefox": "npm run pretest && karma start test/karma.conf.js --browsers Firefox", | ||
"test:ie": "npm run pretest && karma start test/karma.conf.js --browsers IE", | ||
"test:safari": "npm run pretest && karma start test/karma.conf.js --browsers Safari", | ||
"test": "karma start scripts/karma.conf.js", | ||
"posttest": "shx cat test/dist/coverage/text.txt", | ||
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s", | ||
"preversion": "npm test", | ||
"version": "babel-node scripts/version.js", | ||
"postversion": "babel-node scripts/postversion.js", | ||
"prepublish": "npm run build" | ||
"version": "is-prerelease || npm run update-changelog && git add CHANGELOG.md", | ||
"watch": "npm-run-all -p watch:*", | ||
"watch:css": "npm run build:css -- -w", | ||
"watch:js": "npm run build:js -- -w", | ||
"prepublishOnly": "npm run build && vjsverify" | ||
}, | ||
"keywords": [ | ||
"videojs" | ||
"videojs", | ||
"videojs-plugin" | ||
], | ||
"author": "Brightcove", | ||
"license": "Apache-2.0", | ||
"browserify": { | ||
"transform": [ | ||
"browserify-versionify" | ||
] | ||
}, | ||
"browserify-shim": { | ||
"qunit": "global:QUnit", | ||
"sinon": "global:sinon", | ||
"video.js": "global:videojs" | ||
}, | ||
"style": "dist/videojs-flashls-source-handler.css", | ||
"videojs-plugin": { | ||
"style": "dist/videojs-flashls-source-handler.css", | ||
"script": "dist/videojs-flashls-source-handler.min.js" | ||
@@ -59,6 +47,3 @@ }, | ||
"docs", | ||
"es5", | ||
"scripts", | ||
"test/dist", | ||
"test/karma.conf.js" | ||
"test/dist" | ||
] | ||
@@ -70,3 +55,2 @@ }, | ||
"docs/", | ||
"es5/", | ||
"index.html", | ||
@@ -79,35 +63,47 @@ "scripts/", | ||
"@brightcove/videojs-flashls-swf": "6.4.3", | ||
"browserify-versionify": "^1.0.6", | ||
"global": "^4.3.0", | ||
"global": "^4.3.2", | ||
"mux.js": "^4.3.2", | ||
"video.js": "^5.10.1" | ||
"video.js": "^6 || ^7" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.14.0", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-es3": "^1.0.1", | ||
"babelify": "^7.3.0", | ||
"bannerize": "^1.0.2", | ||
"bluebird": "^3.2.2", | ||
"browserify": "^12.0.2", | ||
"browserify-shim": "^3.8.12", | ||
"budo": "^8.0.4", | ||
"bundle-collapser": "^1.2.1", | ||
"glob": "^6.0.3", | ||
"karma": "^2.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-detect-browsers": "^2.2.6", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-qunit": "^0.1.9", | ||
"lodash": "^4.11.2", | ||
"mkdirp": "^0.5.1", | ||
"npm-run-all": "^1.5.1", | ||
"qunitjs": "^1.21.0", | ||
"rimraf": "^2.5.1", | ||
"semver": "^5.3.0", | ||
"sinon": "~1.14.0", | ||
"uglify-js": "^2.6.1", | ||
"videojs-standard": "^4.0.0" | ||
"conventional-changelog-cli": "^2.0.1", | ||
"conventional-changelog-videojs": "^3.0.0", | ||
"doctoc": "^1.3.1", | ||
"husky": "^1.0.0-rc.13", | ||
"jsdoc": "https://github.com/BrandonOCasey/jsdoc#feat/plugin-from-cli", | ||
"karma": "^3.0.0", | ||
"lint-staged": "^7.2.2", | ||
"not-prerelease": "^1.0.1", | ||
"npm-merge-driver-install": "^1.0.0", | ||
"npm-run-all": "^4.1.3", | ||
"pkg-ok": "^2.2.0", | ||
"rollup": "^0.65.0", | ||
"shx": "^0.3.2", | ||
"sinon": "^6.1.5", | ||
"videojs-flash": "^2.1.1", | ||
"videojs-generate-karma-config": "~3.0.0", | ||
"videojs-generate-rollup-config": "~2.2.0", | ||
"videojs-generator-verify": "^1.0.5", | ||
"videojs-standard": "~7.1.0" | ||
}, | ||
"module": "dist/videojs-flashls-source-handler.es.js", | ||
"browserslist": [ | ||
"defaults", | ||
"ie 11" | ||
], | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"vjsstandard --fix", | ||
"git add" | ||
], | ||
"README.md": [ | ||
"npm run docs:toc", | ||
"git add" | ||
] | ||
} | ||
} |
# videojs-flashls-source-handler | ||
[![Build Status][travis-icon]][travis-link] | ||
[![Slack Status][slack-icon]][slack-link] | ||
[![Build Status](https://travis-ci.org/brightcove/videojs-flashls-source-handler.svg?branch=master)](https://travis-ci.org/brightcove/videojs-flashls-source-handler) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/brightcove/videojs-flashls-source-handler.svg)](https://greenkeeper.io/) | ||
[![Slack Status](http://slack.videojs.com/badge.svg)](http://slack.videojs.com) | ||
[![NPM](https://nodei.co/npm/@brightcove/videojs-flashls-source-handler.png?downloads=true&downloadRank=true)](https://nodei.co/npm/@brightcove/videojs-flashls-source-handler/) | ||
A source handler to integrate flashls with video.js | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Browserify](#browserify) | ||
- [RequireJS/AMD](#requirejsamd) | ||
- [License](#license) | ||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
## Installation | ||
```sh | ||
npm install --save videojs-flashls-source-handler | ||
npm install --save @brightcove/videojs-flashls-source-handler | ||
``` | ||
@@ -18,4 +34,2 @@ | ||
## The SWF | ||
This plugin requires the use of a [customized SWF](https://github.com/brightcove/videojs-flashls-swf) that is not included in videojs-flash. | ||
@@ -25,18 +39,17 @@ | ||
`videojs.options.flash.swf = '//path/to/swf';` | ||
### `<script>` Tag | ||
This is the simplest case. Get the script in whatever way you prefer and include the plugin _after_ you include [video.js][videojs], so that the `videojs` global is available. | ||
```html | ||
<script src="//path/to/video.min.js"></script> | ||
<script src="//path/to/videojs-flash.min.js"></script> | ||
<script src="//path/to/videojs-flashls-source-handler.min.js"></script> | ||
<script> | ||
var player = videojs('my-video'); | ||
player.flashlsSourceHandler(); | ||
var player = videojs('my-video', { | ||
flash: { | ||
swf: '//path/to/swf' | ||
} | ||
}); | ||
</script> | ||
``` | ||
__Note: The `swf` option must be set before or during player creation.__ | ||
### Browserify | ||
@@ -48,2 +61,3 @@ | ||
var videojs = require('video.js'); | ||
require('videojs-flash'); | ||
@@ -53,7 +67,9 @@ // The actual plugin function is exported by this module, but it is also | ||
// to a variable. | ||
require('videojs-flashls-source-handler'); | ||
require('@brightcove/videojs-flashls-source-handler'); | ||
var player = videojs('my-video'); | ||
player.flashlsSourceHandler(); | ||
var player = videojs('my-video', { | ||
flash: { | ||
swf: '//path/to/swf' | ||
} | ||
}); | ||
``` | ||
@@ -66,6 +82,8 @@ | ||
```js | ||
require(['video.js', 'videojs-flashls-source-handler'], function(videojs) { | ||
var player = videojs('my-video'); | ||
player.flashlsSourceHandler(); | ||
require(['video.js', 'videojs-flash', 'videojs-flashls-source-handler'], function(videojs) { | ||
var player = videojs('my-video', { | ||
flash: { | ||
swf: '//path/to/swf' | ||
} | ||
}); | ||
}); | ||
@@ -80,5 +98,1 @@ ``` | ||
[videojs]: http://videojs.com/ | ||
[slack-icon]: http://slack.videojs.com/badge.svg | ||
[slack-link]: http://slack.videojs.com | ||
[travis-icon]: https://travis-ci.org/brightcove/videojs-flashls-source-handler.svg?branch=master | ||
[travis-link]: https://travis-ci.org/brightcove/videojs-flashls-source-handler |
@@ -7,2 +7,3 @@ import videojs from 'video.js'; | ||
import { updateAudioTrack, setupAudioTracks } from './flashlsAudioTracks.js'; | ||
import {version as VERSION} from '../package.json'; | ||
@@ -125,3 +126,3 @@ /** | ||
* The quality levels list | ||
* @param {String} id | ||
* @param {string} id | ||
* The id of the new active quality level | ||
@@ -168,5 +169,6 @@ * @function updateSelectedIndex | ||
* time. | ||
* | ||
* @param {TimeRanges} buffered - the TimeRanges object to query | ||
* @param {number} time - the time to filter on. | ||
* @returns {TimeRanges} a new TimeRanges object | ||
* @return {TimeRanges} a new TimeRanges object | ||
*/ | ||
@@ -185,3 +187,3 @@ const findRange = function(buffered, time) { | ||
if (tech.options_ && tech.options_.playerId) { | ||
let _player = videojs(tech.options_.playerId); | ||
const _player = videojs(tech.options_.playerId); | ||
@@ -229,2 +231,3 @@ if (!_player.hasOwnProperty('hls')) { | ||
this.onAudioTrackChanged = this.onAudioTrackChanged.bind(this); | ||
this.onPlay_ = this.onPlay_.bind(this); | ||
@@ -238,2 +241,3 @@ this.tech_.on('loadedmetadata', this.onLoadedmetadata_); | ||
this.tech_.on('fragmentloaded', this.onFragmentLoaded_); | ||
this.tech_.on('play', this.onPlay_); | ||
@@ -255,2 +259,14 @@ this.metadataStream_.on('data', this.onMetadataStreamData_); | ||
onPlay_() { | ||
// if the viewer has paused and we fell out of the live window, | ||
// seek forward to the live point | ||
if (this.tech_.duration() === Infinity) { | ||
const seekable = this.seekable(); | ||
if (this.tech_.currentTime() < seekable.start(0)) { | ||
return this.tech_.setCurrentTime(seekable.end(seekable.length - 1)); | ||
} | ||
} | ||
} | ||
/** | ||
@@ -263,4 +279,4 @@ * Calculates the interval of time that is currently seekable. | ||
seekable() { | ||
let seekableStart = this.tech_.el_.vjs_getProperty('seekableStart'); | ||
let seekableEnd = this.tech_.el_.vjs_getProperty('seekableEnd'); | ||
const seekableStart = this.tech_.el_.vjs_getProperty('seekableStart'); | ||
const seekableEnd = this.tech_.el_.vjs_getProperty('seekableEnd'); | ||
@@ -312,3 +328,3 @@ if (seekableEnd === 0) { | ||
updateSelectedIndex(this.qualityLevels_, | ||
this.tech_.el_.vjs_getProperty('level') + ''); | ||
this.tech_.el_.vjs_getProperty('level') + ''); | ||
} | ||
@@ -497,4 +513,4 @@ | ||
new window.VTTCue(caption.startPts / 90000, | ||
caption.endPts / 90000, | ||
caption.text)); | ||
caption.endPts / 90000, | ||
caption.text)); | ||
} | ||
@@ -512,2 +528,3 @@ } | ||
this.tech_.off('fragmentloaded', this.onFragmentLoaded_); | ||
this.tech_.off('play', this.onPlay_); | ||
@@ -585,4 +602,4 @@ if (this.qualityLevels_) { | ||
// Include the version number. | ||
FlashlsSourceHandler.VERSION = '__VERSION__'; | ||
FlashlsSourceHandler.VERSION = VERSION; | ||
export default FlashlsSourceHandler; |
@@ -84,3 +84,3 @@ /** | ||
representations = levels.filter(level => !level.audio) | ||
.map(createRepresentation.bind(null, updateEnabled)); | ||
.map(createRepresentation.bind(null, updateEnabled)); | ||
} | ||
@@ -87,0 +87,0 @@ |
@@ -17,3 +17,5 @@ import QUnit from 'qunit'; | ||
}, { | ||
audioTrack: (val) => this.swfAudioTrack = val | ||
audioTrack: (val) => { | ||
this.swfAudioTrack = val; | ||
} | ||
}); | ||
@@ -28,170 +30,170 @@ | ||
QUnit.test('setupAudioTracks does nothing when no audio tracks from swf', | ||
function(assert) { | ||
setupAudioTracks(this.tech); | ||
function(assert) { | ||
setupAudioTracks(this.tech); | ||
assert.equal(this.vjsAudioTracks.length, 0, 'no videojs audio tracks created'); | ||
}); | ||
assert.equal(this.vjsAudioTracks.length, 0, 'no videojs audio tracks created'); | ||
}); | ||
QUnit.test('setupAudioTracks creates videojs audio tracks for each swf audio track', | ||
function(assert) { | ||
function(assert) { | ||
// org.mangui.hls.model.AudioTrack | ||
this.swfAudioTracks = [ | ||
{ | ||
id: 1, | ||
isDefault: true, | ||
isAAC: true, | ||
title: 'English', | ||
source: 1 | ||
}, | ||
{ | ||
id: 3, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'Spanish', | ||
source: 1 | ||
}, | ||
{ | ||
id: 5, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'French', | ||
source: 1 | ||
} | ||
]; | ||
this.swfAudioTracks = [ | ||
{ | ||
id: 1, | ||
isDefault: true, | ||
isAAC: true, | ||
title: 'English', | ||
source: 1 | ||
}, | ||
{ | ||
id: 3, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'Spanish', | ||
source: 1 | ||
}, | ||
{ | ||
id: 5, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'French', | ||
source: 1 | ||
} | ||
]; | ||
// org.mangui.hls.playlist.AltAudioTrack | ||
/* eslint-disable camelcase */ | ||
this.swfAltAudioTracks = [ | ||
{ | ||
group_id: 'low', | ||
lang: 'en', | ||
name: 'English', | ||
default_track: true, | ||
autoselect: true, | ||
url: '0.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'en', | ||
name: 'English', | ||
default_track: true, | ||
autoselect: true, | ||
url: '1.m3u8' | ||
}, | ||
{ | ||
group_id: 'low', | ||
lang: 'es', | ||
name: 'Spanish', | ||
default_track: false, | ||
autoselect: true, | ||
url: '2.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'es', | ||
name: 'Spanish', | ||
default_track: false, | ||
autoselect: true, | ||
url: '3.m3u8' | ||
}, | ||
{ | ||
group_id: 'low', | ||
lang: 'fr', | ||
name: 'French', | ||
default_track: false, | ||
autoselect: true, | ||
url: '4.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'fr', | ||
name: 'French', | ||
default_track: false, | ||
autoselect: true, | ||
url: '5.m3u8' | ||
} | ||
]; | ||
/* eslint-enable camelcase */ | ||
// org.mangui.hls.playlist.AltAudioTrack | ||
/* eslint-disable camelcase */ | ||
this.swfAltAudioTracks = [ | ||
{ | ||
group_id: 'low', | ||
lang: 'en', | ||
name: 'English', | ||
default_track: true, | ||
autoselect: true, | ||
url: '0.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'en', | ||
name: 'English', | ||
default_track: true, | ||
autoselect: true, | ||
url: '1.m3u8' | ||
}, | ||
{ | ||
group_id: 'low', | ||
lang: 'es', | ||
name: 'Spanish', | ||
default_track: false, | ||
autoselect: true, | ||
url: '2.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'es', | ||
name: 'Spanish', | ||
default_track: false, | ||
autoselect: true, | ||
url: '3.m3u8' | ||
}, | ||
{ | ||
group_id: 'low', | ||
lang: 'fr', | ||
name: 'French', | ||
default_track: false, | ||
autoselect: true, | ||
url: '4.m3u8' | ||
}, | ||
{ | ||
group_id: 'high', | ||
lang: 'fr', | ||
name: 'French', | ||
default_track: false, | ||
autoselect: true, | ||
url: '5.m3u8' | ||
} | ||
]; | ||
/* eslint-enable camelcase */ | ||
// set initial selection of swf audio track made by flashls | ||
this.swfAudioTrack = 0; | ||
// set initial selection of swf audio track made by flashls | ||
this.swfAudioTrack = 0; | ||
assert.equal(this.vjsAudioTracks.length, 0, 'Initial size of vjsAudioTracks'); | ||
assert.equal(this.vjsAudioTracks.length, 0, 'Initial size of vjsAudioTracks'); | ||
setupAudioTracks(this.tech); | ||
setupAudioTracks(this.tech); | ||
assert.equal(this.vjsAudioTracks.length, 3, 'Length after setupAudioTracks()'); | ||
assert.equal(this.vjsAudioTracks[0].id, 'English', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[0].enabled, true, 'correct audio track enabled'); | ||
assert.equal(this.vjsAudioTracks[1].id, 'Spanish', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[1].enabled, false, 'Other Audio track are disabled'); | ||
assert.equal(this.vjsAudioTracks[2].id, 'French', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[2].enabled, false, 'Other Audio track are disabled'); | ||
}); | ||
assert.equal(this.vjsAudioTracks.length, 3, 'Length after setupAudioTracks()'); | ||
assert.equal(this.vjsAudioTracks[0].id, 'English', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[0].enabled, true, 'correct audio track enabled'); | ||
assert.equal(this.vjsAudioTracks[1].id, 'Spanish', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[1].enabled, false, 'Other Audio track are disabled'); | ||
assert.equal(this.vjsAudioTracks[2].id, 'French', 'corrrect id'); | ||
assert.equal(this.vjsAudioTracks[2].enabled, false, 'Other Audio track are disabled'); | ||
}); | ||
QUnit.test('updateAudioTrack sets audioTrack on swf when videojs audioTrack changes', | ||
function(assert) { | ||
function(assert) { | ||
// org.mangui.hls.model.AudioTrack | ||
this.swfAudioTracks = [ | ||
{ | ||
id: 1, | ||
isDefault: true, | ||
isAAC: true, | ||
title: 'English', | ||
source: 1 | ||
}, | ||
{ | ||
id: 3, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'Spanish', | ||
source: 1 | ||
}, | ||
{ | ||
id: 5, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'French', | ||
source: 1 | ||
} | ||
]; | ||
this.swfAudioTracks = [ | ||
{ | ||
id: 1, | ||
isDefault: true, | ||
isAAC: true, | ||
title: 'English', | ||
source: 1 | ||
}, | ||
{ | ||
id: 3, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'Spanish', | ||
source: 1 | ||
}, | ||
{ | ||
id: 5, | ||
isDefault: false, | ||
isAAC: true, | ||
title: 'French', | ||
source: 1 | ||
} | ||
]; | ||
this.vjsAudioTracks.push({ | ||
id: 'English', | ||
label: 'English', | ||
enabled: false, | ||
language: 'en', | ||
default: true | ||
}, { | ||
id: 'Spanish', | ||
label: 'Spanish', | ||
enabled: false, | ||
language: 'es', | ||
default: false | ||
}, { | ||
id: 'French', | ||
label: 'French', | ||
enabled: false, | ||
language: 'fr', | ||
default: false | ||
}); | ||
this.vjsAudioTracks.push({ | ||
id: 'English', | ||
label: 'English', | ||
enabled: false, | ||
language: 'en', | ||
default: true | ||
}, { | ||
id: 'Spanish', | ||
label: 'Spanish', | ||
enabled: false, | ||
language: 'es', | ||
default: false | ||
}, { | ||
id: 'French', | ||
label: 'French', | ||
enabled: false, | ||
language: 'fr', | ||
default: false | ||
}); | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, -1, | ||
'When all tracks are disabled, it does not set any track'); | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, -1, | ||
'When all tracks are disabled, it does not set any track'); | ||
this.vjsAudioTracks[1].enabled = true; | ||
this.vjsAudioTracks[2].enabled = true; | ||
this.vjsAudioTracks[1].enabled = true; | ||
this.vjsAudioTracks[2].enabled = true; | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, 1, | ||
'When more than 1 track enabled, set the swf audio track to the first enabled track'); | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, 1, | ||
'When more than 1 track enabled, set the swf audio track to the first enabled track'); | ||
this.vjsAudioTracks[1].enabled = false; | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, 2, | ||
'Correct enabled audio track id after switching tracks'); | ||
}); | ||
this.vjsAudioTracks[1].enabled = false; | ||
this.swfAudioTrack = -1; | ||
updateAudioTrack(this.tech); | ||
assert.equal(this.swfAudioTrack, 2, | ||
'Correct enabled audio track id after switching tracks'); | ||
}); |
@@ -56,97 +56,101 @@ import QUnit from 'qunit'; | ||
QUnit.test('createRepresentations creates a list of representation objects', | ||
function(assert) { | ||
const levels = [ | ||
{ | ||
index: 0, | ||
width: 640, | ||
height: 360, | ||
bitrate: 865000 | ||
}, | ||
{ | ||
index: 1, | ||
width: 1280, | ||
height: 720, | ||
bitrate: 12140000 | ||
}, | ||
{ | ||
index: 2, | ||
width: void 0, | ||
height: void 0, | ||
bitrate: 65000, | ||
audio: true | ||
}, | ||
{ | ||
index: 3, | ||
width: 1920, | ||
height: 1080, | ||
bitrate: 16120000 | ||
} | ||
]; | ||
const tech = makeMochTech({ levels: () => levels }, {}); | ||
function(assert) { | ||
const levels = [ | ||
{ | ||
index: 0, | ||
width: 640, | ||
height: 360, | ||
bitrate: 865000 | ||
}, | ||
{ | ||
index: 1, | ||
width: 1280, | ||
height: 720, | ||
bitrate: 12140000 | ||
}, | ||
{ | ||
index: 2, | ||
width: void 0, | ||
height: void 0, | ||
bitrate: 65000, | ||
audio: true | ||
}, | ||
{ | ||
index: 3, | ||
width: 1920, | ||
height: 1080, | ||
bitrate: 16120000 | ||
} | ||
]; | ||
const tech = makeMochTech({ levels: () => levels }, {}); | ||
const representationsApi = createRepresentations(tech); | ||
const representationsApi = createRepresentations(tech); | ||
assert.equal(typeof representationsApi, 'function', | ||
'createRepresentations returns a function for getting the list of representations'); | ||
assert.equal(typeof representationsApi, 'function', | ||
'createRepresentations returns a function for getting the list of representations'); | ||
const representations = representationsApi(); | ||
const representations = representationsApi(); | ||
assert.equal(representations.length, 3, 'created a list of representations'); | ||
assert.equal(representations[0].id, '0', 'created representation for video'); | ||
assert.equal(representations[1].id, '1', 'created representation for video'); | ||
assert.equal(representations[2].id, '3', 'created representation for video'); | ||
}); | ||
assert.equal(representations.length, 3, 'created a list of representations'); | ||
assert.equal(representations[0].id, '0', 'created representation for video'); | ||
assert.equal(representations[1].id, '1', 'created representation for video'); | ||
assert.equal(representations[2].id, '3', 'created representation for video'); | ||
}); | ||
QUnit.test('representations sets levels on tech correctly when enabling/disabling', | ||
function(assert) { | ||
const levels = [ | ||
{ | ||
index: 0, | ||
width: 640, | ||
height: 360, | ||
bitrate: 865000 | ||
}, | ||
{ | ||
index: 1, | ||
width: 1280, | ||
height: 720, | ||
bitrate: 12140000 | ||
}, | ||
{ | ||
index: 2, | ||
width: 1920, | ||
height: 1080, | ||
bitrate: 16120000 | ||
} | ||
]; | ||
let currentLevel = -1; | ||
let autoLevelCapping = -1; | ||
const tech = makeMochTech({ levels: () => levels }, { | ||
level: (val) => currentLevel = val, | ||
autoLevelCapping: (val) => autoLevelCapping = val | ||
}); | ||
const representations = createRepresentations(tech)(); | ||
function(assert) { | ||
const levels = [ | ||
{ | ||
index: 0, | ||
width: 640, | ||
height: 360, | ||
bitrate: 865000 | ||
}, | ||
{ | ||
index: 1, | ||
width: 1280, | ||
height: 720, | ||
bitrate: 12140000 | ||
}, | ||
{ | ||
index: 2, | ||
width: 1920, | ||
height: 1080, | ||
bitrate: 16120000 | ||
} | ||
]; | ||
let currentLevel = -1; | ||
let autoLevelCapping = -1; | ||
const tech = makeMochTech({ levels: () => levels }, { | ||
level: (val) => { | ||
currentLevel = val; | ||
}, | ||
autoLevelCapping: (val) => { | ||
autoLevelCapping = val; | ||
} | ||
}); | ||
const representations = createRepresentations(tech)(); | ||
assert.deepEqual(representations.map(rep => rep.enabled()), [true, true, true], | ||
'all representations enabled on creation'); | ||
assert.equal(currentLevel, -1, 'auto level mode'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping'); | ||
assert.deepEqual(representations.map(rep => rep.enabled()), [true, true, true], | ||
'all representations enabled on creation'); | ||
assert.equal(currentLevel, -1, 'auto level mode'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping'); | ||
representations[2].enabled(false); | ||
assert.equal(currentLevel, -1, | ||
'auto level mode when more than one representation is enabled'); | ||
assert.equal(autoLevelCapping, 1, 'autoLevelCapping set to highest enabled bitrate'); | ||
representations[2].enabled(false); | ||
assert.equal(currentLevel, -1, | ||
'auto level mode when more than one representation is enabled'); | ||
assert.equal(autoLevelCapping, 1, 'autoLevelCapping set to highest enabled bitrate'); | ||
representations[2].enabled(true); | ||
assert.equal(currentLevel, -1, 'auto level mode when all enabled'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping when all enabled'); | ||
representations[2].enabled(true); | ||
assert.equal(currentLevel, -1, 'auto level mode when all enabled'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping when all enabled'); | ||
representations[2].enabled(false); | ||
representations[0].enabled(false); | ||
assert.equal(currentLevel, 1, 'manual level mode when only one enabled representation'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping in manual level mode'); | ||
representations[2].enabled(false); | ||
representations[0].enabled(false); | ||
assert.equal(currentLevel, 1, 'manual level mode when only one enabled representation'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping in manual level mode'); | ||
representations[1].enabled(false); | ||
assert.equal(currentLevel, -1, 'auto level mode when all disabled'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping when all disabled'); | ||
}); | ||
representations[1].enabled(false); | ||
assert.equal(currentLevel, -1, 'auto level mode when all disabled'); | ||
assert.equal(autoLevelCapping, -1, 'no autoLevelCapping when all disabled'); | ||
}); |
@@ -37,16 +37,38 @@ import QUnit from 'qunit'; | ||
QUnit.test('triggers an event when bandwidth updates after segment load', | ||
function(assert) { | ||
let bandwidthupdate = 0; | ||
function(assert) { | ||
let bandwidthupdate = 0; | ||
const tech = makeMochTech({}); | ||
const tech = makeMochTech({}); | ||
/* eslint-disable no-unused-vars */ | ||
// need to create handler to setup event listeners | ||
const handler = new FlashlsHandler('this.m3u8', tech, {}); | ||
/* eslint-enable no-unused-vars */ | ||
/* eslint-disable no-unused-vars */ | ||
// need to create handler to setup event listeners | ||
const handler = new FlashlsHandler('this.m3u8', tech, {}); | ||
/* eslint-enable no-unused-vars */ | ||
tech.on('bandwidthupdate', () => bandwidthupdate++); | ||
tech.on('bandwidthupdate', () => bandwidthupdate++); | ||
tech.trigger('fragmentloaded'); | ||
assert.equal(bandwidthupdate, 1, 'tech fired a bandwidthupdate'); | ||
}); | ||
tech.trigger('fragmentloaded'); | ||
assert.equal(bandwidthupdate, 1, 'tech fired a bandwidthupdate'); | ||
}); | ||
QUnit.test('seeks to live point when playhead is outside seekable', | ||
function(assert) { | ||
let time = 0; | ||
const tech = makeMochTech({}); | ||
tech.duration = () => Infinity; | ||
tech.currentTime = () => 0; | ||
tech.setCurrentTime = (t) => { | ||
time = t; | ||
}; | ||
const handler = new FlashlsHandler('this.m3u8', tech, {}); | ||
const seekableStart = 10; | ||
const seekableEnd = 20; | ||
const seekable = videojs.createTimeRange(seekableStart, seekableEnd); | ||
handler.seekable = () => seekable; | ||
tech.trigger('play'); | ||
assert.equal(time, seekableEnd, 'seeked to live'); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
535595
4
19
14626
93
1
23
4
+ Added@babel/runtime@7.26.0(transitive)
+ Added@videojs/http-streaming@2.16.3(transitive)
+ Added@videojs/vhs-utils@3.0.5(transitive)
+ Added@videojs/xhr@2.6.0(transitive)
+ Added@xmldom/xmldom@0.8.10(transitive)
+ Addedaes-decrypter@3.1.3(transitive)
+ Addedkeycode@2.2.1(transitive)
+ Addedm3u8-parser@4.8.0(transitive)
+ Addedmpd-parser@0.22.1(transitive)
+ Addedmux.js@6.0.1(transitive)
+ Addedpkcs7@1.0.4(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedurl-toolkit@2.2.5(transitive)
+ Addedvideo.js@7.21.6(transitive)
+ Addedvideojs-font@3.2.0(transitive)
+ Addedvideojs-vtt.js@0.15.5(transitive)
- Removedbrowserify-versionify@^1.0.6
- Removedbabel-runtime@6.26.0(transitive)
- Removedbrowserify-versionify@1.0.6(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedes5-shim@4.6.7(transitive)
- Removedfind-root@0.1.2(transitive)
- Removedglobal@4.3.04.3.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedparse-headers@2.0.5(transitive)
- Removedprocess@0.5.2(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedthrough2@0.6.3(transitive)
- Removedtsml@1.0.1(transitive)
- Removedvideo.js@5.20.5(transitive)
- Removedvideojs-font@2.0.0(transitive)
- Removedvideojs-ie8@1.1.2(transitive)
- Removedvideojs-swf@5.4.1(transitive)
- Removedvideojs-vtt.js@0.12.6(transitive)
- Removedxhr@2.2.2(transitive)
- Removedxtend@4.0.2(transitive)
Updatedglobal@^4.3.2
Updatedvideo.js@^6 || ^7