def load_video_file(self, file):
file_ok = False
if isinstance(file, Gio.File):
file_ok = True
stream = Gtk.MediaFile.new_for_file(file)
else:
if os.path.exists(file):
stream = Gtk.MediaFile.new_for_filename(file)
file_ok = True
if file_ok:
self.video.set_media_stream(stream)
stream.play()
And it works, but the stream is silent ; Of course I double-checked the various video files that I test with and they all have an audio track, sometimes even several ; I tried basically every combination of codec / container that I can find, and yes, they all play fine, but no sound.
I checked pavucontrol (the Pulse Audio control app, tab “Playback” select “All streams”) during the playback and there is effectively no audio stream / sink ever created and / or playing.
This, both within Builder “run” and after building & flatpak run. Oh, and no warning or error in both cases, too.
Outside of Builder / Flatpak however, my Gtk4VideoExample test script (which uses the same load_video_file() func) is playing the same test files with sound without problem.
What could be preventing the app (full Builder project code here) from producing audio?
Yes, thank you Stefan, I checked that too, in fact I ran all my test video through Totem too, to make sure ; Every codec / container runs fine, and into my test script too. It’s only inside Builder / Flatpak that I can get any sound at all, it’s a very strange situation.
Platform details:
Ubuntu 22.4 ; GNOME Builder 43.2 (43.2) from channel “flatpak-stable” ABI 43 GTK+ 4.8.2.
Also
I ran into quite a serious problem trying to open files with the build executable (ie: not within Builder) when os.path.exists(filepath) would always return false…?
I found an explanation and a workaround in this SO answer :
But shouldn’t it be something that Builder sets up? Maybe in the startup wizard “This app will read files on the user disk YES / NO” because now as it is, I would have to put this in a post-install script, which defeats the whole Flatpak purpose
And if I have to request access to the disk / File System, maybe (probably) I have to request access to the audio output, too? That sounds consistent to me.
So the question is, well, are:
How to inform Flatpak (before the build) that the executable will open files / URIs ; and
That is weird ; I have sound but not on all video / codecs, when my test script (using the same Gtk.Video() functions) plays everything with audio out… I have every finish-arg in the book…