onPlaybackStatusUpdate 应在每 100 毫秒后返回输出,但仅在播放或停止时返回。我的代码中是否缺少某些内容。(我是 Expo 和 Expo AV 的新手)。请参阅下面用于加载和播放音频文件的代码
if(!sound._loaded)
await sound.loadAsync(
require('./assets/Audio.mp3'),
initialStatus,
);
sound.setStatusAsync({progressUpdateIntervalMillis: 200});
sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
await sound.playAsync();
console.log(sound);
}
const initialStatus = (status) => {
console.log("initialStatus");
console.log(status);
}
let onPlaybackStatusUpdate = async (playbackStatus) => {
//if(!isNaN(playbackStatus.durationMillis))
//setTotalLength(playbackStatus.durationMillis/1000);
//setCurrentPos(playbackStatus.positionMillis.toString().split(".")[0]/1000);
//setIsPlaying(playbackStatus.isPlaying);
console.log("onPlaybackStatusUpdate");
console.log(playbackStatus);
}