Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Resuming a paused live radio stream continued from the buffered position rather than seeking to live, causing stream disruption after long pauses.

Changes

  • SeekToLive() method: New helper that seeks the MediaPlayer to the live edge (NaturalDuration) - a lightweight approach that avoids disposing/recreating the MediaSource
  • Play() method: Calls SeekToLive() after starting playback to ensure we're at the live position
  • PlaybackStateChanged handler: Detects external resume (hardware buttons, system controls) and seeks to live position
// Seek to the live edge using NaturalDuration
private void SeekToLive()
{
    MediaPlaybackSession session = _player.PlaybackSession;
    if (session.IsSeekable && session.NaturalDuration.TotalSeconds > 0)
    {
        session.Position = session.NaturalDuration;
    }
}

Watchdog service continues to provide recovery if stream fails to start.

Original prompt

This section details on the original issue you should resolve

<issue_title>When resuming the stream, always seek forward to the live radio</issue_title>
<issue_description>Currently if the system or user pauses Trdo, when resumed it continues from the paused time, which causes an issue if there is a long gap it can cause the stream to get disrupted. Instead when resuming the stream it should seek forward to always be streaming live.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 24, 2025 21:54
Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com>
Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com>
Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stream resume to seek forward to live radio Always seek to live stream when resuming radio playback Nov 24, 2025
Copilot AI requested a review from TheJoeFin November 24, 2025 22:02
@TheJoeFin
Copy link
Owner

@copilot looks good, rebase from main

Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot looks good, rebase from main

I'm unable to perform a rebase as I don't have access to force push, which is required after rebasing. Could you please rebase this branch from main on your end? Alternatively, if you'd prefer, I can merge main into this branch instead (though that will create a merge commit rather than a linear history).

@TheJoeFin
Copy link
Owner

@copilot merge main into this then

Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot merge main into this then

Done. Merged main into this branch in commit fad3b59.

@TheJoeFin
Copy link
Owner

@copilot this seems like a very heavy handed way of doing it by fully disposing the MediaPlayer every time. Just try to seek the MediaPlayer to Live, would that work?

Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot this seems like a very heavy handed way of doing it by fully disposing the MediaPlayer every time. Just try to seek the MediaPlayer to Live, would that work?

Good point. Changed the approach to use SeekToLive() which seeks to NaturalDuration (live edge) instead of disposing/recreating the MediaSource. This is much lighter weight - see commit c274943.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When resuming the stream, always seek forward to the live radio

2 participants