[Gambas-user] Fwd: Music.Length part 2

Patrik Karlsson pata.karlsson at ...626...
Fri May 30 10:15:04 CEST 2014


From: Benoît Minisini <gambas at ...1...>
Date: 2014-05-28 14:38 GMT+02:00
Subject: Re: [Gambas-user] Music.Length part 2
To: Patrik Karlsson <pata.karlsson at ...626...>


Le 28/05/2014 14:32, Patrik Karlsson a écrit :

 I had some trouble with gambas gstreamer on Elementary OS so now I'm on
> Kubuntu.
>
> I get MediaPlayer to play a mp3 file as long as it is located _outside_
> my gambas project:
>    $hPlayer.URL = Media.URL("internal.mp3") ' does not play
>    $hPlayer.URL = Media.URL("/home/patrik/external.mp3") 'plays
>
> What I really do need is to play, get the duration an position for a
> file bundled _inside_ my gambas project.
> Is MediaPlayer capable of doing that?
>
> If not, can MediaPlayer play a file in my gambas executable archive with
> something like:
>    $hPlayer.URL = Media.URL("/home/patrik/app.gambas#internal.mp3") ?
>
> /Patrik
>

No, GStreamer URLs cannot extract files located inside a Gambas archive.

The solution is copying the Gambas archive file to a temporary real file,
and use it as URL.

sTemp = File.SetExt(Temp$(),"mp3")
Copy "internal.mp3" to sTemp
$hPlayer.URL = Media.URL(sTemp)
...
Kill sTemp ' If your file is very big, this could be useful

I eventually can implement that transparently inside gb.media in the future.

Regards,

-- 
Benoît Minisini

Thanks, this solved my problem, and may I say, Temp$() is a really nice
concept! :)

However, I noticed that it takes about 0.15 seconds (for GStreamer?) to
calculate the length of my mp3 file, but I was able to manage that.

/Patrik



More information about the User mailing list