Expo SDK 49
This is the code:
if (!source) {
log.debug("Could not find source for type: " + type);
return;
}
Audio.Sound.createAsync(source, {
shouldPlay: true,
})
.then((res) => {
log.debug("Sound created async", res);
res.sound.setOnPlaybackStatusUpdate((status: AVPlaybackStatus) => {
log.debug("Sound status: ", status);
if (!status.isLoaded && status.error) {
log.debug("Error playing sound: ", status.error);
}
if (status.isLoaded && !status.didJustFinish) return;
log.debug("Unloading sound" + type);
res.sound.unloadAsync().catch((error) => {
log.debug("Error unloading sound: ", error);
});
});
res.sound.setStatusAsync({
shouldPlay: true,
volume: 1,
});
})
.catch((error) => {
log.debug("playSound error: ", error);
});
This will trigger these log outputs.
LOG 19:18:18 | DEBUG : Sound created async
{
"sound": {
"_loaded": true,
"_loading": false,
"_key": 180,
"_lastStatusUpdate": null,
"_lastStatusUpdateTime": null,
"_subscriptions": [
{
"@@nativeEmitterSubscription@@": {}
},
{
"@@nativeEmitterSubscription@@": {}
},
{
"@@nativeEmitterSubscription@@": {}
}
],
"_eventEmitter": {
"_listenerCount": 3,
"_nativeModule": {},
"_eventEmitter": {
"_nativeModule": {}
}
},
"_coalesceStatusUpdatesInMillis": 100,
"_onPlaybackStatusUpdate": null,
"_onMetadataUpdate": null,
"_onAudioSampleReceived": null
},
"status": {
"isMuted": false,
"isBuffering": false,
"audioPan": 0,
"uri": "/data/user/0/the.app/cache/ExponentAsset-9ceb4b5da88589c465b41b6c98c207e1.mp3",
"shouldPlay": true,
"durationMillis": 444,
"isLoaded": true,
"didJustFinish": false,
"androidImplementation": "SimpleExoPlayer",
"isLooping": false,
"progressUpdateIntervalMillis": 500,
"volume": 1,
"playableDurationMillis": 444,
"shouldCorrectPitch": false,
"isPlaying": true,
"rate": 1,
"positionMillis": 0
}
}
LOG 19:18:18 | DEBUG : Sound status:
{
"isMuted": false,
"isBuffering": false,
"audioPan": 0,
"uri": "/data/user/0/the.app/cache/ExponentAsset-9ceb4b5da88589c465b41b6c98c207e1.mp3",
"shouldPlay": true,
"durationMillis": 444,
"isLoaded": true,
"didJustFinish": false,
"androidImplementation": "SimpleExoPlayer",
"isLooping": false,
"progressUpdateIntervalMillis": 500,
"volume": 1,
"playableDurationMillis": 444,
"shouldCorrectPitch": false,
"isPlaying": true,
"rate": 1,
"positionMillis": 0
}
But no sound is every played. And no more statuses are received…
Any ideas?