Old 6th November 2004, 16:24   #1
watercolours
Member
 
Join Date: Feb 2004
Posts: 92
help with play2 pause script

i decided to use play2pause script modified by frisbeemonkey (since i use play and pause overlays). but i have a problem. at the startup of the winamp, only pause overlay is visible and i can't play a song. but if i play a song via double clicking on playlist or if i switch to my skin after i start a song in another skin everything becomes ok. the problem is just at the startup of the program. normally, if it is already open, i can pause, stop, continue and do anything as it should be. but only i can't let a song play when i first run the winamp with my skin. my winamp is 5.03 and here's the script (i didn't change a line):
//-----------------------------------------------------------------------------
// play2pause.m
//
// Example of a Play/Pause Script
// created by Gonzotek & Vica.
//
// modified by FrisbeeMonkey
//-----------------------------------------------------------------------------

// USING THIS SCRIPT:
//*****************************************************************************
// 1. Define play and pause buttons in your XML.
// 2. Make sure their ids are "Play" and "Pause"
// 3. Copy this script (and play2pause.maki) to your scripts folder.
// 4. If you don't have play2pause.maki, compile this script.
// 5. Add this line to the group that contains your play and pause buttons:
// <script id="play2pause" file="scripts/play2pause.maki"/>
// 6. Refresh your skin(F5) and try it out.
//*****************************************************************************

// never forget to include std.mi
#include "../../../lib/std.mi"

//declares global variables for use in script
Global Group ButtonsGrp;
Global Button Play, Pause;
Global Layer PlayOverlay, PauseOverlay;
Global Boolean useOverlay;

//when the script is loaded, do this
System.onScriptLoaded() {

//gets the group that has the objects we want
ButtonsGrp = getScriptGroup();
useOverlay = 1;
//gets the "id" tags as defined in player-normal-group.xml for the two buttons
Pause = ButtonsGrp.getObject("Pause");
Play = ButtonsGrp.getObject("Play");
PauseOverlay = ButtonsGrp.getObject("PauseButtonOverlay");
if (PauseOverlay == NULL) useOverlay = 0;
PlayOverlay = ButtonsGrp.getObject("PlayButtonOverlay");

// hides both buttons until playing status is determined
Pause.hide();
Play.hide();
if (useOverlay){
PauseOverlay.hide();
PlayOverlay.hide();
}
//determines whether Winamp is playing or paused, then shows the buttons accordingly
if (getplayitemstring() != "") {
Pause.show();
if (useOverlay) PauseOverlay.show();
} else {
Play.show();
if (useOverlay) PlayOverlay.show();
}
}//end onScriptLoaded()


// If winamp is playing, hides the play button and shows pause
System.onPlay()
{
Play.hide();
Pause.show();
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
}//end onPlay()


// If winamp is paused, hides pause and shows play
System.onPause()
{
Play.show();
Pause.hide();
if (useOverlay) {
PlayOverlay.show();
PauseOverlay.hide();
}
}//end onPause()

// If winamp is stopped, shows play and hides pause
System.onStop()
{
Play.show();
Pause.hide();
if (useOverlay) {
PlayOverlay.show();
PauseOverlay.hide();
}
}//end onStop()


