UNPKG

@eyevinn/web-player-airplay

Version:

See [@eyevinn/web-player](https://www.npmjs.com/package/@eyevinn/web-player).

2 lines (1 loc) 1.71 kB
var t,e=(t=require("mitt"))&&"object"==typeof t&&"default"in t?t.default:t;function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var n,r=function(){function t(){this.emitter=e()}var i=t.prototype;return i.on=function(t,e){this.emitter.on.apply(this,arguments)},i.off=function(t,e){this.emitter.on.apply(this,arguments)},i.emit=function(t,e){this.emitter.emit.apply(this,arguments)},i.destroy=function(){this.emitter.all.clear()},t}();(n=exports.AirPlayEvent||(exports.AirPlayEvent={})).AVAILABILITY_CHANGED="airplay:availability_changed",n.TARGET_CHANGED="airplay:target_changed",exports.AirPlay=function(t){var e,n;function r(e){var i;return(i=t.call(this)||this).video=e,window.WebKitPlaybackTargetAvailabilityEvent?(e.addEventListener("webkitplaybacktargetavailabilitychanged",i.onAvailabilityChanged=i.onAvailabilityChanged.bind(a(i))),e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",i.onTargetChanged=i.onTargetChanged.bind(a(i)))):i.emit(exports.AirPlayEvent.AVAILABILITY_CHANGED,{available:!1}),i}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,i(e,n);var o=r.prototype;return o.onAvailabilityChanged=function(t){this.emit(exports.AirPlayEvent.AVAILABILITY_CHANGED,{available:"available"===t.availability})},o.onTargetChanged=function(t){this.emit(exports.AirPlayEvent.TARGET_CHANGED,{wireless:!0})},o.toggleAirPlay=function(){this.video.webkitShowPlaybackTargetPicker()},o.destroy=function(){this.video.removeEventListener("webkitplaybacktargetavailabilitychanged",this.onAvailabilityChanged)},r}(r);