Skip to content

fix(mediaplayer): build file URIs that work on Windows - #959

Merged
srperens merged 2 commits into
mainfrom
fix/mediaplayer-windows-file-uri
Oct 2, 2026
Merged

srperens merged 2 commits into
mainfrom
fix/mediaplayer-windows-file-uri

Conversation

@srperens

@srperens srperens commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

normalize_uri and two media player tests built file URIs as format!("file://{}", path.display()). On Windows that gives file://C:\media\clip.mp4, which no source element accepts. So the Media Player could not play a local file on Windows. Since #945 landed, three of its tests have also failed there with StateChangeError (seen in #879's Windows build): decodebin3_decodes_only_the_tracks_it_has_outputs_for, each_audio_track_gets_its_own_output_when_there_are_enough and playback_carries_on_in_time_after_a_file_switch. Windows builds only on main or with the ci:windows label, so #945's own CI did not catch it.

file_uri now uses glib::filename_to_uri, which handles the drive letter, backslashes and escaping. A path it refuses (one that is not absolute) keeps the old form. The tests use the same function.

The test writers needed a fix too. With the URI fix alone, the three tests still failed on Windows. The tests write their media files with gst::parse::launch("... filesink location=<path>"), and in a launch string a Windows path's backslashes are read as escapes. The file was written somewhere else, so the URI pointed at nothing. file_writer now sets location as a property.

Type of Change

  • Bug fix

Testing

  • cargo test --lib mediaplayer on macOS: 28 passed, including the new a_file_uri_turns_back_into_its_path. That test builds a URI for a temp path with spaces and requires glib::filename_from_uri to give the same path back. On Windows the old form fails that.
  • The Windows build runs on this PR through the ci:windows label. It runs the three failing tests and the new one.
  • cargo clippy --all-targets -- -D warnings and cargo fmt are clean.

🤖 Generated with Claude Code

normalize_uri and two media player tests pasted path.display() after
file://, which on Windows gives file://C:\media\clip.mp4: no source
element accepts it, so the Media Player could not play a local file on
Windows, and three of its tests failed there once #945 landed (Windows
only builds on main or with the ci:windows label). file_uri now uses
glib::filename_to_uri, which handles the drive, backslashes and escaping,
and keeps the old form for a path it refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srperens srperens added the ci:windows Run Build (Windows) on this pull request label Oct 2, 2026
The two test-file writers put the path into a gst::parse::launch string.
There a Windows path's backslashes are read as escapes, so the file was
written somewhere else and the URI the tests then played pointed at
nothing: the three tests still failed on Windows with StateChangeError
after the file URI fix. file_writer sets the location as a property.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srperens
srperens merged commit 974db74 into main Oct 2, 2026
9 checks passed
@srperens
srperens deleted the fix/mediaplayer-windows-file-uri branch October 2, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:windows Run Build (Windows) on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant