FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Displaying iTunes Lyrics: solution found, but need some help

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Salling Clicker for Windows
View previous topic :: View next topic  
Author Message
G-
Newbie


Joined: 19 Mar 2006
Posts: 2

PostPosted: Sun Mar 19, 2006 10:58 pm    Post subject: Displaying iTunes Lyrics: solution found, but need some help Reply with quote

Hello,

I've written a script to display the lyrics of the currently playing song in iTunes on the remote device using iTunes.CurrentTrack.Lyrics.

Initially I wanted to display all the lyrics in a normal window that could scroll, as though I was reading a normal text file on my phone, but after looking through the scripts and the forum I couldn't see a function to do this. I tried MsgBox, but it was far too small.

I then found CreateListScreen, which almost does what's needed, the only problem being that rows don't wrap. scScroll is a workable hack, but it's ugly.

First of all I tried splitting the lyrics into an array by "\r\n" and then looping through a CreateRow for every element. This was quite good, because I could do scScroll and scSmall, but it was very slow and crashed my computer.

I then tried using widget.itemLabels directly. This method is much quicker, but I don't see any way of specifying scScroll and scSmall here.

Here's my code. What's the best way of displaying the lyrics? A scrollable window would be ideal; CreateList with scSmall and scScroll is the next best thing.

[code:1]var iTunes = null


var helper = new ActiveXObject("SCHelper.SECHelper");
if (helper.IsProcessRunning("iTunes.exe")) {
launchWidget();
} else {
var launchQuestion = CreateQuestionDialog("launch_");
launchQuestion.textualContent = "Launch iTunes?";
theTerminal.Push(launchQuestion);
}

function launch_OK(w)
{
launchWidget();
}

///////////////////////////////////////////////////////////////////////////

function launchWidget()
{


iTunes = new ActiveXObject("iTunes.Application");
var lyrics = iTunes.CurrentTrack.Lyrics;
var splitlyrics = lyrics.split("\r\n");
var songname = iTunes.CurrentTrack.Name;
var artist = iTunes.CurrentTrack.Artist;

var widget = CreateListScreen( "mylist_" );
widget.title = "Lyrics";


if (lyrics) {


widget.itemLabels = splitlyrics;
// widget.ScSmall(); Is there anything like this?
theTerminal.Push(widget);

}

else {

var msgbox = CreateMessageboxDialog( "messagebox_");
msgbox.title = "";
msgbox.textualContent = "No lyrics were found for " + "\'" + songname + "\'.";

theTerminal.Push(msgbox);



}

}[/code:1]
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Mar 20, 2006 12:07 am    Post subject: Reply with quote

Hi,

I think the best way to do this given the current set of widgets available would be either of these two (depending a bit on how the lyrics are supposed to be used/enjoyed):

1. MessageBox: all devices using the Clicker client software can show a fair amount of text 2kb+. I think it'd be suitable for most songs; but I could be wrong.

2. Keypad/Mediaplayer widget: loop through the lines of lyrics in a single, wrapped, text row. Update the contents with every few seconds. This would not be useful for singing along, but definitely quite cool.

Using list widgets is not recommended as you have no way of knowing how to break the lines up. Not even I know how many characters will fit on a line, as it depends on the fonts present on the device, and also on OS and screen size, of course.

If there's wide-spread interest in support for something more polished (and customized) for lyrics viewing, I'd be interested in hearing about this, and I'd be happy to add something for it in a future version. :-)

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
G-
Newbie


Joined: 19 Mar 2006
Posts: 2

PostPosted: Mon Mar 20, 2006 12:21 am    Post subject: Reply with quote

Jonas,

Thanks for the reply. What exactly is the Keypad widget? Could you possibly give me a bit of pseudo-code to explain what you've suggested?

Also, is there a way of applying scrolling, small text to the whole list widget? I know you can with a CreateRow.

I think is quite a bit of interest in lyrics given the 943 views on [url]http://www.salling.com/forums/viewtopic.php?t=3271&highlight=itunes+lyrics[/url] topic.
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Mar 20, 2006 12:55 am    Post subject: Reply with quote

Hi,

Nope; you cannot specify the font size of overflow characteristics of labels in a List widget. I can see how this could potentially be useful in representing lyrics, but I do not know if it'd be the best way to add this feature.

A keypad widget comes in two derived forms, of which the more elaborate one is the mediaplayer widget you see in the iTunes controller.

Here's an example:
http://www.salling.com/forums/viewtopic.php?p=10504

I suggest you make your script push one of these (ignore all the send keystroke stuff in the tutorial) and implement an update callback that occasionally changes the text row contents so you move further into the lyrics as time passes. You could check out the iTunes Remote script for sample code on that one (the text rows are updated to reflect the currently playing song).

For additional thrills, you could even make a couple of text rows, shift content between them, inserting the newest content "on top" to create the illusion of automatic scrolling. Or you could make the up/down keys control the scrolling. This would work best on devices running the Clicker client software. Do not create new text rows all the time; that'd cause problems, I think. Instead, create the number of rows you need and move the textual content between them.

Actually, I think this'd be a rather neat solution, given the widget tools you currently have at your disposal. Only problem is that there's no way of knowing how many rows of text will fit on the screen. In case of vertical overflow, Clicker will clip the text (on the PC in the case of client-less phones; on the device in the case of Clicker client running on the phone)

Best.
--
Jonas

[quote="G-"]Jonas,

Thanks for the reply. What exactly is the Keypad widget? Could you possibly give me a bit of pseudo-code to explain what you've suggested?

Also, is there a way of applying scrolling, small text to the whole list widget? I know you can with a CreateRow.

I think is quite a bit of interest in lyrics given the 943 views on [url]http://www.salling.com/forums/viewtopic.php?t=3271&highlight=itunes+lyrics[/url] topic.[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Salling Clicker for Windows All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group