@eyevinn/web-player-airplay
Version:
See [@eyevinn/web-player](https://www.npmjs.com/package/@eyevinn/web-player).
2 lines (1 loc) • 1.5 kB
JavaScript
import t from"mitt";function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t})(t,e)}var e,a=function(){function i(){this.emitter=t()}var e=i.prototype;return e.on=function(t,i){this.emitter.on.apply(this,arguments)},e.off=function(t,i){this.emitter.on.apply(this,arguments)},e.emit=function(t,i){this.emitter.emit.apply(this,arguments)},e.destroy=function(){this.emitter.all.clear()},i}();!function(t){t.AVAILABILITY_CHANGED="airplay:availability_changed",t.TARGET_CHANGED="airplay:target_changed"}(e||(e={}));var n=function(t){function a(i){var a;return(a=t.call(this)||this).video=i,window.WebKitPlaybackTargetAvailabilityEvent?(i.addEventListener("webkitplaybacktargetavailabilitychanged",a.onAvailabilityChanged=a.onAvailabilityChanged.bind(a)),i.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",a.onTargetChanged=a.onTargetChanged.bind(a))):a.emit(e.AVAILABILITY_CHANGED,{available:!1}),a}var n,r;r=t,(n=a).prototype=Object.create(r.prototype),n.prototype.constructor=n,i(n,r);var o=a.prototype;return o.onAvailabilityChanged=function(t){this.emit(e.AVAILABILITY_CHANGED,{available:"available"===t.availability})},o.onTargetChanged=function(t){this.emit(e.TARGET_CHANGED,{wireless:!0})},o.toggleAirPlay=function(){this.video.webkitShowPlaybackTargetPicker()},o.destroy=function(){this.video.removeEventListener("webkitplaybacktargetavailabilitychanged",this.onAvailabilityChanged)},a}(a);export{n as AirPlay,e as AirPlayEvent};