PDA

View Full Version : Pass a filename to a Media Player page?



Can't Think of a Name
08-09-2006, 01:42 PM
Is it possible to make *one* global media player page and have a bunch of labels that call it but specify different files? Or if I have 500 files on the CD do I have to make 500 pages that are the same except for the filename?

Thanks

Lorne
08-09-2006, 02:18 PM
Yes. :) Just set a global variable with the file path that you want to open, and use actions to load that file into the object.

What kind of files do you mean?

For video files, you can use the Video.Load action. For HTML files you can use the Web.LoadURL action. For flash files you can use the Flash.Load action, etc.

(Great name btw. :))

Can't Think of a Name
08-09-2006, 02:20 PM
:) Nothing else I tried was free, I was going to call myself "NoGoodNamesLeftHere" but I thought it might be misinterpreted as anger.

Specifically, MP3 files in the WMP plugin. I've got a good 500 or so (all legal, don't worry!) and I'd rather not make 500 WMP pages. Can you give me a hand as to how I have to set up that page and how to pass info to it in links?

Thanks

Lorne
08-09-2006, 02:21 PM
I have a feeling one of our users might have an example of something along those lines that they could share...

Do you want the list and the player on separate pages, or on the same page?

Can't Think of a Name
08-09-2006, 03:22 PM
The player can be one separate page and the list will be over multiple pages, but never the player page.

Lorne
08-09-2006, 03:43 PM
In that case, just use a global variable to hold the current mp3 file. (You could use additional variables to hold other information, like the track name, and stuff.)

So, for example on page 1, someone clicks one of your labels, in that On Click event you'll have code like:


g_strCurrentFile = "AutoPlay\\Audio\\Imogen Heap\\05 Hide and Seek.mp3";
g_strCurrentTrackName = "Hide and Seek";
g_strCurrentArtist = "Imogen Heap";

And then on your player page, you put actions in the On Show event to load that file into media player plugin and start playing it.


MediaPlayer.Load("Player", g_strCurrentFile); -- change "Player" to actual object name
MediaPlayer.Play("Player");
-- could set some label objects to show the track and artist, like so:
Label.SetText("labelTrack", g_strCurrentTrackName);
Label.SetText("labelArtist", g_strCurrentArtist);

If you don't want the track to start playing automatically, you could remove the MediaPlayer.Play() action and use buttons on the player page instead.

Can't Think of a Name
08-09-2006, 04:02 PM
That seems like it's going to work just fine. Thank you!!

Lorne
08-09-2006, 04:05 PM
You're welcome. Let me know how it turns out!

yosik
08-09-2006, 04:16 PM
Starting from a point where you have a m3u file which represents your mp3 files. This would be a text file where each mp3 file (meaning its complete path) occupies one line of text.

Attached is a very quick example (using the AudioPlayer Template).

Yossi

Can't Think of a Name
08-09-2006, 04:47 PM
You're welcome. Let me know how it turns out!

It works PERFECTLY! Just what I needed. If I have some extra time I'll hide the WiMP interface and add a progress bar, but it does what I need it to do!

Thanks for keeping me sane and ahead of schedule.

Roboblue
08-09-2006, 05:21 PM
Here is a music player that has a lot of features that several of us here put together back in November.
You may get a lot of ideas from it