Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Winamp Status Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: October 03 2004 at 13:13 | IP Logged Quote TonyNo

While working on some new TTS reminders, I wanted to be able to pause Winamp if it was playing and a reminder was to be spoken. This turned into a few hours of research and playing around to get this macro. It communicates with Winamp via Windows Messaging and updates a Global Variable (WINAMP STATUS) with the status code: -1=Winamp not loaded, 0=Stopped, 1=Playing, 3=Paused.

insert into macroheader values ('TEST WINAMP','WINAMP STATUS',0,0,1);
insert into macrodetail values ('TEST WINAMP',1,15,'[LOCAL1]',NULL,'ph_findwindow("Winamp v1.x",0)',0);
insert into macrodetail values ('TEST WINAMP',2,16,'',NULL,'if([LOCAL1] = 0, 1, 3)',0);
insert into macrodetail values ('TEST WINAMP',3,10,'WINAMP STATUS',NULL,'-1',0);
insert into macrodetail values ('TEST WINAMP',4,16,'',NULL,'999',0);
insert into macrodetail values ('TEST WINAMP',5,10,'WINAMP STATUS',NULL,'ph_sendmsg( [LOCAL1], 1024, 0, 104)',0);


You could, with a case statement, also use text instead of numbers...

case ( {WINAMP STATUS} WHEN -1 THEN "Not Loaded" WHEN 0 THEN "Stopped" WHEN 1 THEN "Playing" WHEN 3 THEN "Paused")
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dmoreno
Newbie
Newbie
Avatar

Joined: February 15 2002
Location: United States
Online Status: Offline
Posts: 31
Posted: February 25 2006 at 08:29 | IP Logged Quote dmoreno

Is there a way to get powerhome to recognize or detect a song change in a playlist?
Back to Top View dmoreno's Profile Search for other posts by dmoreno
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 25 2006 at 09:33 | IP Logged Quote TonyNo

This is something that needs to come from Winamp. Dave has mentioned that he may look at writing a Winamp plugin for this and some other functions.

As an update, the latest version of PH supports Winamp directly with ph_winampinfo and ph_winampctrl.

The first post in this thread is now reduced to ph_winampinfo ( "status", 1). This command returns "playing", "paused", "stopped", and "not running". After this is executed, LOCAL1 will contain "0". If an error occurs, then LOCAL1 will contain "1". If Winamp is not running, then LOCAL1 will contain "2". If the command is not recognized, then LOCAL1 will contain "3".
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dmoreno
Newbie
Newbie
Avatar

Joined: February 15 2002
Location: United States
Online Status: Offline
Posts: 31
Posted: February 26 2006 at 06:52 | IP Logged Quote dmoreno

TonyNo, I think a plugin would be a good idea. Is there a way setup a macro to fire, say every 15 to 30 seconds to poll winamp for a song change?

What I did was create a textbox with current track using the ph_ccmodify function. Couldn't I get the track length from ph_winampinfo and fire a macro then?
Back to Top View dmoreno's Profile Search for other posts by dmoreno
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 26 2006 at 10:29 | IP Logged Quote dhoward

Until I get the Winamp plugin written, using the ph_winampinfo and ph_winampctrl functions is the best we've got.

Instead of polling every 15 to 30 seconds, I would setup a waiting macro to handle the changes. You would have to fire this macro when you press play and have to handle situations for when you hit pause, stop, fast forward, etc. The basic idea would be to wait for the length of the song, wake up, get the current playing song title, wait again, etc.

The wait formula would be something like: ph_winampinfo("tracklen",0) - (ph_winampinfo("trackpos",0) / 1000) + 1

So no matter when the macro was called, it would calculate the total length of the song minus the current position and then add 1 second to make sure you've made it to the next song.

I would think you could make something like this work.

Let me know if you need help.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 26 2006 at 10:35 | IP Logged Quote TonyNo

That is how my JavaScript works with Browseamp to keep synced. Good solution!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dmoreno
Newbie
Newbie
Avatar

Joined: February 15 2002
Location: United States
Online Status: Offline
Posts: 31
Posted: March 02 2006 at 04:27 | IP Logged Quote dmoreno

OK Dave got it to work. The way I did it was getting the track length minus the current position. I used a doctored formula as above to create a timed macro. But every time I click a button it creates a new timed macro.Is there a way to update the existing timed macro, or even kill the existing timed macro before creating a new one. I looked through the help files and searched the forum, but not finding what I was looking for?
Back to Top View dmoreno's Profile Search for other posts by dmoreno
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 02 2006 at 07:49 | IP Logged Quote TonyNo

Do you mean Timed Event?

Dave suggested using Wait in a macro, which can be updated (ph_extendmacrowait) or killed (ph_killmacrowait).
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: September 04 2006 at 11:16 | IP Logged Quote TonyNo

I just found a problem with Dave's suggested wait formula. Apparently, the times are returned as a string, so change it to this...

int( number( ph_winampinfo( "tracklen",0)) - ( number( ph_winampinfo( "trackpos",0)) / 1000) + 1)
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: September 15 2006 at 23:06 | IP Logged Quote dhoward

Gosh, I hope Don got this figured out. I cant believe I missed this.

To kill an existing waiting macro, use the ph_killmacrowait("WAITINGMACROID"). You can also extend the wait time of a currently waiting macro with ph_extendmacrowait. These functions are documented in the help file.

Good catch Tony. Yes, the ph_winampinfo function returns a string since depending upon the requested info, it may not be numeric data (PowerHome has no concept of function overloading).

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: October 26 2008 at 09:12 | IP Logged Quote TonyNo

I'm finally tracking down an error condition with this that's been plaguing me for a while now.

The problem is that, sometimes, the track position comes back as beyond the track length.

Example:
Track Length: 285
Track Pos: 285420

I think this caused an endless loop with my code, but I can't recall for sure. Testing now.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum