flowplayer-files
Version:
Flowplayer js and css files for v2.5.9 after the reboot of flowplayer
17 lines (14 loc) • 16.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e=e||self).flowplayer=e.flowplayer||{},e.flowplayer.chromecast=t())}(this,(function(){"use strict";var e=[].slice;function t(e,t,n){for(var r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);r.length;){if(null==e)return n;var a=r.shift();if("string"!=typeof a)return n;e=e[a]}return null==e?n:e}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function r(e){var t=document.createElement("a");t.href=e;var n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function a(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}var o=function(e){var t=e.src,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}(e,["src"]);return[n({src:t,type:a("video/"+r(t))},o)]};function i(e){var t,n=e.split("{"),r=n[0],i=n[1];return i?(t=r,i.slice(0,-1).split(",").map((function(e){return{src:t+e,type:a("video/"+e)}}))):o({src:e})}function c(e){return"function"==typeof e}function u(){throw new Error("Function was expected as Argument[0]")}var s=[].slice;function f(e){if(!(this instanceof f))return new f(e);var t=this;return t.data=e,t.tap=function(){var e=s.call(arguments),n=e.shift();return n==f.lift?t.data:c(n)?(n.apply(t,[t.data].concat(e)),t):void u()},t.into=t.fmap=function(){var e=s.call(arguments),n=e.shift();return n==f.lift?t.data:c(n)?f(n.apply(t,[t.data].concat(e))):void u()},t.unwrap=function(){return t.data},t}f.of=f,f.lift=function(e){return e instanceof f?e.data:e},f._apply=f.apply=function(e,t){if(0==t.length)return e();if(1==t.length)return e(t[0]);if(2==t.length)return e(t[0],t[1]);if(3==t.length)return e(t[0],t[1],t[2]);if(4==t.length)return e(t[0],t[1],t[2],t[3]);if(5==t.length)return e(t[0],t[1],t[2],t[3],t[4]);throw new Error("Pipe._apply() does not support arity > 5")},f.maybe=function(e,t,n){return e?f._apply(t,[e].concat(s.call(arguments,2,arguments.length))):e},f.curry=function(e,t,n){return(t=t||[]).length>e.length-1?e.apply(n,t):function(){var r=t.concat(s.call(arguments));return f.curry(e,r,n)}};function l(){return d().fmap(f.maybe,(function(e){return e.getCurrentSession()}))}function p(){return l().fmap(f.maybe,(function(e){return e.getMediaSession()}))}function d(){return f.of(window).fmap(t,"cast.framework.CastContext").fmap(f.maybe,(function(e){return e.getInstance()}))}function m(){return t(window,"flowplayer.instances",[])}function y(){return m().filter((function(e){return U.is_same(e)}))}function v(){return m().filter((function(e){return!U.is_same(e)}))}function h(e,t){y().forEach((function(n){n.emit(e,t)}))}function g(e,t){v().forEach((function(n){n.emit(e,t)}))}function w(e,t){m().forEach((function(n){n.emit(e,t)}))}var E={PAUSED:"isPaused",CURRENT_TIME:"currentTime",DURATION:"duration",CONNECTED:"isConnected",PLAYER_STATE:"playerState",SAVED_STATE:"savedPlayerState",DISPLAY_NAME:"displayName",STATUS:"statusText"},_={player:void 0,controller:void 0};function b(){_.player=new cast.framework.RemotePlayer,_.controller=new cast.framework.RemotePlayerController(_.player),_.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,S),_.controller.addEventListener(cast.framework.RemotePlayerEventType.MEDIA_INFO_CHANGED,(function(){g("chromecast:idle")}))}function S(e){h("chromecast:field:update",e)}function T(e){var n=[].slice.call(e.querySelectorAll("track")),r=t(e,"hls.subtitleTracks",[]);return[].concat.apply([],n,r).filter((function(e){return"string"==typeof e.lang}))}function A(e){return T(e).map((function(e,t){var n=new chrome.cast.media.Track(t,chrome.cast.media.TrackType.TEXT);return n.trackContentType="text/vtt",n.subtype=chrome.cast.media.TextTrackType.SUBTITLES,n.trackContentId=e.src||e.url,n.name=e.label||e.name,n.language=e.lang,n}))}function C(e){N().fmap(f.maybe,(function(t){var n=new chrome.cast.media.EditTracksInfoRequest(e);t.editTracksInfo(n,console.debug,console.error)}))}var O=Object.freeze({__proto__:null,getCurrentSession:l,getMediaSession:p,getCastContext:d,players:m,casting_players:y,idle_players:v,broadcast_to_active:h,broadcast_to_idle:g,broadcast:w,FIELDS:E,SINGLETONS:_,refresh_singletons:b,onremotechange:S,tracks:T,cast_tracks:A,editTracks:C});function k(e,n,r){l().fmap(f.maybe,(function(n){var a=U.get_media(e);if(a){var o=new chrome.cast.media.MediaInfo(a.src,a.type);o.tracks=A(e),o.metadata=new chrome.cast.media.GenericMediaMetadata;var i=new chrome.cast.media.LoadRequest(o);isNaN(e.currentTime)||(i.currentTime=e.currentTime),o.tracks.length&&(i.activeTrackIds=T(e).filter((function(e){return"showing"==t(e,"track.mode",e.mode)})).map((function(e,t){return t}))),i.customData=t(e,"opts.chromecast",{}),console.debug("cast:request(%o)",i),n.loadMedia(i).then((function(){HTMLMediaElement.prototype.pause.call(e),b(),g("chromecast:idle")}),r)}}))}function N(){return p()}function x(){return!!p().unwrap()}function L(){return!!l().unwrap()}function P(){return N().fmap(f.maybe,t,"media.duration").unwrap()}function j(){return N().fmap(f.maybe,t,"playerState").unwrap()}function I(e){return e?D(e):N().fmap(f.maybe,(function(e){return e.getEstimatedTime()})).unwrap()}function D(e){return N().fmap(f.maybe,(function(t){var n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n)})),e}function M(){return N().fmap(f.maybe,(function(e){return e.play()})).unwrap()}function R(){return N().fmap(f.maybe,(function(e){return e.pause()})).unwrap()}var q=Object.freeze({__proto__:null,load:k,media:N,has_media:x,exists:L,device_name:function(){return l().fmap(f.maybe,(function(e){return e.getCastDevice().friendlyName})).unwrap()},duration:P,state:j,currentTime:I,seek:D,play:M,pause:R});var H=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function U(e){this.video=e,function(e,t){var n={play:function(){return U.is_same(t)?M():x()?U.load(t):void U.load(t)},pause:function(){return U.is_same(t)?R():HTMLMediaElement.prototype.pause.call(t)}};n.currentTime={get:I,set:I},n.duration={get:P},n.paused={get:function(){return"PAUSED"===j()}},n.playing={get:function(){return"PLAYING"===j()}},Object.keys(n).forEach((function(e){if("object"==typeof n[e])return Object.defineProperty(t,e,{get:function(){return U.is_same(t)?n[e].get():Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,e).get.call(this)},set:function(r){return U.is_same(t)?n[e].set(r):Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,e).set.call(this,r)}});var r=t[e];t[e]=function(){var t=[].slice.apply(arguments);return L()?n[e].apply(this,t):r.apply(this,t)}}))}(0,e)}function G(){}U.of=function(e){return e.sender||(e.sender=new U(e)),e.sender},U.normalize_src=function(e){return f.of(e).fmap(t,"original_src",[]).fmap((function(e){return"string"==typeof e?i(e):e})).fmap((function(e){return e.map((function(e){return"string"==typeof e?i(e):e}))})).fmap((function(e){return[].concat.apply([],e)})).fmap((function(e){return e.filter(U.is_supported_media)}))},U.is_same=function(e){const n=U.normalize_src(e).unwrap().map((function(e){return t(e,"src")}));return N().fmap(f.maybe,t,"media.contentId").fmap(f.maybe,(function(e){return!!~n.indexOf(e)})).unwrap()},U.maybe=function(e,t){e.sender&&t(e.sender,e)},U.getEstimatedTime=function(){return p().fmap(f.maybe,(function(e){return e.getEstimatedTime()})).unwrap()},U.is_supported_media=function(e){return t(e,"type","").toString().match(H)},U.load=function(e){k(e,console.debug,console.error)},U.destroy=function(e){e.video=0},U.get_media=function(e){return U.normalize_src(e).fmap(f.maybe,(function(e){return e.shift()})).unwrap()};var F=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"}),Y="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function z(e,n){if(document.querySelector("script[src='"+Y+"']"))return J();var r,a,o,i;r=Y,o=document.getElementsByTagName("head")[0],(i=document.createElement("script")).src=r,i.onload=i.onerror=a||G,o.appendChild(i),window.__onGCastApiAvailable=function(){!function(e,n){if(!B())return;var r=t(e,"chromecast.app","940D4BE4");d().fmap(f.maybe,(function(e){e.setOptions({receiverApplicationId:r,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),e.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){w("chromecast:state:changed",e)})),e.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){b(),w("chromecast:session:changed",e)}))}))}(e),J()}}function B(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function J(){if(B())return w("chromecast:available");w("chromecast:unavailable")}var W="is-chromecast-playing",V=!!function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}return e}()&&{passive:!0},X=["touchstart","touchmove"];function K(e){return e.emit=function(t,n,r){r=r||{};var a=function(e){var t=document.createEvent("Event");return t.initEvent(e,!1,!0),t}(t);return n&&function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];for(var a in t)e[a]=t[a]}(a,{data:n||{}}),e.dispatchEvent(a),!1===r.return_self?a:e},e.on=function(t,n){return"string"==typeof t&&(t=t.split(" ")),t.forEach((function(t){return function(e){return~X.indexOf(e)}(t)?e.addEventListener(t,n,V):e.addEventListener(t,n)})),e},e.off=function(t,n){return e.removeEventListener(t,n),e},e.one=e.once=function(t,n){return e.on(t,(function r(a){e.off(t,r),n(a)}))},e}var Q=Array.isArray,Z="undefined"!=typeof window&&K(window),$="undefined"!=typeof document&&K(document),ee=["span","a","em","p","i"],te=ee.concat(["div","strong","video","img","ol","ul","li","script"]);function ne(e,t,n){var r=ae(document.createElement(e));if(Q(t)&&(n=t,t=!1),Q(n)||(n=[n]),r.append(n.filter((function(e){return e}))),"object"!=typeof t)return r;for(var a in t)a in r?r[a]=t[a]:r.setAttribute(a,t[a]);return r}function re(t){var n=t.tagName;t.__flowplayer__=1,t.find=function(e){var n=t.querySelector(e);return n?ae(n):n},t.html=function(e){return t.innerHTML=e,t},t.empty=function(){return t.innerHTML="",t},t.offset=function(){var e={top:0,left:0},n=t;do{e.left+=n.offsetLeft||0,e.top+=n.offsetTop||0}while(n=n.offsetParent);return e},t.innerWidth=function(){var e=getComputedStyle(t);return t.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)};var r=t.insert=function(e,n){return Q(n)?n.map((function(n){return t.insert(e,n)}))[0]:ae(n="string"==typeof n?t.insertAdjacentHTML(e,n):t.insertAdjacentElement?t.insertAdjacentElement(e,n):t.appendChild(n))};return t.append=r.bind(t,"beforeend"),t.prepend=r.bind(t,"afterbegin"),t.css=function(e,n){if("object"==typeof e){for(var r in e)t.css(r,e[r]);return t}return void 0===n?getComputedStyle(t)[e]:(1*n&&(n+="px"),t.style[e]=n,t)},t.show=function(){return t.css({display:~ee.indexOf(n)?"inline":"block"})},t.hide=function(){return t.css({display:"none"})},t.remove=function(){var e=t.parentNode;e&&e.removeChild(t)},t.attr=function(e,n){return null==n?t.getAttribute(e):(t.setAttribute(e,n),t)},t.txt=function(e){return t.textContent=e,t},t.fp=function(e){return t.addClass("fp-"+e)},t.addClass=function(e){return e.split(" ").forEach((function(e){t.hasClass(e)||(t.className+=(t.className?" ":"")+e)})),t},t.removeClass=function(e){e=e.split(" ");var n=t.className.split(" ");return t.className=n.filter((function(t){return!~e.indexOf(t)})).join(" "),t},t.toggleClass=function(e,n){return void 0===n&&(n=!t.hasClass(e)),n?t.addClass(e):t.removeClass(e)},t.findAll=function(n){return r=t.querySelectorAll(n),e.call(r);var r},t.hasClass=function(e){return~t.className.split(" ").indexOf(e)},t}function ae(e){return void 0===e||function(e){return e&&e.__flowplayer__}(e)?e:re(K(e))}function oe(e,t){if("string"==typeof e&&"<"==e[0])return ne(e.slice(1,-1),t);if("string"!=typeof e)return ae(e);var n=t instanceof HTMLElement&&t.querySelector(".fp-"+e)||document.querySelector(e);return n?ae(n):void 0}oe.window=Z,oe.document=$,oe.el=ne,te.forEach((function(e){oe[e]=function(t,n){return"string"==typeof t&&(t={class:t}),ne(e,t,n)}}));function ie(e,n,r){"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname&&console.warn("Secure URL required to enable Chromecast"),z(e);var a={pending:void 0};r.on("reap",(function(){U.maybe(r,U.destroy)})),r.on("mount",(function(){var a,o,i,c,u=t(n,"middle");u&&(a=u,o={poster:e.poster},i=oe.div("fp-chromecast"),c=oe.el("p"),o.poster&&(i.style.backgroundImage=["url(",o.poster,")"].join("")),i.append(c),a.prepend(i));var s=t(n,"ui.header.secondary");s&&function(e,t){var n=oe.el("span").addClass("fp-cast-button");n.append(oe.el("google-cast-launcher")),e.prepend(n),n.on("click",(function(){const e=l().unwrap();if(e)return e.endSession(!0);t.emit("chromecast:start")}))}(s,r)})),r.on("chromecast:available",(function(){r.setState("is-cast-available",!0),U.of(r)})),r.on("chromecast:unavailable",(function(){r.setState("is-cast-available",!1),U.maybe(r,U.destroy)})),r.on("chromecast:start",(function(){if(x())return U.load(r);a.pending=!0})),r.on("tracks:text:updated",(function(e){if(x())return e.data?void C(T(r).map((function(e,t){return{track:e.track,id:t}})).filter((function(t){return t.track==e.data})).map((function(e){return e.id}))):C([])})),r.on("chromecast:idle",(function(){r.setState(W,!1),r.setState("is-starting",!0)})),r.on("chromecast:field:update",(function(e){var n=t(e,"data.field"),a=t(e,"data.value");switch(n){case E.CURRENT_TIME:return r.emit("timeupdate",a);case E.PLAYER_STATE:return"PLAYING"==a?r.emit("playing"):"PAUSED"==a?r.emit("pause"):void 0;case"mediaInfo":var o=(a||{}).fake_session||q;return function(e,n){if(0!=e.root){var r=e.root.querySelector(".fp-chromecast p");if(r){var a="";a=(a=e._t("chromecast.message","{{state}} on {{device}}").replace("{{device}}",t(n,"device","chromecast"))).replace("{{state}}",t(n,"state","").toLowerCase()),r.txt(a)}}}(r,{device:o.device_name(),state:o.state()}),o.hide_controls&&r.setState("no-chromecast-controls",!0),r.setState("is-starting",!1),r.setState(W,!0)}})),r.on("chromecast:session:changed",(function(e){switch(t(e,"data.sessionState")){case cast.framework.SessionState.SESSION_ENDED:return r.setState(W,!1);case cast.framework.SessionState.SESSION_RESUMED:case cast.framework.SessionState.SESSION_STARTED:a.pending&&(a.pending=!1,U.load(r))}}))}return window.CastSession=q,window.CastUtils=O,ie.apps=F,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});var n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,ie)}));