Thread: Resurgence-Skin
View Single Post
Old 27th January 2007, 17:30   #11
hammerhead
The Shark
(Forum King)
 
hammerhead's Avatar
 
Join Date: Jul 2002
Posts: 2,537
Send a message via AIM to hammerhead
Quote:
Originally posted by eagle3386
Guys, this is absolutely strange.. As a programmer, I already did a search inside the skinning docs and found that function.. - Though, after compiling and reselecting it in the skin browser, there was no change..
Right now, I did just the same and everything works..

Also the rounding thing is gone (dividing by "2.55" rounds that number perfectly, although I don't know why.. *LOL*)..


Though, there's one thing I don't understand. While adjusting the volume, the notifier comes up with a "slide-in" from the bottom. But this sliding movement is interrupted everytime I press the keys for the volume change again. Is there any chance that the notifier moves on although I press the keys while it is moving?
yeah, the rounding thing works because volume (and pretty much all skin-relevant properties) is measure in byte-form (0-255).

adjusted the script slightly, now it should be a little smoother:

PHP Code:
#include "std.mi"
#include "attribs.m"

Function reset();
Function 
createNotifier();
Function 
showNotifier(Int w);
Function 
onNext();

Function 
Int fillNextTrackInfo(String corneroverride);
Function 
Int fillCustomInfo(String customstring);

Function 
checkPref(int bypassfs);

Global 
Container notifier_container;
Global 
Layout notifier_layout;
Global 
Timer notifier_timerstarttimer;
Global 
String last_autotitle;
Global 
slider holdtime;
Global 
animatedlayer holdtimeanim;

Global 
boolean notifierOut false;

// ------------------------------------------------------------------------------
// init
// ------------------------------------------------------------------------------
System.onScriptLoaded() {
  
initAttribs();
  
notifier_timer = new Timer;
  
starttimer = new Timer;
  
starttimer.setdelay(1);
  
starttimer.start();
}
starttimer.ontimer() {
  
starttimer.stop();
      
Group c System.GetContainer("config").GetLayout("normal").FindObject("configpage").FindObject("cfp2");
    
holdtime c.GetObject("set.nhold");
    
holdtimeanim c.GetObject("holdanim");
    
holdtimeanim.gotoFrame(holdtime.getposition() / 10000 holdtimeanim.getlength() - 1);
}
// ------------------------------------------------------------------------------
// shutdown
// ------------------------------------------------------------------------------
System.onScriptUnloading() {
  
delete notifier_timer;
  
delete starttimer;
}

// ------------------------------------------------------------------------------
// called by the system when the global hotkey for notification is pressed
// ------------------------------------------------------------------------------
System.onShowNotification() {
  if (
checkPref(1)) return;
  
createNotifier();
  
String str;
  if (
getStatus() == STATUS_PLAYINGstr "Playing";
  if (
getStatus() == STATUS_PAUSEDstr "Playback Paused";
  if (
getStatus() == STATUS_STOPPEDstr "Playback Stopped";
  
showNotifier(fillNextTrackInfo(str));
  
complete// prevents other scripts from getting the message
  
return 1// tells anybody else that might watch the returned value that, yes, we implemented that
}

// ------------------------------------------------------------------------------
// called by the system when the title for the playing item changes, this could be the result of the player
// going to the next track, or of an update in the track title
// ------------------------------------------------------------------------------
System.onTitleChange(String newtitle) {
  if (
last_autotitle == newtitle) return;
  if (
StrLeft(newtitle1) == "[") {
    if (
StrLeft(newtitle7) == "[Buffer" ||
        
StrLeft(newtitle4) == "[ICY") return;
  }
  
last_autotitle newtitle;
  
onNext();
}

// ------------------------------------------------------------------------------
// called by the system when the user clicks the next button
// ------------------------------------------------------------------------------
onNext() {
  if (
checkPref(0)) return;
  
createNotifier();
  
showNotifier(fillNextTrackInfo(""));
}

// ------------------------------------------------------------------------------
// called by the system when the user clicks the play button
// ------------------------------------------------------------------------------
System.onPlay() {
  if (
checkPref(0)) return;
  
createNotifier();
  
showNotifier(fillNextTrackInfo("Playing"));
}


System.OnVolumeChanged(int newVol)
{
  if (
checkPref(0)) return;
 
 
  if (
notifierOut)
  {
    
Group p notifier_layout;
    
Text endofplayback p.findObject("endofplayback");

    if (
endofplayback)
      
endofplayback.setText("Volume: " integerToString(newVol/2.55) + "%");
  }
  else
  {
    
createNotifier();
    
showNotifier(fillCustomInfo("Volume: " integerToString(newVol/2.55) + "%"));
  }
}

// ------------------------------------------------------------------------------
// called by the system when the user clicks the pause button
// ------------------------------------------------------------------------------
System.onPause() {
  if (
checkPref(0)) return;
  
createNotifier();
  
showNotifier(fillCustomInfo("Playback Paused"));
}

// ------------------------------------------------------------------------------
// called by the system when the user clicks the pause button again
// ------------------------------------------------------------------------------
System.onResume() {
  if (
checkPref(0)) return;
  
createNotifier();
  
showNotifier(fillNextTrackInfo("Resuming Playback"));
}

// ------------------------------------------------------------------------------
// called by the system when the user clicks the play button
// ------------------------------------------------------------------------------
System.onStop() {
  if (
checkPref(0)) return;
  
createNotifier();
  
showNotifier(fillCustomInfo("End of Playback"));
}

// ------------------------------------------------------------------------------
// checks if we should display anything
// ------------------------------------------------------------------------------
Int checkPref(int bypassfs) {
  if (!
bypassfs && notifier_disablefullscreen_attrib.getData() == "1" && isVideoFullscreen()) return 1;
  if (
notifier_never_attrib.getData() == "1") return 1;
  if (
notifier_minimized_attrib.getData() == "1" && !isMinimized()) return 1;
  if (
notifier_windowshade_attrib.getData() == "1") {
    if (
isMinimized()) return 0;
    
Container c getContainer("main");
    if (!
c) return 1;
    
Layout l c.getCurLayout();
    if (!
l) return 1;
    if (
l.getId() != "player.main.titlebar" && l.getId() != "player.main.shade") return 1;
  }
  return 
0;
}

// ------------------------------------------------------------------------------
// fade in/out completed
// ------------------------------------------------------------------------------
notifier_layout.onTargetReached() {
  
int y notifier_layout.getTop();
  if (
getViewportHeight() + getViewportTop()) {
    
notifier_timer.setDelay(StringToInteger(notifier_holdtime_attrib.getData()));
    
notifier_timer.start();
  }
  else if (
>= getViewportHeight() + getViewportTop()) {
    
reset();
  }
}

// ------------------------------------------------------------------------------
// hold time elapsed
// ------------------------------------------------------------------------------
notifier_timer.onTimer() {
  
stop();
  
notifier_layout.setTargetY(getViewportHeight() + getViewportTop() + notifier_layout.getHeight());
  
notifier_layout.setTargetSpeed(1);
  
notifier_layout.gotoTarget();

  
notifierOut false;
}

// ------------------------------------------------------------------------------
// when notifier is clicked, bring back the app from minimized state if its minimized and focus it
// ------------------------------------------------------------------------------
notifier_layout.onLeftButtonDown(int xint y) {
  
notifier_timer.stop();
  
notifier_layout.cancelTarget();
  
reset();
  
restoreApplication();
  
activateApplication();
}

// ------------------------------------------------------------------------------
// close the notifier window, destroys the container automatically because it's dynamic
// ------------------------------------------------------------------------------
reset() {
  
notifier_timer.stop();
  
notifier_layout.resize(0,0,0,0);
  
notifier_container.close();
  
notifier_container NULL;
  
notifier_layout NULL;
}

// ------------------------------------------------------------------------------
createNotifier() {
  if (
notifier_container == NULL) {
    
notifier_container newDynamicContainer("notifier");
    if (!
notifier_container) return; // reinstall duh!
    
if (isDesktopAlphaAvailable())
      
notifier_layout notifier_container.getLayout("desktopalpha");
    else
      
notifier_layout notifier_container.getLayout("normal");
    if (!
notifier_layout) return; // reinstall twice, man
  
} else {
    
notifier_layout.cancelTarget();
    
notifier_timer.stop();
  }
}

// ------------------------------------------------------------------------------
showNotifier(int w) {
  
notifierOut true;

  
int x getViewportWidth() + getViewportLeft() - 5;
  
85;
  if(
notifier_whichsideleft_attrib.getData() == "1"getViewportLeft() + 5;
  if(
notifier_whichsideright_attrib.getData() == "1"getViewportWidth() + getViewportLeft() - 5;
  
int y getViewportHeight() + getViewportTop() - notifier_layout.getHeight() - 5;

  if (!
notifier_layout.isVisible()) {
      
notifier_layout.resize(xnotifier_layout.getHeight() + 5wnotifier_layout.getHeight());
  }
  
notifier_layout.show();
  
notifier_layout.setAlpha(255);
  
notifier_layout.setTargetX(x);
  
notifier_layout.setTargetW(w);
  
notifier_layout.setTargetY(y);
  
notifier_layout.setTargetH(notifier_layout.getHeight());
  
notifier_layout.setTargetSpeed(2);
  
notifier_layout.gotoTarget();
}
// ------------------------------------------------------------------------------
Int fillNextTrackInfo(String corneroverride) {
  
Int maxv 0;
  
Int stream 0;
  
Group p notifier_layout;
  
Text plentry p.findObject("plentry");
  
Text nexttrack p.findObject("nexttrack");
  
Text _title p.findObject("title");
  
Text album p.findObject("album");
  
Text artist p.findObject("artist");
  
Text endofplayback p.findObject("endofplayback");

  if (
StrLeft(getPlayItemString(), 7) == "http://"stream 1;

  if (
endofplaybackendofplayback.settext("");

  if (
plentry) { plentry.setText(integerToString(getPlaylistIndex()+1)+"/"+integerToString(getPlaylistLength())); plentry.show(); }
  if (
nexttrack) {
    if (
corneroverride == "") {
      if (!
stream) {
        if (!
isVideo())
          
nexttrack.setText("New track");
        else
          
nexttrack.setText("New video");
      }
      else 
nexttrack.setText("On air");
    } else 
nexttrack.setText(corneroverride);
    
nexttrack.show();
  }
  if (
_title) {
    
String str;
    if (!
stream) {
      
_title.setXmlParam("ticker""0");
      
_title.setXmlParam("display""");
      
str getPlayitemMetaDataString("title"); 
      if (
str == ""str getPlayitemDisplayTitle();
      
String l getPlayItemMetaDataString("length");
      if (
!= "") {
        
str += " (" integerToTime(stringtointeger(l)) + ")";
      }
      
_title.setText(str);
    } else {
      
_title.setXmlParam("ticker""1");
      
_title.setXmlParam("display""songtitle");
      
_title.setText("");
    }
    
_title.show(); 
  }
  if (
artist) { 
    if (!
stream) {
      if (
isVideo())
        
artist.setText(""); 
      else
        
artist.setText(getPlayitemMetaDataString("artist")); 
    } else {
      if (
isVideo())
        
artist.setText("Internet TV"); 
      else
        
artist.setText("Internet Radio"); 
    }
    
artist.show(); 
  }
  if (
album) { 
    
String str;
    if (!
stream && !isVideo()) {
      
album.setXmlParam("display""");
      
str getPlayitemMetaDataString("album");
      
String l getPlayitemMetaDataString("track");
      if (
!= "" && != "-1"str += " (Track " ")";
      
album.setText(str); 
    } else {
      
album.setText("");
      
album.setXmlParam("display""songinfo");
    }
    
album.show(); 
  }
  
maxv artist.getAutoWidth();
  if (
maxv album.getAutoWidth()) maxv album.getAutoWidth();
  if (
maxv _title.getAutoWidth()) maxv _title.getAutoWidth();
  if (
maxv 128maxv 128;
  if (
maxv getViewportWidth()/4maxv getViewportWidth()/4;
  
  return 
maxv;
}

// ------------------------------------------------------------------------------
Int fillCustomInfo(String customtext) {
  
Group p notifier_layout;
  
Text plentry p.findObject("plentry");
  
Text nexttrack p.findObject("nexttrack");
  
Text _title p.findObject("title");
  
Text album p.findObject("album");
  
Text artist p.findObject("artist");
  
Text endofplayback p.findObject("endofplayback");

  if (
plentry) { plentry.hide(); }
  if (
nexttracknexttrack.hide();
  if (
_title) { _title.hide(); }
  if (
artist) { artist.hide(); }
  if (
album) { album.hide(); }

  if (
endofplayback) {
    
endofplayback.setText(customtext);
    
int aw endofplayback.getAutoWidth();
    
endofplayback.show();
    if (
aw 128)
      return 
aw;
  }
  return 
128;
}

holdtime.OnSetPosition(int x)
{
    
holdtimeanim.gotoFrame(10000 holdtimeanim.getlength() - 1);

yeah, maki is not the most logical thing at times, but it seems to work (usually )
hammerhead is offline   Reply With Quote