@draftbit/core 50.5.4 → 50.5.5-7faebf.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +1 -1
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +6 -1
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +6 -1
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +1 -1
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx +10 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx";import*as React from"react";import{Audio,InterruptionModeIOS,InterruptionModeAndroid}from"expo-av";import{mapToMediaPlayerStatus,normalizeBase64Source,useSourceDeepCompareEffect}from"../MediaPlayerCommon";import MediaPlaybackWrapper from"../MediaPlaybackWrapper";import{jsx as _jsx}from"react/jsx-runtime";var HeadlessAudioPlayer=React.forwardRef(function(_ref,ref){var source=_ref.source,_ref$interruptionMode=_ref.interruptionMode,interruptionMode=_ref$interruptionMode===void 0?"lower volume":_ref$interruptionMode,_ref$playsInBackgroun=_ref.playsInBackground,playsInBackground=_ref$playsInBackgroun===void 0?false:_ref$playsInBackgroun,_ref$playsInSilentMod=_ref.playsInSilentModeIOS,playsInSilentModeIOS=_ref$playsInSilentMod===void 0?false:_ref$playsInSilentMod,_ref$playThroughEarpi=_ref.playThroughEarpieceAndroid,playThroughEarpieceAndroid=_ref$playThroughEarpi===void 0?false:_ref$playThroughEarpi,onPlaybackStatusUpdateProp=_ref.onPlaybackStatusUpdate,onPlaybackFinish=_ref.onPlaybackFinish,_ref$isLooping=_ref.isLooping,isLooping=_ref$isLooping===void 0?false:_ref$isLooping,_ref$volume=_ref.volume,volume=_ref$volume===void 0?1.0:_ref$volume;var _React$useState=React.useState(),_React$useState2=_slicedToArray(_React$useState,2),currentSound=_React$useState2[0],setCurrentSound=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),isPlaying=_React$useState4[0],setIsPlaying=_React$useState4[1];React.useEffect(function(){if(currentSound&&typeof(currentSound==null?void 0:currentSound.setIsLoopingAsync)==="function"){currentSound.setIsLoopingAsync(isLooping);}},[currentSound,isLooping]);React.useEffect(function(){if(currentSound&&typeof(currentSound==null?void 0:currentSound.setVolumeAsync)==="function"){currentSound.setVolumeAsync(volume);}},[currentSound,volume]);var updateAudioMode=React.useCallback(_asyncToGenerator(function*(){try{yield Audio.setAudioModeAsync({staysActiveInBackground:playsInBackground,interruptionModeIOS:interruptionMode==="lower volume"?InterruptionModeIOS.DuckOthers:InterruptionModeIOS.DoNotMix,interruptionModeAndroid:interruptionMode==="lower volume"?InterruptionModeAndroid.DuckOthers:InterruptionModeAndroid.DoNotMix,playsInSilentModeIOS:playsInSilentModeIOS,playThroughEarpieceAndroid:playThroughEarpieceAndroid});}catch(e){console.error("Failed to set audio mode. interruptionMode, playsInBackground, playsInSilentModeIOS, playThroughEarpieceAndroid might not be set. Failed with",e);}}),[interruptionMode,playsInBackground,playsInSilentModeIOS,playThroughEarpieceAndroid]);var onPlaybackStatusUpdate=function onPlaybackStatusUpdate(status){var mappedStatus=mapToMediaPlayerStatus(status);onPlaybackStatusUpdateProp==null?void 0:onPlaybackStatusUpdateProp(mappedStatus);if(status.isLoaded){if(status.didJustFinish){if(isLooping){return;}onPlaybackFinish==null?void 0:onPlaybackFinish();}setIsPlaying(status.isPlaying);}};var onTogglePlayback=function onTogglePlayback(){updateAudioMode();};var loadAudio=function(){var _ref3=_asyncToGenerator(function*(){onPlaybackStatusUpdateProp==null?void 0:onPlaybackStatusUpdateProp({isPlaying:false,isLoading:true,isBuffering:false,currentPositionMillis:0,durationMillis:0,bufferedDurationMillis:0,isError:false});var finalSource=yield normalizeBase64Source(source,"audio");var _yield$Audio$Sound$cr=yield Audio.Sound.createAsync(finalSource),sound=_yield$Audio$Sound$cr.sound;setCurrentSound(sound);sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);});return function loadAudio(){return _ref3.apply(this,arguments);};}();useSourceDeepCompareEffect(function(){loadAudio();},[source]);return _jsx(MediaPlaybackWrapper,{ref:ref,isPlaying:isPlaying,media:currentSound,onTogglePlayback:onTogglePlayback});});export default HeadlessAudioPlayer;
|
|
1
|
+
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx";import*as React from"react";import{Audio,InterruptionModeIOS,InterruptionModeAndroid}from"expo-av";import{mapToMediaPlayerStatus,normalizeBase64Source,useSourceDeepCompareEffect}from"../MediaPlayerCommon";import MediaPlaybackWrapper from"../MediaPlaybackWrapper";import{jsx as _jsx}from"react/jsx-runtime";var HeadlessAudioPlayer=React.forwardRef(function(_ref,ref){var source=_ref.source,_ref$interruptionMode=_ref.interruptionMode,interruptionMode=_ref$interruptionMode===void 0?"lower volume":_ref$interruptionMode,_ref$playsInBackgroun=_ref.playsInBackground,playsInBackground=_ref$playsInBackgroun===void 0?false:_ref$playsInBackgroun,_ref$playsInSilentMod=_ref.playsInSilentModeIOS,playsInSilentModeIOS=_ref$playsInSilentMod===void 0?false:_ref$playsInSilentMod,_ref$playThroughEarpi=_ref.playThroughEarpieceAndroid,playThroughEarpieceAndroid=_ref$playThroughEarpi===void 0?false:_ref$playThroughEarpi,onPlaybackStatusUpdateProp=_ref.onPlaybackStatusUpdate,onPlaybackFinish=_ref.onPlaybackFinish,_ref$isLooping=_ref.isLooping,isLooping=_ref$isLooping===void 0?false:_ref$isLooping,_ref$volume=_ref.volume,volume=_ref$volume===void 0?1.0:_ref$volume;var _React$useState=React.useState(),_React$useState2=_slicedToArray(_React$useState,2),currentSound=_React$useState2[0],setCurrentSound=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),isPlaying=_React$useState4[0],setIsPlaying=_React$useState4[1];React.useEffect(function(){if(currentSound&&typeof(currentSound==null?void 0:currentSound.setIsLoopingAsync)==="function"){currentSound.setIsLoopingAsync(isLooping);}},[currentSound,isLooping]);React.useEffect(function(){if(currentSound&&typeof(currentSound==null?void 0:currentSound.setVolumeAsync)==="function"){currentSound.setVolumeAsync(volume);}},[currentSound,volume]);var updateAudioMode=React.useCallback(_asyncToGenerator(function*(){try{yield Audio.setAudioModeAsync({staysActiveInBackground:playsInBackground,interruptionModeIOS:interruptionMode==="lower volume"?InterruptionModeIOS.DuckOthers:InterruptionModeIOS.DoNotMix,interruptionModeAndroid:interruptionMode==="lower volume"?InterruptionModeAndroid.DuckOthers:InterruptionModeAndroid.DoNotMix,playsInSilentModeIOS:playsInSilentModeIOS,playThroughEarpieceAndroid:playThroughEarpieceAndroid});}catch(e){if((e==null?void 0:e.code)==="E_AUDIO_AUDIOMODE"){console.warn("Background audio playback only works in published apps, not in preview mode. For iOS apps, add 'audio' under UI Background Modes in Project Settings > Apple App Store.");}else{console.error("Failed to set audio mode. interruptionMode, playsInBackground, playsInSilentModeIOS, playThroughEarpieceAndroid might not be set. Failed with",e);}}}),[interruptionMode,playsInBackground,playsInSilentModeIOS,playThroughEarpieceAndroid]);var onPlaybackStatusUpdate=function onPlaybackStatusUpdate(status){var mappedStatus=mapToMediaPlayerStatus(status);onPlaybackStatusUpdateProp==null?void 0:onPlaybackStatusUpdateProp(mappedStatus);if(status.isLoaded){if(status.didJustFinish){if(isLooping){return;}onPlaybackFinish==null?void 0:onPlaybackFinish();}setIsPlaying(status.isPlaying);}};var onTogglePlayback=function onTogglePlayback(){updateAudioMode();};var loadAudio=function(){var _ref3=_asyncToGenerator(function*(){onPlaybackStatusUpdateProp==null?void 0:onPlaybackStatusUpdateProp({isPlaying:false,isLoading:true,isBuffering:false,currentPositionMillis:0,durationMillis:0,bufferedDurationMillis:0,isError:false});var finalSource=yield normalizeBase64Source(source,"audio");var _yield$Audio$Sound$cr=yield Audio.Sound.createAsync(finalSource),sound=_yield$Audio$Sound$cr.sound;setCurrentSound(sound);sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);});return function loadAudio(){return _ref3.apply(this,arguments);};}();useSourceDeepCompareEffect(function(){loadAudio();},[source]);return _jsx(MediaPlaybackWrapper,{ref:ref,isPlaying:isPlaying,media:currentSound,onTogglePlayback:onTogglePlayback});});export default HeadlessAudioPlayer;
|
|
@@ -35,7 +35,12 @@ const HeadlessAudioPlayer = React.forwardRef(({ source, interruptionMode = "lowe
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
|
-
|
|
38
|
+
if ((e === null || e === void 0 ? void 0 : e.code) === "E_AUDIO_AUDIOMODE") {
|
|
39
|
+
console.warn("Background audio playback only works in published apps, not in preview mode. For iOS apps, add 'audio' under UI Background Modes in Project Settings > Apple App Store.");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.error("Failed to set audio mode. interruptionMode, playsInBackground, playsInSilentModeIOS, playThroughEarpieceAndroid might not be set. Failed with", e);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
}, [
|
|
41
46
|
interruptionMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadlessAudioPlayer.js","sourceRoot":"","sources":["../../../../../../src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KA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,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QACnD,IAAI;YACF,MAAM,KAAK,CAAC,iBAAiB,CAAC;gBAC5B,uBAAuB,EAAE,iBAAiB;gBAC1C,mBAAmB,EACjB,gBAAgB,KAAK,cAAc;oBACjC,CAAC,CAAC,mBAAmB,CAAC,UAAU;oBAChC,CAAC,CAAC,mBAAmB,CAAC,QAAQ;gBAClC,uBAAuB,EACrB,gBAAgB,KAAK,cAAc;oBACjC,CAAC,CAAC,uBAAuB,CAAC,UAAU;oBACpC,CAAC,CAAC,uBAAuB,CAAC,QAAQ;gBACtC,oBAAoB;gBACpB,0BAA0B;aAC3B,CAAC,CAAC;SACJ;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,+IAA+I,EAC/I,CAAC,CACF,CAAC;
|
|
1
|
+
{"version":3,"file":"HeadlessAudioPlayer.js","sourceRoot":"","sources":["../../../../../../src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,EAEL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D;;;GAGG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAI1C,CACE,EACE,MAAM,EACN,gBAAgB,GAAG,cAAc,EACjC,iBAAiB,GAAG,KAAK,EACzB,oBAAoB,GAAG,KAAK,EAC5B,0BAA0B,GAAG,KAAK,EAClC,sBAAsB,EAAE,0BAA0B,EAClD,gBAAgB,EAChB,SAAS,GAAG,KAAK,EACjB,MAAM,GAAG,GAAG,GACb,EACD,GAAG,EACH,EAAE;IACF,MAAM,CAAC,YAAY,EAAE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