// After paused and button is again pressed starting play, will show pause and hide play
System.onResume()
{
Play.hide();
Pause.show();
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
watercolours is offline   Reply With Quote
Old 6th November 2004, 16:41   #2
SLoB
Major Dude
 
SLoB's Avatar
 
Join Date: Jul 2003
Location: UK
Posts: 1,316
the answer to this has been said loads of times, check the maki thread (last few pages it think)

you shouldnt use getplayitemstring as its not accurate, use
System.getStatus();

for example
// Determines whether Winamp is playing or paused, then shows the buttons accordingly
Int iGetMainStatus = System.getStatus();

//either paused or stopped
if (iGetMainStatus==STATUS_PAUSED || iGetMainStatus==STATUS_STOPPED) {
btnPause.hide();
btnPlay.show();
}
else {
//must be playing
btnPlay.hide();
btnPause.show();
}

use the search button
SLoB is offline   Reply With Quote
Old 7th November 2004, 21:10   #3
watercolours
Member
 
Join Date: Feb 2004
Posts: 92
hi again,
i found the related topic and found the fixed script. though the script runs fine, i have problem with the buttons. i use overlays for both play and pause buttons. since the fixed version didn't mention any PlayButtonOverlay thing, i used
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
like stuff from frisbeemonkey accordingly. Actually here is the maki i tried to write (sorry i don't know to write them in color as you do).

---------------------------------------------------------------
//-----------------------------------------------------------------------------
// play2pause.m
//
// Example of a Play/Pause Script
// created by Gonzotek & Vica.
//
// modified by FrisbeeMonkey
//-----------------------------------------------------------------------------

// USING THIS SCRIPT:
//*****************************************************************************
// 1. Define play and pause buttons in your XML.
// 2. Make sure their ids are "Play" and "Pause"
// 3. Copy this script (and play2pause.maki) to your scripts folder.
// 4. If you don't have play2pause.maki, compile this script.
// 5. Add this line to the group that contains your play and pause buttons:
// <script id="play2pause" file="scripts/play2pause.maki"/>
// 6. Refresh your skin(F5) and try it out.
//*****************************************************************************

// never forget to include std.mi
#include "../../../lib/std.mi"

//declares global variables for use in script
Global Group ButtonsGrp;
Global Button Play, Pause;
Global Layer PlayOverlay, PauseOverlay;
Global Boolean useOverlay;

//when the script is loaded, do this
System.onScriptLoaded() {


//gets the "id" tags as defined in player-normal-group.xml for the two buttons
Pause = ButtonsGrp.getObject("Pause");
Play = ButtonsGrp.getObject("Play");
PauseOverlay = ButtonsGrp.getObject("PauseButtonOverlay");
if (PauseOverlay == NULL) useOverlay = 0;
PlayOverlay = ButtonsGrp.getObject("PlayButtonOverlay");

// hides both buttons until playing status is determined
Pause.hide();
Play.hide();
if (useOverlay){
PauseOverlay.hide();
PlayOverlay.hide();
}
if (system.getStatus() == 1) {
pause.show();
play.hide();
} else {
pause.hide();
play.show();
}

//determines whether Winamp is playing or paused(or stopped), then shows the buttons accordingly
//system.getstatus returns -1 for paused, 0 for stopped, 1 for playing
if (system.getstatus() > 0) {
Pause.show();
Play.hide();
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
} else {
Play.show();
Pause.hide();
if (useOverlay) {
PlayOverlay.show();
PauseOverlay.hide();
}
}
}//end onScriptLoaded()


// If winamp is playing, hides the play button and shows pause
System.onPlay()
{
Play.hide();
Pause.show();
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
}//end onPlay()


// If winamp is paused, hides pause and shows play
System.onPause()
{
Play.show();
Pause.hide();
if (useOverlay) {
PlayOverlay.show();
PauseOverlay.hide();
}
}//end onPause()

// If winamp is stopped, shows play and hides pause
System.onStop()
{
Play.show();
Pause.hide();
if (useOverlay) {
PlayOverlay.show();
PauseOverlay.hide();
}
}//end onStop()


// After paused and button is again pressed starting play, will show pause and hide play
System.onResume()
{
Play.hide();
Pause.show();
if (useOverlay) {
PlayOverlay.hide();
PauseOverlay.show();
}
}
--------------------------------------------------------------
and the problem... the script functions perfectly, no problem about that. in situations when play will show and pause will hide, there is no problem also. but in situations when play will hide and pause will show, both of them shows. so pause and play overlap. in the old script (with overlay stuff but unfixed) this problem hasn't occurred. i also tried the simple fixed version (without overlay stuff) at page14 in maki cheats section but nothing has changed.
can someone help?
watercolours is offline   Reply With Quote
Old 12th November 2004, 17:27   #4
watercolours
Member
 
Join Date: Feb 2004
Posts: 92
i did it. it's a miracle. really. some moderator can lock this topic now. thank you everybody.
watercolours is offline   Reply With Quote
Old 12th November 2004, 21:11   #5
carlosp
Major Dude
 
carlosp's Avatar
 
Join Date: Nov 2002
Location: Hamburg, Germany
Posts: 1,312
*locked*
carlosp is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump