使用audio_service插件flutter计算会话中播放的总体音频
void _listenToPlaybackState() {
_audioHandler.playbackState.listen(
(playbackState) {
final isPlaying = playbackState.playing;
// if (isPlaying) {
// shouldShowMiniPlayerNotfier.value = true;
// if (_currentPlayingEpisode.isNegative == false) {
// var episodeId = _currentPlayingEpisode;
// log('hitting play api for episodeId: $episodeId ::: $_currentPlayingEpisode');
// _currentPlayingEpisode = -1;
// podcastsController.updatePlayCountOfEpisodeById(episodeId);
// }
// }
final processingState = playbackState.processingState;
if (processingState == AudioProcessingState.loading ||
processingState == AudioProcessingState.buffering) {
playButtonNotifier.value = ButtonState.loading;
} else if (!isPlaying) {
playButtonNotifier.value = ButtonState.paused;
log("Audio Paused ${currentMediaItemIdNotifier.value}");
} else if (processingState != AudioProcessingState.completed) {
playButtonNotifier.value = ButtonState.playing;
` // MixpanelManager.timeEvent(MixPanel.audioPlayingTimeSpent);
log("Audio Play ${currentMediaItemIdNotifier.value}");
} else if (processingState == AudioProcessingState.idle) {
playButtonNotifier.value = ButtonState.stopped;
log("Audio Stopped ${currentMediaItemIdNotifier.value}");
} else {
_audioHandler.seek(Duration.zero);
_audioHandler.pause();
}
},
);
}
我发布了一个当用户尝试从通知面板或按钮播放音频时登录事件的示例。请帮助设置分析事件
“计算音频服务颤振的总体音频播放时间以进行分析”任何更新??