UNPKG

@eyevinn/web-player-airplay

Version:

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

2 lines (1 loc) 1.61 kB
var t,e=(t=require("mitt"))&&"object"==typeof t&&"default"in t?t.default:t;function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var a,n=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}();(a=exports.AirPlayEvent||(exports.AirPlayEvent={})).AVAILABILITY_CHANGED="airplay:availability_changed",a.TARGET_CHANGED="airplay:target_changed",exports.AirPlay=function(t){function e(e){var i;return(i=t.call(this)||this).video=e,window.WebKitPlaybackTargetAvailabilityEvent?(e.addEventListener("webkitplaybacktargetavailabilitychanged",i.onAvailabilityChanged=i.onAvailabilityChanged.bind(i)),e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",i.onTargetChanged=i.onTargetChanged.bind(i))):i.emit(exports.AirPlayEvent.AVAILABILITY_CHANGED,{available:!1}),i}var a,n;n=t,(a=e).prototype=Object.create(n.prototype),a.prototype.constructor=a,i(a,n);var r=e.prototype;return r.onAvailabilityChanged=function(t){this.emit(exports.AirPlayEvent.AVAILABILITY_CHANGED,{available:"available"===t.availability})},r.onTargetChanged=function(t){this.emit(exports.AirPlayEvent.TARGET_CHANGED,{wireless:!0})},r.toggleAirPlay=function(){this.video.webkitShowPlaybackTargetPicker()},r.destroy=function(){this.video.removeEventListener("webkitplaybacktargetavailabilitychanged",this.onAvailabilityChanged)},e}(n);