tauri icon indicating copy to clipboard operation
tauri copied to clipboard

fix(linux): adding Gstreamer plugin for handling asset://

Open aaalloc opened this issue 2 months ago • 3 comments

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 avatar Nov 01 '25 15:11 aaalloc

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 avatar Nov 14 '25 23:11 DEVGOD2020

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 !

aaalloc avatar Nov 15 '25 14:11 aaalloc

any status about this ?

aaalloc avatar Dec 09 '25 18:12 aaalloc