From 2ce3b40c94c1a119098ac2bcde3fc4c3623cf068 Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 15 May 2020 17:06:31 -0700 Subject: [PATCH] [ts] Upgrade to TypeScript 3.9.2 (#8280) * [ts] Upgrade to TypeScript 3.9.2 This upgrades TypeScript to 3.9.2 to keep us more up to date. It also supports `@ts-expect-error` for places where we want to get notified if a future TS version stops triggering type checker errors. https://devblogs.microsoft.com/typescript/announcing-typescript-3-9/ It is also supposed to be faster but I don't have real numbers on this. CI might be a reasonable indicator. Also updated ts-jest, since there was a bug that required clearing the Jest cache. Updated the TS version in expo-module-scripts. Ran `expotools check-packages --no-uniformity-check ` to rebuild, test, and lint all files. * [ts] Fix up files for TS 3.9 * [ts] Rebuild JS files with TS 3.9.2 --- build/AV.d.ts | 8 +- build/Audio/Sound.js | 276 +++++++++++----------- build/Audio/Sound.js.map | 2 +- build/Video.d.ts | 3 +- build/Video.js | 486 ++++++++++++++++++++------------------- build/Video.js.map | 2 +- 6 files changed, 392 insertions(+), 385 deletions(-) diff --git a/build/AV.d.ts b/build/AV.d.ts index c6ca6f0ecef92..df900368faca6 100644 --- a/build/AV.d.ts +++ b/build/AV.d.ts @@ -97,14 +97,14 @@ export interface Playback extends AV { export declare const PlaybackMixin: { playAsync(): Promise; playFromPositionAsync(positionMillis: number, tolerances?: { - toleranceMillisBefore?: number | undefined; - toleranceMillisAfter?: number | undefined; + toleranceMillisBefore?: number; + toleranceMillisAfter?: number; }): Promise; pauseAsync(): Promise; stopAsync(): Promise; setPositionAsync(positionMillis: number, tolerances?: { - toleranceMillisBefore?: number | undefined; - toleranceMillisAfter?: number | undefined; + toleranceMillisBefore?: number; + toleranceMillisAfter?: number; }): Promise; setRateAsync(rate: number, shouldCorrectPitch?: boolean, pitchCorrectionQuality?: PitchCorrectionQuality): Promise; setVolumeAsync(volume: number): Promise; diff --git a/build/Audio/Sound.js b/build/Audio/Sound.js index 911410efe0f5e..c19fa8ae20549 100644 --- a/build/Audio/Sound.js +++ b/build/Audio/Sound.js @@ -2,154 +2,158 @@ import { EventEmitter } from '@unimodules/core'; import { PlaybackMixin, assertStatusValuesInBounds, getNativeSourceAndFullInitialStatusForLoadAsync, getUnloadedStatus, } from '../AV'; import ExponentAV from '../ExponentAV'; import { throwIfAudioIsDisabled } from './AudioAvailability'; -export class Sound { - constructor() { - this._loaded = false; - this._loading = false; - this._key = null; - this._lastStatusUpdate = null; - this._lastStatusUpdateTime = null; - this._subscriptions = []; - this._eventEmitter = new EventEmitter(ExponentAV); - this._coalesceStatusUpdatesInMillis = 100; - this._onPlaybackStatusUpdate = null; - this._internalStatusUpdateCallback = ({ key, status, }) => { - if (this._key === key) { - this._callOnPlaybackStatusUpdateForNewStatus(status); - } - }; - this._internalErrorCallback = ({ key, error }) => { - if (this._key === key) { - this._errorCallback(error); - } - }; - this._errorCallback = (error) => { - this._clearSubscriptions(); +let Sound = /** @class */ (() => { + class Sound { + constructor() { this._loaded = false; + this._loading = false; this._key = null; - this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error)); - }; - // ### Unified playback API ### (consistent with Video.js) - // All calls automatically call onPlaybackStatusUpdate as a side effect. - // Get status API - this.getStatusAsync = async () => { - if (this._loaded) { - return this._performOperationAndHandleStatusAsync(() => ExponentAV.getStatusForSound(this._key)); - } - const status = getUnloadedStatus(); - this._callOnPlaybackStatusUpdateForNewStatus(status); - return status; - }; - } - // Internal methods - _callOnPlaybackStatusUpdateForNewStatus(status) { - const shouldDismissBasedOnCoalescing = this._lastStatusUpdateTime && - JSON.stringify(status) === this._lastStatusUpdate && - Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis; - if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) { - this._onPlaybackStatusUpdate(status); - this._lastStatusUpdateTime = new Date(); - this._lastStatusUpdate = JSON.stringify(status); + this._lastStatusUpdate = null; + this._lastStatusUpdateTime = null; + this._subscriptions = []; + this._eventEmitter = new EventEmitter(ExponentAV); + this._coalesceStatusUpdatesInMillis = 100; + this._onPlaybackStatusUpdate = null; + this._internalStatusUpdateCallback = ({ key, status, }) => { + if (this._key === key) { + this._callOnPlaybackStatusUpdateForNewStatus(status); + } + }; + this._internalErrorCallback = ({ key, error }) => { + if (this._key === key) { + this._errorCallback(error); + } + }; + this._errorCallback = (error) => { + this._clearSubscriptions(); + this._loaded = false; + this._key = null; + this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error)); + }; + // ### Unified playback API ### (consistent with Video.js) + // All calls automatically call onPlaybackStatusUpdate as a side effect. + // Get status API + this.getStatusAsync = async () => { + if (this._loaded) { + return this._performOperationAndHandleStatusAsync(() => ExponentAV.getStatusForSound(this._key)); + } + const status = getUnloadedStatus(); + this._callOnPlaybackStatusUpdateForNewStatus(status); + return status; + }; } - } - async _performOperationAndHandleStatusAsync(operation) { - throwIfAudioIsDisabled(); - if (this._loaded) { - const status = await operation(); - this._callOnPlaybackStatusUpdateForNewStatus(status); - return status; + // Internal methods + _callOnPlaybackStatusUpdateForNewStatus(status) { + const shouldDismissBasedOnCoalescing = this._lastStatusUpdateTime && + JSON.stringify(status) === this._lastStatusUpdate && + Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis; + if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) { + this._onPlaybackStatusUpdate(status); + this._lastStatusUpdateTime = new Date(); + this._lastStatusUpdate = JSON.stringify(status); + } } - else { - throw new Error('Cannot complete operation because sound is not loaded.'); + async _performOperationAndHandleStatusAsync(operation) { + throwIfAudioIsDisabled(); + if (this._loaded) { + const status = await operation(); + this._callOnPlaybackStatusUpdateForNewStatus(status); + return status; + } + else { + throw new Error('Cannot complete operation because sound is not loaded.'); + } } - } - // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate). - _subscribeToNativeEvents() { - if (this._loaded) { - this._subscriptions.push(this._eventEmitter.addListener('didUpdatePlaybackStatus', this._internalStatusUpdateCallback)); - this._subscriptions.push(this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)); + // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate). + _subscribeToNativeEvents() { + if (this._loaded) { + this._subscriptions.push(this._eventEmitter.addListener('didUpdatePlaybackStatus', this._internalStatusUpdateCallback)); + this._subscriptions.push(this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)); + } } - } - _clearSubscriptions() { - this._subscriptions.forEach(e => e.remove()); - this._subscriptions = []; - } - setOnPlaybackStatusUpdate(onPlaybackStatusUpdate) { - this._onPlaybackStatusUpdate = onPlaybackStatusUpdate; - this.getStatusAsync(); - } - // Loading / unloading API - async loadAsync(source, initialStatus = {}, downloadFirst = true) { - throwIfAudioIsDisabled(); - if (this._loading) { - throw new Error('The Sound is already loading.'); + _clearSubscriptions() { + this._subscriptions.forEach(e => e.remove()); + this._subscriptions = []; } - if (!this._loaded) { - this._loading = true; - const { nativeSource, fullInitialStatus, } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst); - // This is a workaround, since using load with resolve / reject seems to not work. - return new Promise((resolve, reject) => { - const loadSuccess = (result) => { - const [key, status] = result; - this._key = key; - this._loaded = true; - this._loading = false; - this._subscribeToNativeEvents(); - this._callOnPlaybackStatusUpdateForNewStatus(status); - resolve(status); - }; - const loadError = (error) => { - this._loading = false; - reject(error); - }; - ExponentAV.loadForSound(nativeSource, fullInitialStatus) - .then(loadSuccess) - .catch(loadError); - }); + setOnPlaybackStatusUpdate(onPlaybackStatusUpdate) { + this._onPlaybackStatusUpdate = onPlaybackStatusUpdate; + this.getStatusAsync(); } - else { - throw new Error('The Sound is already loaded.'); + // Loading / unloading API + async loadAsync(source, initialStatus = {}, downloadFirst = true) { + throwIfAudioIsDisabled(); + if (this._loading) { + throw new Error('The Sound is already loading.'); + } + if (!this._loaded) { + this._loading = true; + const { nativeSource, fullInitialStatus, } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst); + // This is a workaround, since using load with resolve / reject seems to not work. + return new Promise((resolve, reject) => { + const loadSuccess = (result) => { + const [key, status] = result; + this._key = key; + this._loaded = true; + this._loading = false; + this._subscribeToNativeEvents(); + this._callOnPlaybackStatusUpdateForNewStatus(status); + resolve(status); + }; + const loadError = (error) => { + this._loading = false; + reject(error); + }; + ExponentAV.loadForSound(nativeSource, fullInitialStatus) + .then(loadSuccess) + .catch(loadError); + }); + } + else { + throw new Error('The Sound is already loaded.'); + } } - } - async unloadAsync() { - if (this._loaded) { - this._loaded = false; - const key = this._key; - this._key = null; - const status = await ExponentAV.unloadForSound(key); - this._callOnPlaybackStatusUpdateForNewStatus(status); - this._clearSubscriptions(); - return status; + async unloadAsync() { + if (this._loaded) { + this._loaded = false; + const key = this._key; + this._key = null; + const status = await ExponentAV.unloadForSound(key); + this._callOnPlaybackStatusUpdateForNewStatus(status); + this._clearSubscriptions(); + return status; + } + else { + return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate. + } } - else { - return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate. + // Set status API (only available while isLoaded = true) + async setStatusAsync(status) { + assertStatusValuesInBounds(status); + return this._performOperationAndHandleStatusAsync(() => ExponentAV.setStatusForSound(this._key, status)); } - } - // Set status API (only available while isLoaded = true) - async setStatusAsync(status) { - assertStatusValuesInBounds(status); - return this._performOperationAndHandleStatusAsync(() => ExponentAV.setStatusForSound(this._key, status)); - } - async replayAsync(status = {}) { - if (status.positionMillis && status.positionMillis !== 0) { - throw new Error('Requested position after replay has to be 0.'); + async replayAsync(status = {}) { + if (status.positionMillis && status.positionMillis !== 0) { + throw new Error('Requested position after replay has to be 0.'); + } + return this._performOperationAndHandleStatusAsync(() => ExponentAV.replaySound(this._key, { + ...status, + positionMillis: 0, + shouldPlay: true, + })); } - return this._performOperationAndHandleStatusAsync(() => ExponentAV.replaySound(this._key, { - ...status, - positionMillis: 0, - shouldPlay: true, - })); } -} -Sound.create = async (source, initialStatus = {}, onPlaybackStatusUpdate = null, downloadFirst = true) => { - console.warn(`Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`); - return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst); -}; -Sound.createAsync = async (source, initialStatus = {}, onPlaybackStatusUpdate = null, downloadFirst = true) => { - const sound = new Sound(); - sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate); - const status = await sound.loadAsync(source, initialStatus, downloadFirst); - return { sound, status }; -}; + Sound.create = async (source, initialStatus = {}, onPlaybackStatusUpdate = null, downloadFirst = true) => { + console.warn(`Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`); + return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst); + }; + Sound.createAsync = async (source, initialStatus = {}, onPlaybackStatusUpdate = null, downloadFirst = true) => { + const sound = new Sound(); + sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate); + const status = await sound.loadAsync(source, initialStatus, downloadFirst); + return { sound, status }; + }; + return Sound; +})(); +export { Sound }; Object.assign(Sound.prototype, PlaybackMixin); //# sourceMappingURL=Sound.js.map \ No newline at end of file diff --git a/build/Audio/Sound.js.map b/build/Audio/Sound.js.map index 2923966b0b3b0..16211d9d16ae3 100644 --- a/build/Audio/Sound.js.map +++ b/build/Audio/Sound.js.map @@ -1 +1 @@ -{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAEL,aAAa,EAIb,0BAA0B,EAC1B,+CAA+C,EAC/C,iBAAiB,GAClB,MAAM,OAAO,CAAC;AAEf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,MAAM,OAAO,KAAK;IAAlB;QACE,YAAO,GAAY,KAAK,CAAC;QACzB,aAAQ,GAAY,KAAK,CAAC;QAC1B,SAAI,G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AAC,GAAG,EAAE,CACrD,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YAChC,GAAG,MAAM;YACT,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;;AA3MM,YAAM,GAAG,KAAK,EACnB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;IACvD,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;IACF,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,CAAC,CAAC;AACzF,CAAC,CAAC;AAEK,iBAAW,GAAG,KAAK,EACxB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;IACvD,MAAM,KAAK,GAAU,IAAI,KAAK,EAAE,CAAC;IACjC,KAAK,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IACxD,MAAM,MAAM,GAAqB,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAC;AAgNJ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport {\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getUnloadedStatus,\n} from '../AV';\nimport { PitchCorrectionQuality } from '../Audio';\nimport ExponentAV from '../ExponentAV';\nimport { throwIfAudioIsDisabled } from './AudioAvailability';\n\ntype AudioInstance = number | HTMLMediaElement | null;\nexport class Sound implements Playback {\n _loaded: boolean = false;\n _loading: boolean = false;\n _key: AudioInstance = null;\n _lastStatusUpdate: string | null = null;\n _lastStatusUpdateTime: Date | null = null;\n _subscriptions: { remove: () => void }[] = [];\n _eventEmitter: EventEmitter = new EventEmitter(ExponentAV);\n _coalesceStatusUpdatesInMillis: number = 100;\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n static create = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n console.warn(\n `Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`\n );\n return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst);\n };\n\n static createAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n const sound: Sound = new Sound();\n sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);\n const status: AVPlaybackStatus = await sound.loadAsync(source, initialStatus, downloadFirst);\n return { sound, status };\n };\n\n // Internal methods\n\n _callOnPlaybackStatusUpdateForNewStatus(status: AVPlaybackStatus) {\n const shouldDismissBasedOnCoalescing =\n this._lastStatusUpdateTime &&\n JSON.stringify(status) === this._lastStatusUpdate &&\n Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis;\n\n if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) {\n this._onPlaybackStatusUpdate(status);\n this._lastStatusUpdateTime = new Date();\n this._lastStatusUpdate = JSON.stringify(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loaded) {\n const status = await operation();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because sound is not loaded.');\n }\n }\n\n _internalStatusUpdateCallback = ({\n key,\n status,\n }: {\n key: AudioInstance;\n status: AVPlaybackStatus;\n }) => {\n if (this._key === key) {\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n }\n };\n\n _internalErrorCallback = ({ key, error }: { key: AudioInstance; error: string }) => {\n if (this._key === key) {\n this._errorCallback(error);\n }\n };\n\n // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate).\n _subscribeToNativeEvents() {\n if (this._loaded) {\n this._subscriptions.push(\n this._eventEmitter.addListener(\n 'didUpdatePlaybackStatus',\n this._internalStatusUpdateCallback\n )\n );\n\n this._subscriptions.push(\n this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)\n );\n }\n }\n\n _clearSubscriptions() {\n this._subscriptions.forEach(e => e.remove());\n this._subscriptions = [];\n }\n\n _errorCallback = (error: string) => {\n this._clearSubscriptions();\n this._loaded = false;\n this._key = null;\n this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error));\n };\n\n // ### Unified playback API ### (consistent with Video.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n if (this._loaded) {\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.getStatusForSound(this._key)\n );\n }\n const status: AVPlaybackStatus = getUnloadedStatus();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Loading / unloading API\n\n async loadAsync(\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loading) {\n throw new Error('The Sound is already loading.');\n }\n if (!this._loaded) {\n this._loading = true;\n\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(\n source,\n initialStatus,\n downloadFirst\n );\n\n // This is a workaround, since using load with resolve / reject seems to not work.\n return new Promise((resolve, reject) => {\n const loadSuccess = (result: [AudioInstance, AVPlaybackStatus]) => {\n const [key, status] = result;\n this._key = key;\n this._loaded = true;\n this._loading = false;\n this._subscribeToNativeEvents();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n resolve(status);\n };\n\n const loadError = (error: Error) => {\n this._loading = false;\n reject(error);\n };\n\n ExponentAV.loadForSound(nativeSource, fullInitialStatus)\n .then(loadSuccess)\n .catch(loadError);\n });\n } else {\n throw new Error('The Sound is already loaded.');\n }\n }\n\n async unloadAsync(): Promise {\n if (this._loaded) {\n this._loaded = false;\n const key = this._key;\n this._key = null;\n const status = await ExponentAV.unloadForSound(key);\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n this._clearSubscriptions();\n return status;\n } else {\n return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate.\n }\n }\n\n // Set status API (only available while isLoaded = true)\n\n async setStatusAsync(status: AVPlaybackStatusToSet): Promise {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.setStatusForSound(this._key, status)\n );\n }\n\n async replayAsync(status: AVPlaybackStatusToSet = {}): Promise {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.replaySound(this._key, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (\n rate: number,\n shouldCorrectPitch: boolean,\n pitchCorrectionQuality?: PitchCorrectionQuality\n ) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n}\n\nObject.assign(Sound.prototype, PlaybackMixin);\n"]} \ No newline at end of file +{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAEL,aAAa,EAIb,0BAA0B,EAC1B,+CAA+C,EAC/C,iBAAiB,GAClB,MAAM,OAAO,CAAC;AAEf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D;IAAA,MAAa,KAAK;QAAlB;YACE,YAAO,GAAY,KAAK,CAAC;YACzB,aAAQ,GAAY,KAAK,CAAC;YAC1B,SAAI,GAAkB,IAAI,CAAC;YAC3B,sBAAiB,GAAkB,IAAI,CAAC;YACxC,0BAAqB,GAAgB,IAAI,CAAC;YAC1C,mBAAc,GAA6B,EAAE,CAAC;YAC9C,kBAAa,GAAiB,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3D,mCAA8B,GAAW,GAAG,CAAC;YAC7C,4BAAuB,GAAgD,IAAI,CAAC;YAsD5E,kCAA6B,GAAG,CAAC,EAC/B,GAAG,EACH,MAAM,GAIP,EAAE,EAAE;gBACH,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE;oBACrB,IAAI,CAAC,uCAAuC,CAAC,MAAM,CAAC,CAAC;iBACtD;YACH,CAAC,CAAC;YAEF,2BAAsB,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAyC,EAAE,EAAE;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W,GAAG,KAAK,EACxB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;QACvD,MAAM,KAAK,GAAU,IAAI,KAAK,EAAE,CAAC;QACjC,KAAK,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,MAAM,GAAqB,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;QAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC,CAAC;IA8MJ,YAAC;KAAA;SA/OY,KAAK;AAiPlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport {\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getUnloadedStatus,\n} from '../AV';\nimport { PitchCorrectionQuality } from '../Audio';\nimport ExponentAV from '../ExponentAV';\nimport { throwIfAudioIsDisabled } from './AudioAvailability';\n\ntype AudioInstance = number | HTMLMediaElement | null;\nexport class Sound implements Playback {\n _loaded: boolean = false;\n _loading: boolean = false;\n _key: AudioInstance = null;\n _lastStatusUpdate: string | null = null;\n _lastStatusUpdateTime: Date | null = null;\n _subscriptions: { remove: () => void }[] = [];\n _eventEmitter: EventEmitter = new EventEmitter(ExponentAV);\n _coalesceStatusUpdatesInMillis: number = 100;\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n static create = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n console.warn(\n `Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`\n );\n return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst);\n };\n\n static createAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n const sound: Sound = new Sound();\n sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);\n const status: AVPlaybackStatus = await sound.loadAsync(source, initialStatus, downloadFirst);\n return { sound, status };\n };\n\n // Internal methods\n\n _callOnPlaybackStatusUpdateForNewStatus(status: AVPlaybackStatus) {\n const shouldDismissBasedOnCoalescing =\n this._lastStatusUpdateTime &&\n JSON.stringify(status) === this._lastStatusUpdate &&\n Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis;\n\n if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) {\n this._onPlaybackStatusUpdate(status);\n this._lastStatusUpdateTime = new Date();\n this._lastStatusUpdate = JSON.stringify(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loaded) {\n const status = await operation();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because sound is not loaded.');\n }\n }\n\n _internalStatusUpdateCallback = ({\n key,\n status,\n }: {\n key: AudioInstance;\n status: AVPlaybackStatus;\n }) => {\n if (this._key === key) {\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n }\n };\n\n _internalErrorCallback = ({ key, error }: { key: AudioInstance; error: string }) => {\n if (this._key === key) {\n this._errorCallback(error);\n }\n };\n\n // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate).\n _subscribeToNativeEvents() {\n if (this._loaded) {\n this._subscriptions.push(\n this._eventEmitter.addListener(\n 'didUpdatePlaybackStatus',\n this._internalStatusUpdateCallback\n )\n );\n\n this._subscriptions.push(\n this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)\n );\n }\n }\n\n _clearSubscriptions() {\n this._subscriptions.forEach(e => e.remove());\n this._subscriptions = [];\n }\n\n _errorCallback = (error: string) => {\n this._clearSubscriptions();\n this._loaded = false;\n this._key = null;\n this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error));\n };\n\n // ### Unified playback API ### (consistent with Video.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n if (this._loaded) {\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.getStatusForSound(this._key)\n );\n }\n const status: AVPlaybackStatus = getUnloadedStatus();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Loading / unloading API\n\n async loadAsync(\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loading) {\n throw new Error('The Sound is already loading.');\n }\n if (!this._loaded) {\n this._loading = true;\n\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(\n source,\n initialStatus,\n downloadFirst\n );\n\n // This is a workaround, since using load with resolve / reject seems to not work.\n return new Promise((resolve, reject) => {\n const loadSuccess = (result: [AudioInstance, AVPlaybackStatus]) => {\n const [key, status] = result;\n this._key = key;\n this._loaded = true;\n this._loading = false;\n this._subscribeToNativeEvents();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n resolve(status);\n };\n\n const loadError = (error: Error) => {\n this._loading = false;\n reject(error);\n };\n\n ExponentAV.loadForSound(nativeSource, fullInitialStatus)\n .then(loadSuccess)\n .catch(loadError);\n });\n } else {\n throw new Error('The Sound is already loaded.');\n }\n }\n\n async unloadAsync(): Promise {\n if (this._loaded) {\n this._loaded = false;\n const key = this._key;\n this._key = null;\n const status = await ExponentAV.unloadForSound(key);\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n this._clearSubscriptions();\n return status;\n } else {\n return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate.\n }\n }\n\n // Set status API (only available while isLoaded = true)\n\n async setStatusAsync(status: AVPlaybackStatusToSet): Promise {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.setStatusForSound(this._key, status)\n );\n }\n\n async replayAsync(status: AVPlaybackStatusToSet = {}): Promise {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.replaySound(this._key, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (\n rate: number,\n shouldCorrectPitch: boolean,\n pitchCorrectionQuality?: PitchCorrectionQuality\n ) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n}\n\nObject.assign(Sound.prototype, PlaybackMixin);\n"]} \ No newline at end of file diff --git a/build/Video.d.ts b/build/Video.d.ts index 998eac7cc4df9..3aa6f53820ed1 100644 --- a/build/Video.d.ts +++ b/build/Video.d.ts @@ -67,7 +67,6 @@ export default class Video extends React.Component imple }>[] | undefined> | undefined; accessibilityLabel?: PropTypes.Validator | undefined; accessibilityRole?: PropTypes.Validator<"none" | "button" | "header" | "link" | "menu" | "menuitem" | "summary" | "image" | "switch" | "text" | "search" | "keyboardkey" | "adjustable" | "imagebutton" | "alert" | "checkbox" | "combobox" | "menubar" | "progressbar" | "radio" | "radiogroup" | "scrollbar" | "spinbutton" | "tab" | "tablist" | "timer" | "toolbar" | undefined> | undefined; - accessibilityStates?: PropTypes.Validator | undefined; accessibilityState?: PropTypes.Validator | undefined; accessibilityHint?: PropTypes.Validator | undefined; accessibilityValue?: PropTypes.Validator | undefined; @@ -76,7 +75,7 @@ export default class Video extends React.Component imple accessibilityLiveRegion?: PropTypes.Validator<"none" | "polite" | "assertive" | undefined> | undefined; importantForAccessibility?: PropTypes.Validator<"auto" | "yes" | "no" | "no-hide-descendants" | undefined> | undefined; accessibilityElementsHidden?: PropTypes.Validator | undefined; - accessibilityTraits?: PropTypes.Validator<"key" | "none" | "button" | "header" | "link" | "summary" | "image" | "text" | "search" | "adjustable" | "disabled" | "selected" | "plays" | "frequentUpdates" | "startsMedia" | "allowsDirectInteraction" | "pageTurn" | import("react-native").AccessibilityTrait[] | undefined> | undefined; + accessibilityTraits?: PropTypes.Validator<"key" | "none" | "button" | "header" | "link" | "summary" | "image" | "text" | "search" | "adjustable" | "selected" | "plays" | "disabled" | "frequentUpdates" | "startsMedia" | "allowsDirectInteraction" | "pageTurn" | import("react-native").AccessibilityTrait[] | undefined> | undefined; accessibilityViewIsModal?: PropTypes.Validator | undefined; onAccessibilityEscape?: PropTypes.Validator<(() => void) | undefined> | undefined; onAccessibilityTap?: PropTypes.Validator<(() => void) | undefined> | undefined; diff --git a/build/Video.js b/build/Video.js index ced35d1c37352..be63680424160 100644 --- a/build/Video.js +++ b/build/Video.js @@ -41,237 +41,247 @@ const _STYLES = StyleSheet.create({ // we have to use the provided native module mock to access constants const ExpoVideoManagerConstants = ExpoVideoManager; const ExpoVideoViewManager = ExpoVideoManager; -export default class Video extends React.Component { - // componentOrHandle: null | number | React.Component | React.ComponentClass - constructor(props) { - super(props); - this._nativeRef = React.createRef(); - this._onPlaybackStatusUpdate = null; - // Internal methods - this._handleNewStatus = (status) => { - if (this.state.showPoster && - status.isLoaded && - (status.isPlaying || status.positionMillis !== 0)) { - this.setState({ showPoster: false }); - } - if (this.props.onPlaybackStatusUpdate) { - this.props.onPlaybackStatusUpdate(status); - } - if (this._onPlaybackStatusUpdate) { - this._onPlaybackStatusUpdate(status); - } - }; - this._performOperationAndHandleStatusAsync = async (operation) => { - const video = this._nativeRef.current; - if (!video) { - throw new Error(`Cannot complete operation because the Video component has not yet loaded`); - } - const handle = findNodeHandle(this._nativeRef.current); - const status = await operation(handle); - this._handleNewStatus(status); - return status; - }; - // ### iOS Fullscreening API ### - this._setFullscreen = async (value) => { - return this._performOperationAndHandleStatusAsync((tag) => ExpoVideoViewManager.setFullscreen(tag, value)); - }; - this.presentFullscreenPlayer = async () => { - return this._setFullscreen(true); - }; - this.presentIOSFullscreenPlayer = () => { - console.warn("You're using `presentIOSFullscreenPlayer`. Please migrate your code to use `presentFullscreenPlayer` instead."); - return this.presentFullscreenPlayer(); - }; - this.presentFullscreenPlayerAsync = async () => { - return await this.presentFullscreenPlayer(); - }; - this.dismissFullscreenPlayer = async () => { - return this._setFullscreen(false); - }; - this.dismissIOSFullscreenPlayer = () => { - console.warn("You're using `dismissIOSFullscreenPlayer`. Please migrate your code to use `dismissFullscreenPlayer` instead."); - this.dismissFullscreenPlayer(); - }; - // ### Unified playback API ### (consistent with Audio.js) - // All calls automatically call onPlaybackStatusUpdate as a side effect. - // Get status API - this.getStatusAsync = async () => { - return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.getStatusForVideo(tag)); - }; - // Loading / unloading API - this.loadAsync = async (source, initialStatus = {}, downloadFirst = true) => { - const { nativeSource, fullInitialStatus, } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst); - return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.loadForVideo(tag, nativeSource, fullInitialStatus)); - }; - // Equivalent to setting URI to null. - this.unloadAsync = async () => { - return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.unloadForVideo(tag)); - }; - // Set status API (only available while isLoaded = true) - this.setStatusAsync = async (status) => { - assertStatusValuesInBounds(status); - return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.setStatusForVideo(tag, status)); - }; - this.replayAsync = async (status = {}) => { - if (status.positionMillis && status.positionMillis !== 0) { - throw new Error('Requested position after replay has to be 0.'); - } - return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.replayVideo(tag, { - ...status, - positionMillis: 0, - shouldPlay: true, - })); - }; - // ### Callback wrappers ### - this._nativeOnPlaybackStatusUpdate = (event) => { - this._handleNewStatus(event.nativeEvent); - }; - // TODO make sure we are passing the right stuff - this._nativeOnLoadStart = () => { - if (this.props.onLoadStart) { - this.props.onLoadStart(); - } - }; - this._nativeOnLoad = (event) => { - if (this.props.onLoad) { - this.props.onLoad(event.nativeEvent); - } - this._handleNewStatus(event.nativeEvent); - }; - this._nativeOnError = (event) => { - const error = event.nativeEvent.error; - if (this.props.onError) { - this.props.onError(error); - } - this._handleNewStatus(getUnloadedStatus(error)); - }; - this._nativeOnReadyForDisplay = (event) => { - if (this.props.onReadyForDisplay) { - this.props.onReadyForDisplay(event.nativeEvent); - } - }; - this._nativeOnFullscreenUpdate = (event) => { - if (this.props.onIOSFullscreenUpdate && this.props.onFullscreenUpdate) { - console.warn("You've supplied both `onIOSFullscreenUpdate` and `onFullscreenUpdate`. You're going to receive updates on both the callbacks."); - } - else if (this.props.onIOSFullscreenUpdate) { - console.warn("You're using `onIOSFullscreenUpdate`. Please migrate your code to use `onFullscreenUpdate` instead."); - } - if (this.props.onIOSFullscreenUpdate) { - this.props.onIOSFullscreenUpdate(event.nativeEvent); - } - if (this.props.onFullscreenUpdate) { - this.props.onFullscreenUpdate(event.nativeEvent); - } - }; - this._renderPoster = () => this.props.usePoster && this.state.showPoster ? ( - // @ts-ignore: the react-native type declarations are overly restrictive - ) : null; - this.state = { - showPoster: !!props.usePoster, - }; - } - setNativeProps(nativeProps) { - const nativeVideo = nullthrows(this._nativeRef.current); - nativeVideo.setNativeProps(nativeProps); - } - setOnPlaybackStatusUpdate(onPlaybackStatusUpdate) { - this._onPlaybackStatusUpdate = onPlaybackStatusUpdate; - this.getStatusAsync(); - } - render() { - const source = getNativeSourceFromSource(this.props.source) || undefined; - let nativeResizeMode = ExpoVideoManagerConstants.ScaleNone; - if (this.props.resizeMode) { - const resizeMode = this.props.resizeMode; - if (resizeMode === ResizeMode.STRETCH) { - nativeResizeMode = ExpoVideoManagerConstants.ScaleToFill; - } - else if (resizeMode === ResizeMode.CONTAIN) { - nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFit; - } - else if (resizeMode === ResizeMode.COVER) { - nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFill; - } +let Video = /** @class */ (() => { + class Video extends React.Component { + // componentOrHandle: null | number | React.Component | React.ComponentClass + constructor(props) { + super(props); + this._nativeRef = React.createRef(); + this._onPlaybackStatusUpdate = null; + // Internal methods + this._handleNewStatus = (status) => { + if (this.state.showPoster && + status.isLoaded && + (status.isPlaying || status.positionMillis !== 0)) { + this.setState({ showPoster: false }); + } + if (this.props.onPlaybackStatusUpdate) { + this.props.onPlaybackStatusUpdate(status); + } + if (this._onPlaybackStatusUpdate) { + this._onPlaybackStatusUpdate(status); + } + }; + this._performOperationAndHandleStatusAsync = async (operation) => { + const video = this._nativeRef.current; + if (!video) { + throw new Error(`Cannot complete operation because the Video component has not yet loaded`); + } + const handle = findNodeHandle(this._nativeRef.current); + const status = await operation(handle); + this._handleNewStatus(status); + return status; + }; + // ### iOS Fullscreening API ### + this._setFullscreen = async (value) => { + return this._performOperationAndHandleStatusAsync((tag) => ExpoVideoViewManager.setFullscreen(tag, value)); + }; + this.presentFullscreenPlayer = async () => { + return this._setFullscreen(true); + }; + this.presentIOSFullscreenPlayer = () => { + console.warn("You're using `presentIOSFullscreenPlayer`. Please migrate your code to use `presentFullscreenPlayer` instead."); + return this.presentFullscreenPlayer(); + }; + this.presentFullscreenPlayerAsync = async () => { + return await this.presentFullscreenPlayer(); + }; + this.dismissFullscreenPlayer = async () => { + return this._setFullscreen(false); + }; + this.dismissIOSFullscreenPlayer = () => { + console.warn("You're using `dismissIOSFullscreenPlayer`. Please migrate your code to use `dismissFullscreenPlayer` instead."); + this.dismissFullscreenPlayer(); + }; + // ### Unified playback API ### (consistent with Audio.js) + // All calls automatically call onPlaybackStatusUpdate as a side effect. + // Get status API + this.getStatusAsync = async () => { + return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.getStatusForVideo(tag)); + }; + // Loading / unloading API + this.loadAsync = async (source, initialStatus = {}, downloadFirst = true) => { + const { nativeSource, fullInitialStatus, } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst); + return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.loadForVideo(tag, nativeSource, fullInitialStatus)); + }; + // Equivalent to setting URI to null. + this.unloadAsync = async () => { + return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.unloadForVideo(tag)); + }; + // Set status API (only available while isLoaded = true) + this.setStatusAsync = async (status) => { + assertStatusValuesInBounds(status); + return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.setStatusForVideo(tag, status)); + }; + this.replayAsync = async (status = {}) => { + if (status.positionMillis && status.positionMillis !== 0) { + throw new Error('Requested position after replay has to be 0.'); + } + return this._performOperationAndHandleStatusAsync((tag) => ExponentAV.replayVideo(tag, { + ...status, + positionMillis: 0, + shouldPlay: true, + })); + }; + // ### Callback wrappers ### + this._nativeOnPlaybackStatusUpdate = (event) => { + this._handleNewStatus(event.nativeEvent); + }; + // TODO make sure we are passing the right stuff + this._nativeOnLoadStart = () => { + if (this.props.onLoadStart) { + this.props.onLoadStart(); + } + }; + this._nativeOnLoad = (event) => { + if (this.props.onLoad) { + this.props.onLoad(event.nativeEvent); + } + this._handleNewStatus(event.nativeEvent); + }; + this._nativeOnError = (event) => { + const error = event.nativeEvent.error; + if (this.props.onError) { + this.props.onError(error); + } + this._handleNewStatus(getUnloadedStatus(error)); + }; + this._nativeOnReadyForDisplay = (event) => { + if (this.props.onReadyForDisplay) { + this.props.onReadyForDisplay(event.nativeEvent); + } + }; + this._nativeOnFullscreenUpdate = (event) => { + if (this.props.onIOSFullscreenUpdate && this.props.onFullscreenUpdate) { + console.warn("You've supplied both `onIOSFullscreenUpdate` and `onFullscreenUpdate`. You're going to receive updates on both the callbacks."); + } + else if (this.props.onIOSFullscreenUpdate) { + console.warn("You're using `onIOSFullscreenUpdate`. Please migrate your code to use `onFullscreenUpdate` instead."); + } + if (this.props.onIOSFullscreenUpdate) { + this.props.onIOSFullscreenUpdate(event.nativeEvent); + } + if (this.props.onFullscreenUpdate) { + this.props.onFullscreenUpdate(event.nativeEvent); + } + }; + this._renderPoster = () => this.props.usePoster && this.state.showPoster ? ( + // @ts-ignore: the react-native type declarations are overly restrictive + ) : null; + this.state = { + showPoster: !!props.usePoster, + }; + } + setNativeProps(nativeProps) { + const nativeVideo = nullthrows(this._nativeRef.current); + nativeVideo.setNativeProps(nativeProps); + } + setOnPlaybackStatusUpdate(onPlaybackStatusUpdate) { + this._onPlaybackStatusUpdate = onPlaybackStatusUpdate; + this.getStatusAsync(); } - // Set status via individual props - const status = { ...this.props.status }; - [ - 'progressUpdateIntervalMillis', - 'positionMillis', - 'shouldPlay', - 'rate', - 'shouldCorrectPitch', - 'volume', - 'isMuted', - 'isLooping', - ].forEach(prop => { - if (prop in this.props) { - status[prop] = this.props[prop]; + render() { + const source = getNativeSourceFromSource(this.props.source) || undefined; + let nativeResizeMode = ExpoVideoManagerConstants.ScaleNone; + if (this.props.resizeMode) { + const resizeMode = this.props.resizeMode; + if (resizeMode === ResizeMode.STRETCH) { + nativeResizeMode = ExpoVideoManagerConstants.ScaleToFill; + } + else if (resizeMode === ResizeMode.CONTAIN) { + nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFit; + } + else if (resizeMode === ResizeMode.COVER) { + nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFill; + } } - }); - // Replace selected native props - // @ts-ignore: TypeScript thinks "children" is not in the list of props - const nativeProps = { - ...omit(this.props, 'source', 'onPlaybackStatusUpdate', 'usePoster', 'posterSource', ...Object.keys(status)), - style: StyleSheet.flatten([_STYLES.base, this.props.style]), - source, - resizeMode: nativeResizeMode, - status, - onStatusUpdate: this._nativeOnPlaybackStatusUpdate, - onLoadStart: this._nativeOnLoadStart, - onLoad: this._nativeOnLoad, - onError: this._nativeOnError, - onReadyForDisplay: this._nativeOnReadyForDisplay, - onFullscreenUpdate: this._nativeOnFullscreenUpdate, - }; - return ( + // Set status via individual props + const status = { ...this.props.status }; + [ + 'progressUpdateIntervalMillis', + 'positionMillis', + 'shouldPlay', + 'rate', + 'shouldCorrectPitch', + 'volume', + 'isMuted', + 'isLooping', + ].forEach(prop => { + if (prop in this.props) { + status[prop] = this.props[prop]; + } + }); + // Replace selected native props + // @ts-ignore: TypeScript thinks "children" is not in the list of props + const nativeProps = { + ...omit(this.props, 'source', 'onPlaybackStatusUpdate', 'usePoster', 'posterSource', ...Object.keys(status)), + style: StyleSheet.flatten([_STYLES.base, this.props.style]), + source, + resizeMode: nativeResizeMode, + status, + onStatusUpdate: this._nativeOnPlaybackStatusUpdate, + onLoadStart: this._nativeOnLoadStart, + onLoad: this._nativeOnLoad, + onError: this._nativeOnError, + onReadyForDisplay: this._nativeOnReadyForDisplay, + onFullscreenUpdate: this._nativeOnFullscreenUpdate, + }; + return ( {this._renderPoster()} ); + } } -} -Video.RESIZE_MODE_CONTAIN = ResizeMode.CONTAIN; -Video.RESIZE_MODE_COVER = ResizeMode.COVER; -Video.RESIZE_MODE_STRETCH = ResizeMode.STRETCH; -Video.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; -Video.IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; -Video.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; -Video.IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; -Video.FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; -Video.FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; -Video.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; -Video.FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; -Video.propTypes = { - // Source stuff - source: PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - overrideFileExtensionAndroid: PropTypes.string, - }), - PropTypes.number, - ]), - posterSource: PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, + Video.RESIZE_MODE_CONTAIN = ResizeMode.CONTAIN; + Video.RESIZE_MODE_COVER = ResizeMode.COVER; + Video.RESIZE_MODE_STRETCH = ResizeMode.STRETCH; + Video.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; + Video.IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; + Video.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; + Video.IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; + Video.FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; + Video.FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; + Video.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; + Video.FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; + Video.propTypes = { + // Source stuff + source: PropTypes.oneOfType([ + PropTypes.shape({ + uri: PropTypes.string, + overrideFileExtensionAndroid: PropTypes.string, + }), + PropTypes.number, + ]), + posterSource: PropTypes.oneOfType([ + PropTypes.shape({ + uri: PropTypes.string, + }), + PropTypes.number, + ]), + posterStyle: ViewPropTypes.style, + // Callbacks + onPlaybackStatusUpdate: PropTypes.func, + onLoadStart: PropTypes.func, + onLoad: PropTypes.func, + onError: PropTypes.func, + onIOSFullscreenUpdate: PropTypes.func, + onFullscreenUpdate: PropTypes.func, + onReadyForDisplay: PropTypes.func, + // UI stuff + useNativeControls: PropTypes.bool, + resizeMode: PropTypes.string, + usePoster: PropTypes.bool, + // Playback API + status: PropTypes.shape({ + progressUpdateIntervalMillis: PropTypes.number, + positionMillis: PropTypes.number, + shouldPlay: PropTypes.bool, + rate: PropTypes.number, + shouldCorrectPitch: PropTypes.bool, + volume: PropTypes.number, + isMuted: PropTypes.bool, + isLooping: PropTypes.bool, }), - PropTypes.number, - ]), - posterStyle: ViewPropTypes.style, - // Callbacks - onPlaybackStatusUpdate: PropTypes.func, - onLoadStart: PropTypes.func, - onLoad: PropTypes.func, - onError: PropTypes.func, - onIOSFullscreenUpdate: PropTypes.func, - onFullscreenUpdate: PropTypes.func, - onReadyForDisplay: PropTypes.func, - // UI stuff - useNativeControls: PropTypes.bool, - resizeMode: PropTypes.string, - usePoster: PropTypes.bool, - // Playback API - status: PropTypes.shape({ progressUpdateIntervalMillis: PropTypes.number, positionMillis: PropTypes.number, shouldPlay: PropTypes.bool, @@ -280,22 +290,16 @@ Video.propTypes = { volume: PropTypes.number, isMuted: PropTypes.bool, isLooping: PropTypes.bool, - }), - progressUpdateIntervalMillis: PropTypes.number, - positionMillis: PropTypes.number, - shouldPlay: PropTypes.bool, - rate: PropTypes.number, - shouldCorrectPitch: PropTypes.bool, - volume: PropTypes.number, - isMuted: PropTypes.bool, - isLooping: PropTypes.bool, - // Required by react-native - scaleX: PropTypes.number, - scaleY: PropTypes.number, - translateX: PropTypes.number, - translateY: PropTypes.number, - rotation: PropTypes.number, - ...ViewPropTypes, -}; + // Required by react-native + scaleX: PropTypes.number, + scaleY: PropTypes.number, + translateX: PropTypes.number, + translateY: PropTypes.number, + rotation: PropTypes.number, + ...ViewPropTypes, + }; + return Video; +})(); +export default Video; Object.assign(Video.prototype, PlaybackMixin); //# sourceMappingURL=Video.js.map \ No newline at end of file diff --git a/build/Video.js.map b/build/Video.js.map index 3ac6ff981e9eb..6c0a47998204f 100644 --- a/build/Video.js.map +++ b/build/Video.js.map @@ -1 +1 @@ -{"version":3,"file":"Video.js","sourceRoot":"","sources":["../src/Video.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,KAAK,EAEL,UAAU,EACV,IAAI,EACJ,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,+CAA+C,EAC/C,yBAAyB,EACzB,iBAAiB,EAEjB,aAAa,GAKd,MAAM,MAAM,CAAC;AACd,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAOL,UAAU,GAEX,MAAM,eAAe,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,iBAAiB,EAAE,SAAS,CAAC,IAAI;IAEjC,WAAW;IACX,iBAAiB,EAAE,SAAS,CAAC,IAAI;IACjC,UAAU,EAAE,SAAS,CAAC,MAAM;IAC5B,SAAS,EAAE,SAAS,CAAC,IAAI;IAEzB,eAAe;IACf,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC;QACtB,4BAA4B,EAAE,SAAS,CAAC,MAAM;QAC9C,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,UAAU,EAAE,SAAS,CAAC,IAAI;QAC1B,IAAI,EAAE,SAAS,CAAC,MAAM;QACtB,kBAAkB,EAAE,SAAS,CAAC,IAAI;QAClC,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,OAAO,EAAE,SAAS,CAAC,IAAI;QACvB,SAAS,EAAE,SAAS,CAAC,IAAI;KAC1B,CAAC;IACF,4BAA4B,EAAE,SAAS,CAAC,MAAM;IAC9C,cAAc,EAAE,SAAS,CAAC,MAAM;IAChC,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,IAAI,EAAE,SAAS,CAAC,MAAM;IACtB,kBAAkB,EAAE,SAAS,CAAC,IAAI;IAClC,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,SAAS,EAAE,SAAS,CAAC,IAAI;IAEzB,2BAA2B;IAC3B,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,UAAU,EAAE,SAAS,CAAC,MAAM;IAC5B,UAAU,EAAE,SAAS,CAAC,MAAM;IAC5B,QAAQ,EAAE,SAAS,CAAC,MAAM;IAC1B,GAAG,aAAa;CACjB,CAAC;AAoSJ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import omit from 'lodash/omit';\nimport nullthrows from 'nullthrows';\nimport PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n findNodeHandle,\n Image,\n NativeMethods,\n StyleSheet,\n View,\n ViewPropTypes,\n} from 'react-native';\n\nimport {\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getNativeSourceFromSource,\n getUnloadedStatus,\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n AVPlaybackNativeSource,\n} from './AV';\nimport ExpoVideoManager from './ExpoVideoManager';\nimport ExponentAV from './ExponentAV';\nimport ExponentVideo from './ExponentVideo';\nimport {\n ExponentVideoComponent,\n VideoFullscreenUpdateEvent,\n VideoNativeProps,\n VideoNaturalSize,\n VideoProps,\n VideoReadyForDisplayEvent,\n ResizeMode,\n VideoState,\n} from './Video.types';\n\nexport {\n ExponentVideoComponent,\n VideoFullscreenUpdateEvent,\n VideoNativeProps,\n VideoNaturalSize,\n VideoProps,\n VideoReadyForDisplayEvent,\n ResizeMode,\n VideoState,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n AVPlaybackNativeSource,\n};\n\nexport const FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = 0;\nexport const FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = 1;\nexport const FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = 2;\nexport const FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = 3;\n\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\nconst _STYLES = StyleSheet.create({\n base: {\n overflow: 'hidden',\n },\n poster: {\n position: 'absolute',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n resizeMode: 'contain',\n },\n video: {\n position: 'absolute',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n },\n});\n\n// On a real device UIManager should be present, however when running offline tests with jest-expo\n// we have to use the provided native module mock to access constants\nconst ExpoVideoManagerConstants = ExpoVideoManager;\nconst ExpoVideoViewManager = ExpoVideoManager;\n\nexport default class Video extends React.Component implements Playback {\n static RESIZE_MODE_CONTAIN = ResizeMode.CONTAIN;\n static RESIZE_MODE_COVER = ResizeMode.COVER;\n static RESIZE_MODE_STRETCH = ResizeMode.STRETCH;\n\n static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\n static IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\n static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\n static IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\n static FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\n static FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\n static FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\n static FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\n static propTypes = {\n // Source stuff\n source: PropTypes.oneOfType([\n PropTypes.shape({\n uri: PropTypes.string,\n overrideFileExtensionAndroid: PropTypes.string,\n }), // remote URI like { uri: 'http://foo/bar.mp4' }\n PropTypes.number, // asset module like require('./foo/bar.mp4')\n ]),\n posterSource: PropTypes.oneOfType([\n PropTypes.shape({\n uri: PropTypes.string,\n }), // remote URI like { uri: 'http://foo/bar.mp4' }\n PropTypes.number, // asset module like require('./foo/bar.mp4')\n ]),\n posterStyle: ViewPropTypes.style,\n\n // Callbacks\n onPlaybackStatusUpdate: PropTypes.func,\n onLoadStart: PropTypes.func,\n onLoad: PropTypes.func,\n onError: PropTypes.func,\n onIOSFullscreenUpdate: PropTypes.func,\n onFullscreenUpdate: PropTypes.func,\n onReadyForDisplay: PropTypes.func,\n\n // UI stuff\n useNativeControls: PropTypes.bool,\n resizeMode: PropTypes.string,\n usePoster: PropTypes.bool,\n\n // Playback API\n status: PropTypes.shape({\n progressUpdateIntervalMillis: PropTypes.number,\n positionMillis: PropTypes.number,\n shouldPlay: PropTypes.bool,\n rate: PropTypes.number,\n shouldCorrectPitch: PropTypes.bool,\n volume: PropTypes.number,\n isMuted: PropTypes.bool,\n isLooping: PropTypes.bool,\n }),\n progressUpdateIntervalMillis: PropTypes.number,\n positionMillis: PropTypes.number,\n shouldPlay: PropTypes.bool,\n rate: PropTypes.number,\n shouldCorrectPitch: PropTypes.bool,\n volume: PropTypes.number,\n isMuted: PropTypes.bool,\n isLooping: PropTypes.bool,\n\n // Required by react-native\n scaleX: PropTypes.number,\n scaleY: PropTypes.number,\n translateX: PropTypes.number,\n translateY: PropTypes.number,\n rotation: PropTypes.number,\n ...ViewPropTypes,\n };\n\n _nativeRef = React.createRef & NativeMethods>();\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n // componentOrHandle: null | number | React.Component | React.ComponentClass\n\n constructor(props: VideoProps) {\n super(props);\n this.state = {\n showPoster: !!props.usePoster,\n };\n }\n\n setNativeProps(nativeProps: VideoNativeProps) {\n const nativeVideo = nullthrows(this._nativeRef.current);\n nativeVideo.setNativeProps(nativeProps);\n }\n\n // Internal methods\n\n _handleNewStatus = (status: AVPlaybackStatus) => {\n if (\n this.state.showPoster &&\n status.isLoaded &&\n (status.isPlaying || status.positionMillis !== 0)\n ) {\n this.setState({ showPoster: false });\n }\n\n if (this.props.onPlaybackStatusUpdate) {\n this.props.onPlaybackStatusUpdate(status);\n }\n if (this._onPlaybackStatusUpdate) {\n this._onPlaybackStatusUpdate(status);\n }\n };\n\n _performOperationAndHandleStatusAsync = async (\n operation: (tag: number) => Promise\n ): Promise => {\n const video = this._nativeRef.current;\n if (!video) {\n throw new Error(`Cannot complete operation because the Video component has not yet loaded`);\n }\n\n const handle = findNodeHandle(this._nativeRef.current)!;\n const status: AVPlaybackStatus = await operation(handle);\n this._handleNewStatus(status);\n return status;\n };\n\n // ### iOS Fullscreening API ###\n\n _setFullscreen = async (value: boolean) => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExpoVideoViewManager.setFullscreen(tag, value)\n );\n };\n\n presentFullscreenPlayer = async () => {\n return this._setFullscreen(true);\n };\n\n presentIOSFullscreenPlayer = () => {\n console.warn(\n \"You're using `presentIOSFullscreenPlayer`. Please migrate your code to use `presentFullscreenPlayer` instead.\"\n );\n return this.presentFullscreenPlayer();\n };\n\n presentFullscreenPlayerAsync = async () => {\n return await this.presentFullscreenPlayer();\n };\n\n dismissFullscreenPlayer = async () => {\n return this._setFullscreen(false);\n };\n\n dismissIOSFullscreenPlayer = () => {\n console.warn(\n \"You're using `dismissIOSFullscreenPlayer`. Please migrate your code to use `dismissFullscreenPlayer` instead.\"\n );\n this.dismissFullscreenPlayer();\n };\n\n // ### Unified playback API ### (consistent with Audio.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.getStatusForVideo(tag)\n );\n };\n\n // Loading / unloading API\n\n loadAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise => {\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst);\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.loadForVideo(tag, nativeSource, fullInitialStatus)\n );\n };\n\n // Equivalent to setting URI to null.\n unloadAsync = async (): Promise => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.unloadForVideo(tag)\n );\n };\n\n // Set status API (only available while isLoaded = true)\n\n setStatusAsync = async (status: AVPlaybackStatusToSet): Promise => {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.setStatusForVideo(tag, status)\n );\n };\n\n replayAsync = async (status: AVPlaybackStatusToSet = {}): Promise => {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.replayVideo(tag, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (rate: number, shouldCorrectPitch: boolean) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n\n // ### Callback wrappers ###\n\n _nativeOnPlaybackStatusUpdate = (event: { nativeEvent: AVPlaybackStatus }) => {\n this._handleNewStatus(event.nativeEvent);\n };\n\n // TODO make sure we are passing the right stuff\n _nativeOnLoadStart = () => {\n if (this.props.onLoadStart) {\n this.props.onLoadStart();\n }\n };\n\n _nativeOnLoad = (event: { nativeEvent: AVPlaybackStatus }) => {\n if (this.props.onLoad) {\n this.props.onLoad(event.nativeEvent);\n }\n this._handleNewStatus(event.nativeEvent);\n };\n\n _nativeOnError = (event: { nativeEvent: { error: string } }) => {\n const error: string = event.nativeEvent.error;\n if (this.props.onError) {\n this.props.onError(error);\n }\n this._handleNewStatus(getUnloadedStatus(error));\n };\n\n _nativeOnReadyForDisplay = (event: { nativeEvent: VideoReadyForDisplayEvent }) => {\n if (this.props.onReadyForDisplay) {\n this.props.onReadyForDisplay(event.nativeEvent);\n }\n };\n\n _nativeOnFullscreenUpdate = (event: { nativeEvent: VideoFullscreenUpdateEvent }) => {\n if (this.props.onIOSFullscreenUpdate && this.props.onFullscreenUpdate) {\n console.warn(\n \"You've supplied both `onIOSFullscreenUpdate` and `onFullscreenUpdate`. You're going to receive updates on both the callbacks.\"\n );\n } else if (this.props.onIOSFullscreenUpdate) {\n console.warn(\n \"You're using `onIOSFullscreenUpdate`. Please migrate your code to use `onFullscreenUpdate` instead.\"\n );\n }\n\n if (this.props.onIOSFullscreenUpdate) {\n this.props.onIOSFullscreenUpdate(event.nativeEvent);\n }\n\n if (this.props.onFullscreenUpdate) {\n this.props.onFullscreenUpdate(event.nativeEvent);\n }\n };\n\n _renderPoster = () =>\n this.props.usePoster && this.state.showPoster ? (\n // @ts-ignore: the react-native type declarations are overly restrictive\n \n ) : null;\n\n render() {\n const source = getNativeSourceFromSource(this.props.source) || undefined;\n\n let nativeResizeMode = ExpoVideoManagerConstants.ScaleNone;\n if (this.props.resizeMode) {\n const resizeMode = this.props.resizeMode;\n if (resizeMode === ResizeMode.STRETCH) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleToFill;\n } else if (resizeMode === ResizeMode.CONTAIN) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFit;\n } else if (resizeMode === ResizeMode.COVER) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFill;\n }\n }\n\n // Set status via individual props\n const status: AVPlaybackStatusToSet = { ...this.props.status };\n [\n 'progressUpdateIntervalMillis',\n 'positionMillis',\n 'shouldPlay',\n 'rate',\n 'shouldCorrectPitch',\n 'volume',\n 'isMuted',\n 'isLooping',\n ].forEach(prop => {\n if (prop in this.props) {\n status[prop] = this.props[prop];\n }\n });\n\n // Replace selected native props\n // @ts-ignore: TypeScript thinks \"children\" is not in the list of props\n const nativeProps: VideoNativeProps = {\n ...omit(\n this.props,\n 'source',\n 'onPlaybackStatusUpdate',\n 'usePoster',\n 'posterSource',\n ...Object.keys(status)\n ),\n style: StyleSheet.flatten([_STYLES.base, this.props.style]),\n source,\n resizeMode: nativeResizeMode,\n status,\n onStatusUpdate: this._nativeOnPlaybackStatusUpdate,\n onLoadStart: this._nativeOnLoadStart,\n onLoad: this._nativeOnLoad,\n onError: this._nativeOnError,\n onReadyForDisplay: this._nativeOnReadyForDisplay,\n onFullscreenUpdate: this._nativeOnFullscreenUpdate,\n };\n\n return (\n \n \n {this._renderPoster()}\n \n );\n }\n}\n\nObject.assign(Video.prototype, PlaybackMixin);\n"]} \ No newline at end of file +{"version":3,"file":"Video.js","sourceRoot":"","sources":["../src/Video.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,KAAK,EAEL,UAAU,EACV,IAAI,EACJ,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,+CAA+C,EAC/C,yBAAyB,EACzB,iBAAiB,EAEjB,aAAa,GAKd,MAAM,MAAM,CAAC;AACd,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MA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AkSJ,YAAC;KAAA;eA3WoB,KAAK;AA6W1B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import omit from 'lodash/omit';\nimport nullthrows from 'nullthrows';\nimport PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n findNodeHandle,\n Image,\n NativeMethods,\n StyleSheet,\n View,\n ViewPropTypes,\n} from 'react-native';\n\nimport {\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getNativeSourceFromSource,\n getUnloadedStatus,\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n AVPlaybackNativeSource,\n} from './AV';\nimport ExpoVideoManager from './ExpoVideoManager';\nimport ExponentAV from './ExponentAV';\nimport ExponentVideo from './ExponentVideo';\nimport {\n ExponentVideoComponent,\n VideoFullscreenUpdateEvent,\n VideoNativeProps,\n VideoNaturalSize,\n VideoProps,\n VideoReadyForDisplayEvent,\n ResizeMode,\n VideoState,\n} from './Video.types';\n\nexport {\n ExponentVideoComponent,\n VideoFullscreenUpdateEvent,\n VideoNativeProps,\n VideoNaturalSize,\n VideoProps,\n VideoReadyForDisplayEvent,\n ResizeMode,\n VideoState,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n AVPlaybackNativeSource,\n};\n\nexport const FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = 0;\nexport const FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = 1;\nexport const FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = 2;\nexport const FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = 3;\n\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\nexport const IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\nconst _STYLES = StyleSheet.create({\n base: {\n overflow: 'hidden',\n },\n poster: {\n position: 'absolute',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n resizeMode: 'contain',\n },\n video: {\n position: 'absolute',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n },\n});\n\n// On a real device UIManager should be present, however when running offline tests with jest-expo\n// we have to use the provided native module mock to access constants\nconst ExpoVideoManagerConstants = ExpoVideoManager;\nconst ExpoVideoViewManager = ExpoVideoManager;\n\nexport default class Video extends React.Component implements Playback {\n static RESIZE_MODE_CONTAIN = ResizeMode.CONTAIN;\n static RESIZE_MODE_COVER = ResizeMode.COVER;\n static RESIZE_MODE_STRETCH = ResizeMode.STRETCH;\n\n static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\n static IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\n static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\n static IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\n static FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT;\n static FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = FULLSCREEN_UPDATE_PLAYER_DID_PRESENT;\n static FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS;\n static FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = FULLSCREEN_UPDATE_PLAYER_DID_DISMISS;\n\n static propTypes = {\n // Source stuff\n source: PropTypes.oneOfType([\n PropTypes.shape({\n uri: PropTypes.string,\n overrideFileExtensionAndroid: PropTypes.string,\n }), // remote URI like { uri: 'http://foo/bar.mp4' }\n PropTypes.number, // asset module like require('./foo/bar.mp4')\n ]),\n posterSource: PropTypes.oneOfType([\n PropTypes.shape({\n uri: PropTypes.string,\n }), // remote URI like { uri: 'http://foo/bar.mp4' }\n PropTypes.number, // asset module like require('./foo/bar.mp4')\n ]),\n posterStyle: ViewPropTypes.style,\n\n // Callbacks\n onPlaybackStatusUpdate: PropTypes.func,\n onLoadStart: PropTypes.func,\n onLoad: PropTypes.func,\n onError: PropTypes.func,\n onIOSFullscreenUpdate: PropTypes.func,\n onFullscreenUpdate: PropTypes.func,\n onReadyForDisplay: PropTypes.func,\n\n // UI stuff\n useNativeControls: PropTypes.bool,\n resizeMode: PropTypes.string,\n usePoster: PropTypes.bool,\n\n // Playback API\n status: PropTypes.shape({\n progressUpdateIntervalMillis: PropTypes.number,\n positionMillis: PropTypes.number,\n shouldPlay: PropTypes.bool,\n rate: PropTypes.number,\n shouldCorrectPitch: PropTypes.bool,\n volume: PropTypes.number,\n isMuted: PropTypes.bool,\n isLooping: PropTypes.bool,\n }),\n progressUpdateIntervalMillis: PropTypes.number,\n positionMillis: PropTypes.number,\n shouldPlay: PropTypes.bool,\n rate: PropTypes.number,\n shouldCorrectPitch: PropTypes.bool,\n volume: PropTypes.number,\n isMuted: PropTypes.bool,\n isLooping: PropTypes.bool,\n\n // Required by react-native\n scaleX: PropTypes.number,\n scaleY: PropTypes.number,\n translateX: PropTypes.number,\n translateY: PropTypes.number,\n rotation: PropTypes.number,\n ...ViewPropTypes,\n };\n\n _nativeRef = React.createRef & NativeMethods>();\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n // componentOrHandle: null | number | React.Component | React.ComponentClass\n\n constructor(props: VideoProps) {\n super(props);\n this.state = {\n showPoster: !!props.usePoster,\n };\n }\n\n setNativeProps(nativeProps: VideoNativeProps) {\n const nativeVideo = nullthrows(this._nativeRef.current);\n nativeVideo.setNativeProps(nativeProps);\n }\n\n // Internal methods\n\n _handleNewStatus = (status: AVPlaybackStatus) => {\n if (\n this.state.showPoster &&\n status.isLoaded &&\n (status.isPlaying || status.positionMillis !== 0)\n ) {\n this.setState({ showPoster: false });\n }\n\n if (this.props.onPlaybackStatusUpdate) {\n this.props.onPlaybackStatusUpdate(status);\n }\n if (this._onPlaybackStatusUpdate) {\n this._onPlaybackStatusUpdate(status);\n }\n };\n\n _performOperationAndHandleStatusAsync = async (\n operation: (tag: number) => Promise\n ): Promise => {\n const video = this._nativeRef.current;\n if (!video) {\n throw new Error(`Cannot complete operation because the Video component has not yet loaded`);\n }\n\n const handle = findNodeHandle(this._nativeRef.current)!;\n const status: AVPlaybackStatus = await operation(handle);\n this._handleNewStatus(status);\n return status;\n };\n\n // ### iOS Fullscreening API ###\n\n _setFullscreen = async (value: boolean) => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExpoVideoViewManager.setFullscreen(tag, value)\n );\n };\n\n presentFullscreenPlayer = async () => {\n return this._setFullscreen(true);\n };\n\n presentIOSFullscreenPlayer = () => {\n console.warn(\n \"You're using `presentIOSFullscreenPlayer`. Please migrate your code to use `presentFullscreenPlayer` instead.\"\n );\n return this.presentFullscreenPlayer();\n };\n\n presentFullscreenPlayerAsync = async () => {\n return await this.presentFullscreenPlayer();\n };\n\n dismissFullscreenPlayer = async () => {\n return this._setFullscreen(false);\n };\n\n dismissIOSFullscreenPlayer = () => {\n console.warn(\n \"You're using `dismissIOSFullscreenPlayer`. Please migrate your code to use `dismissFullscreenPlayer` instead.\"\n );\n this.dismissFullscreenPlayer();\n };\n\n // ### Unified playback API ### (consistent with Audio.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.getStatusForVideo(tag)\n );\n };\n\n // Loading / unloading API\n\n loadAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise => {\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(source, initialStatus, downloadFirst);\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.loadForVideo(tag, nativeSource, fullInitialStatus)\n );\n };\n\n // Equivalent to setting URI to null.\n unloadAsync = async (): Promise => {\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.unloadForVideo(tag)\n );\n };\n\n // Set status API (only available while isLoaded = true)\n\n setStatusAsync = async (status: AVPlaybackStatusToSet): Promise => {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.setStatusForVideo(tag, status)\n );\n };\n\n replayAsync = async (status: AVPlaybackStatusToSet = {}): Promise => {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync((tag: number) =>\n ExponentAV.replayVideo(tag, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (rate: number, shouldCorrectPitch: boolean) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n\n // ### Callback wrappers ###\n\n _nativeOnPlaybackStatusUpdate = (event: { nativeEvent: AVPlaybackStatus }) => {\n this._handleNewStatus(event.nativeEvent);\n };\n\n // TODO make sure we are passing the right stuff\n _nativeOnLoadStart = () => {\n if (this.props.onLoadStart) {\n this.props.onLoadStart();\n }\n };\n\n _nativeOnLoad = (event: { nativeEvent: AVPlaybackStatus }) => {\n if (this.props.onLoad) {\n this.props.onLoad(event.nativeEvent);\n }\n this._handleNewStatus(event.nativeEvent);\n };\n\n _nativeOnError = (event: { nativeEvent: { error: string } }) => {\n const error: string = event.nativeEvent.error;\n if (this.props.onError) {\n this.props.onError(error);\n }\n this._handleNewStatus(getUnloadedStatus(error));\n };\n\n _nativeOnReadyForDisplay = (event: { nativeEvent: VideoReadyForDisplayEvent }) => {\n if (this.props.onReadyForDisplay) {\n this.props.onReadyForDisplay(event.nativeEvent);\n }\n };\n\n _nativeOnFullscreenUpdate = (event: { nativeEvent: VideoFullscreenUpdateEvent }) => {\n if (this.props.onIOSFullscreenUpdate && this.props.onFullscreenUpdate) {\n console.warn(\n \"You've supplied both `onIOSFullscreenUpdate` and `onFullscreenUpdate`. You're going to receive updates on both the callbacks.\"\n );\n } else if (this.props.onIOSFullscreenUpdate) {\n console.warn(\n \"You're using `onIOSFullscreenUpdate`. Please migrate your code to use `onFullscreenUpdate` instead.\"\n );\n }\n\n if (this.props.onIOSFullscreenUpdate) {\n this.props.onIOSFullscreenUpdate(event.nativeEvent);\n }\n\n if (this.props.onFullscreenUpdate) {\n this.props.onFullscreenUpdate(event.nativeEvent);\n }\n };\n\n _renderPoster = () =>\n this.props.usePoster && this.state.showPoster ? (\n // @ts-ignore: the react-native type declarations are overly restrictive\n \n ) : null;\n\n render() {\n const source = getNativeSourceFromSource(this.props.source) || undefined;\n\n let nativeResizeMode = ExpoVideoManagerConstants.ScaleNone;\n if (this.props.resizeMode) {\n const resizeMode = this.props.resizeMode;\n if (resizeMode === ResizeMode.STRETCH) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleToFill;\n } else if (resizeMode === ResizeMode.CONTAIN) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFit;\n } else if (resizeMode === ResizeMode.COVER) {\n nativeResizeMode = ExpoVideoManagerConstants.ScaleAspectFill;\n }\n }\n\n // Set status via individual props\n const status: AVPlaybackStatusToSet = { ...this.props.status };\n [\n 'progressUpdateIntervalMillis',\n 'positionMillis',\n 'shouldPlay',\n 'rate',\n 'shouldCorrectPitch',\n 'volume',\n 'isMuted',\n 'isLooping',\n ].forEach(prop => {\n if (prop in this.props) {\n status[prop] = this.props[prop];\n }\n });\n\n // Replace selected native props\n // @ts-ignore: TypeScript thinks \"children\" is not in the list of props\n const nativeProps: VideoNativeProps = {\n ...omit(\n this.props,\n 'source',\n 'onPlaybackStatusUpdate',\n 'usePoster',\n 'posterSource',\n ...Object.keys(status)\n ),\n style: StyleSheet.flatten([_STYLES.base, this.props.style]),\n source,\n resizeMode: nativeResizeMode,\n status,\n onStatusUpdate: this._nativeOnPlaybackStatusUpdate,\n onLoadStart: this._nativeOnLoadStart,\n onLoad: this._nativeOnLoad,\n onError: this._nativeOnError,\n onReadyForDisplay: this._nativeOnReadyForDisplay,\n onFullscreenUpdate: this._nativeOnFullscreenUpdate,\n };\n\n return (\n \n \n {this._renderPoster()}\n \n );\n }\n}\n\nObject.assign(Video.prototype, PlaybackMixin);\n"]} \ No newline at end of file