Skip to content

Conversation

@aaalloc
Copy link

@aaalloc aaalloc commented Nov 1, 2025

asset:// is registered as a custom protocol through WebKit, but when an audio or video is got from that protocol, gstreamer is used in the background and can't play the media because there is no handler for asset://
(related to #3725)

This PR creates a Gstreamer Plugin that will handle asset:// url.

If you want to test it out: build the plugin so that you will have a .so, export GST_PLUGIN_PATH=../../target/debug (where the build .so lies), and then launch your tauri app or simply try it out with gst-launch-1.0 uridecodebin uri=asset:///your/path/to/video/or/audio.mp3 ! videoconvert ! autovideosink

If we want to make things work we will need to place the .so into Gstreamer plugins search path. There's some information about it here : https://gstreamer.freedesktop.org/documentation/gstreamer/gstregistry.html?gi-language=c#gst_registry_add_plugin

On startup, plugins are searched for in the plugin search path. The following locations are checked in this order:

    location from --gst-plugin-path commandline option.
    the GST_PLUGIN_PATH environment variable.
    the GST_PLUGIN_SYSTEM_PATH environment variable.
    default locations (if GST_PLUGIN_SYSTEM_PATH is not set). Those default locations are: $XDG_DATA_HOME/gstreamer-$GST_API_VERSION/plugins/ and $prefix/libs/gstreamer-$GST_API_VERSION/. [$XDG_DATA_HOME](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) defaults to $HOME/.local/share.

A solution would be to add the .so where every other gstreamer plugins lies, in my case I have simply put it in /usr/lib64/gstreamer-1.0 and Gstreamer detected it.

@aaalloc aaalloc requested a review from a team as a code owner November 1, 2025 15:10
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Nov 1, 2025
}

fn uri(&self) -> Option<String> {
None
Copy link
Author

@aaalloc aaalloc Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be like this, but I don't think it is a problem for now

@aaalloc aaalloc force-pushed the tauri-asset-gstreamer-plugin branch from 3a20cd2 to 2450945 Compare November 1, 2025 15:15
@aaalloc aaalloc changed the title fix((linux): adding Gstreamer plugin for handling asset:// fix(linux): adding Gstreamer plugin for handling asset:// Nov 1, 2025
@FabianLars FabianLars self-assigned this Nov 1, 2025
@aaalloc aaalloc force-pushed the tauri-asset-gstreamer-plugin branch from 2450945 to d188140 Compare November 1, 2025 15:26
aaalloc and others added 2 commits November 2, 2025 18:24
asset:// is registered as a custom protocol through WebKit, but when an audio or video is got from that protocol,
gstreamer is used in the background and can't play the media because there is no handler for asset://
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@aaalloc aaalloc force-pushed the tauri-asset-gstreamer-plugin branch from 96a082f to 6ad67e8 Compare November 2, 2025 17:24
@DEVGOD2020
Copy link

For anyone with special charecters in their file names...

use percent_encoding::percent_decode_str;

    // directly having full path after asset:// or having localhost
    let location = location.strip_prefix("localhost").unwrap_or(location).to_string();
    
    //Fix URI UTF8 encoding tauri does, fix file names with special characters
    let location = percent_decode_str(&location)
        .decode_utf8().expect("Valid UTF-8")
        .to_string();

In imp.rs you could also use the percent_encoding crate to handle UTF8 encoding file name related issues.
Spaces, dashes, and Chinese characters in audio file names were causing errors for my tauri music player without the UTF8 decoding.

@socket-security
Copy link

socket-security bot commented Nov 15, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​gst-plugin-version-helper@​0.8.310010093100100
Addedcargo/​gstreamer-base@​0.24.210010093100100
Addedcargo/​gstreamer@​0.24.39810093100100

View full report

@aaalloc
Copy link
Author

aaalloc commented Nov 15, 2025

For anyone with special charecters in their file names...

use percent_encoding::percent_decode_str;

    // directly having full path after asset:// or having localhost
    let location = location.strip_prefix("localhost").unwrap_or(location).to_string();
    
    //Fix URI UTF8 encoding tauri does, fix file names with special characters
    let location = percent_decode_str(&location)
        .decode_utf8().expect("Valid UTF-8")
        .to_string();

In imp.rs you could also use the percent_encoding crate to handle UTF8 encoding file name related issues. Spaces, dashes, and Chinese characters in audio file names were causing errors for my tauri music player without the UTF8 decoding.

@DEVGOD2020 I fixed this case, thank you !

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

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

3 participants