Lotek Deviant

There are several things I want to do.

First off what I am doing is reworking a gadget that was made to play mp3s from WMP, this gadget also displays the song track, artist & album. The problem I have is that I don't find it flexible enough and it's just ugly looking to boot,

I have so far reworked the interface so that it is much nicer looking visually tho still needs some work, got rid of the album art in the interface BUT I still want to be able to display the art but in a flyout which while I can get the flyout itself to work it does not display the album art and would like to know how to reference the working javascript that was in the parent window/gadget to display the image in the flyout.

I am also trying to add functionality by adding settings to the gadget that will offer you checkboxes for the track title, artist, album, song length etc. And have run into several problems with this... 1st how to save.access the settings and then how to apply them so that only those options that are checked are displayed in the gadget. I have been able to get the settings window to pop up and populate it with the checkbox options but that's about it at the moment.

Any help is greatly appreciated.

Re: Sidebar Gadget Development How do I do this: ?

Jonathan Abbott

You've certainly picked an easy task! You could just use my Media Player Gadget and put a request in for the extra stuff you want!

Addressing your points though:

1. To access variables etc from the main gadget code, see my comments in this thread.

2. Saving/accessing settings. I wrote an article on the subject on AeroXperience, unfortunately the site is down! So in brief:

2.1 You need to save the settings as the settings.html closes. ie
Your HEAD section needs to include:

System.Gadget.onSettingsClosing = SettingsClosing;

function SettingsClosing(event) {
System.Gadget.Settings.write("Title", checkboxTitle.checked);
System.Gadget.Settings.write("Artist", checkboxArtist.checked);
System.Gadget.Settings.write("Album", checkboxAlbum.checked);
System.Gadget.Settings.write("Song Length", checkboxSongLength.checked);

And your BODY section for these should be something like:

<input unselectable="on" type="checkbox" id="checkboxTitle" >Title<BR>
<input unselectable="on" type="checkbox" id="checkboxArtist" >Title<BR>
<input unselectable="on" type="checkbox" id="checkboxAlbum" >Title<BR>
<input unselectable="on" type="checkbox" id="checkboxSongLength" >Title<BR>

2.2 You need to populate the check boxes as the settings.html opens:
Include the following in your HEAD section:

function init() {
checkboxTitle.checked = System.Gadget.Settings.read("Title");
checkboxArtist.checked = System.Gadget.Settings.read("Artist");
checkboxAlbum.checked = System.Gadget.Settings.read("Album");
checkboxSongLength.checked = System.Gadget.Settings.read("SongLength");

And the BODY line should be:

<BODY onstartup="init()">

2.3 You need to read the settings in Gadget.html after the settings have closed:
Your HEAD section needs to include:

System.Gadget.onSettingsClosed = SettingsClosed;

function SettingsClosed() {
showTitle = System.Gadget.Settings.read("Title");
showArtist = System.Gadget.Settings.read("Artist");
showAlbum = System.Gadget.Settings.read("Album");
showSongLength = System.Gadget.Settings.read("SongLength");

Re: Sidebar Gadget Development How do I do this: ?

Lotek Deviant

Thank you, now I have something to work with,
btw very nice player definately setting the bar
high for others looking to do the same ;)

Re: Sidebar Gadget Development How do I do this: ?

Jonathan Abbott

Thanks and good luck with yours. If you want to put test versions out, the best place is on AeroXperience, within the Work in Progress section.

A word of advice - don't touch streamed media! It completely screws up all the WMP events. For example, if say track 5 is a stream "http://..." and you start playing it, WMP will report it's playing track 0 because it creates a new playlist for streams! That can be worked around by checking the current playlist name, if it's not yours, your in a stream playlist. But, it doesn't fire the correct events on track 5 - so you don't know it's actually track 5 that's playing.

And it gets worse. If track 0 is a stream, every now and then, WMP will spontaniously connect to that stream, create a new playlist, change to that playlist, and generates a MediaChange event - so you code is now informed that track 0 is playing!

And worse still, if you try to change to another track whilst a stream is playing, it generates an error because you're no longer in your playlist. So you have to check the playlist name before changing tracks and change it back to your original one. But, and this is the clincher - if track 0 is a stream and you try to change back to your original playlist, WMP immediately changes to the stream playlist, so you can no longer play any other tracks!

The pain and tears I'm having to work around this. The developers need shooting!

You end up being unable to use WMP's currentMedia index number to keep track of which track is playing, and can not rely on the Events firing correctly.

If you don't support streams, everything works perfectly!

Another problem you'll come across, WMP doesn't expose the album art though the API, so you have to search for it yourself.