UNPKG

react-native-theoplayer

Version:

A THEOplayer video component for react-native.

44 lines (43 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.THEOplayerNativeAirplay = void 0; var _reactNativeTheoplayer = require("react-native-theoplayer"); var _reactNative = require("react-native"); const NativeCastModule = _reactNative.NativeModules.THEORCTCastModule; class THEOplayerNativeAirplay { _casting = false; _state = _reactNativeTheoplayer.CastState.available; constructor(player) { this._player = player; this._player.addEventListener(_reactNativeTheoplayer.PlayerEventType.CAST_EVENT, this._onCastStateChange); } async init_() { this._casting = await NativeCastModule.airplayCasting(this._player.nativeHandle); this._state = await NativeCastModule.airplayState(this._player.nativeHandle); } _onCastStateChange = event => { if (event.subType === _reactNativeTheoplayer.CastEventType.AIRPLAY_STATE_CHANGE) { this._state = event.state; this._casting = event.state === _reactNativeTheoplayer.CastState.connected; } }; get casting() { return this._casting; } get state() { return this._state; } start() { NativeCastModule.airplayStart(this._player.nativeHandle); } stop() { NativeCastModule.airplayStop(this._player.nativeHandle); } unload_() { this._player.removeEventListener(_reactNativeTheoplayer.PlayerEventType.CAST_EVENT, this._onCastStateChange); } } exports.THEOplayerNativeAirplay = THEOplayerNativeAirplay; //# sourceMappingURL=THEOplayerNativeAirplay.js.map