Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass BufferingProgress interface not supported #33

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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