Skip to content

Commit

Permalink
Bypass BufferingProgress interface not supported (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Apr 23, 2024
2 parents d97eb5b + 5596d95 commit 1cedd24
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion just_audio_windows/windows/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,23 @@ class AudioPlayer {

auto now = std::chrono::system_clock::now();

// Try to get the buffering progress or use 1 if an error occurs
double bufferingProgress;
try
{
bufferingProgress = session.BufferingProgress();
}
catch (...)
{
// If an error occurs, log it and use 1 as the buffering progress
std::cerr << "[just_audio_windows]: Broadcast playback evcent error: Error accessing BufferingProgress. Using default value of 1." << std::endl;
bufferingProgress = 1;
}

eventData[flutter::EncodableValue("processingState")] = flutter::EncodableValue(processingState(session.PlaybackState()));
eventData[flutter::EncodableValue("updatePosition")] = flutter::EncodableValue(TO_MICROSECONDS(session.Position())); //int
eventData[flutter::EncodableValue("updateTime")] = flutter::EncodableValue(TO_MILLISECONDS(now.time_since_epoch())); //int
eventData[flutter::EncodableValue("bufferedPosition")] = flutter::EncodableValue((int64_t)(duration * session.BufferingProgress())); //int
eventData[flutter::EncodableValue("bufferedPosition")] = flutter::EncodableValue((int64_t)(duration * bufferingProgress)); //int
eventData[flutter::EncodableValue("duration")] = flutter::EncodableValue(duration); //int

if (mediaPlaybackList.Items().Size() > 0) {
Expand Down

0 comments on commit 1cedd24

Please sign in to comment.