# Kill our actions
action.destroy nowplaying::advertise
action.destroy nowplaying::configure
-
+
# And finally our toolbar
toolbar.destroy nowplaying
-
+
# Done
}
%h->$setChecked($2)
return %h
}
-
+
constructor()
{
# first of all load the config
%l->$addMultiCellWidget(%gb,2,2,0,2)
%gb->$setTitle($tr("Other","nowplaying"))
%gb->$setOrientation(Vertical)
-
+
# and yet another set of children
@%hShareMedia = $this->$createCheckBox(%gb,$tr("Share Media","nowplaying"),%NowPlaying{"ShareMedia"})
# this child is composed of two children itself
%pb->$setText($tr("OK","nowplaying"))
%pb->$setMinimumWidth(80)
%l->$addWidget(%pb,4,1)
-
+
# invoke $okClicked() when this button is pressed
objects.connect %pb "clicked" $this "okClicked"
%l->$setRowStretch(3,10)
%l->$setColumnStretch(0,1)
}
-
+
okClicked()
{
# the ok button was clicked
nowplaying::core::saveconfig
delete $this
}
-
+
cancelClicked()
{
# just die ignoring all the changes
delete $this
}
-
+
showEvent()
{
# center us to screen
echo $tr("Seems that your media player is not playing at the moment (status:","nowplaying") $mediaplayer.status() ")"
return
}
-
+
# make sure that there is some target
if(($window.type != "channel") && ($window.type != "query"))
{
echo $tr("You can advertise the currently played media only on channels and queries","nowplaying")
return
}
-
+
# now get the media information from the mediaplayer module
# and build our advertisement string
%artist = $mediaplayer.artist
%clrbegin = ""
%clrend = ""
}
-
+
if(%NowPlaying{"BoldTitle"})
{
%bold = "$b"
} else {
%bold = ""
}
-
+
if((%artist != "") && (%title != ""))
{
# add a "null" control code to avoid the title
%position = $mediaplayer.position
%file = $mediaplayer.localfile
if(!$file.exists(%file))%file = ""
-
+
%info = ""
if((%year != "") && (%NowPlaying{"ShowYear"}))%info .= "[Year "%year"]"
%lh = $(%length / 3600000)
%lm = $((%length % 3600000) / 60000)
%ls = $((%length % 60000) / 1000)
-
+
if(%lh > 0)%infolength .= %lh":"
if(%lm < 10)%infolength .= "0"%lm":"
else %infolength .= %lm":"
%ph = $(%position / 3600000)
%pm = $((%position % 3600000) / 60000)
%ps = $((%position % 60000) / 1000)
-
+
if(%ph > 0)%infoposition .= %ph":"
if(%pm < 10)%infoposition .= "0"%pm":"
else %infoposition .= %pm":"
%info .= "["%infolength"]"
}
}
-
+
if((%file != "") && (%NowPlaying{"ShowFileSize"}))
{
%size = $file.size(%file)
}
%s = %nowplaying
-
+
if(%info != "")%s .= "" %info
-
+
# share the media if the user has requested it
if((%file != "") && (%NowPlaying{"ShareMedia"}))
{
%name .= $rand(9)
%name .= $rand(9)
sharedfile.add -t=%NowPlaying{"ShareTimeout"} -n=%name %file
-
+
%s .= "[$b/ctcp $me xdcc get %name$b to download]"
}
-
+
# and finally do the one-line command that this addon is all about :)
- me plays %s
+ me is playing %s
}
# create the actions so the user can access our functions via GUI