Clear Now Playing Button

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Clear Now Playing Button

Post by Benn » Fri Aug 08, 2008 10:25 am

Hey, I would like to have a button on the toolbar which clears the now playing list, as opposed to right clicking now playing > list > clear. (and yes, I am that lazy) I am aware this is a fairly simple script, but having no experience whatsoever I do not know where to start, so any help would be greatly appreciated.

Thanks in advance, Benn.

botijo
Posts: 415
Joined: Fri Dec 07, 2007 3:20 am
Location: Ireland

Re: Clear Now Playing Button

Post by botijo » Fri Aug 08, 2008 1:17 pm

Hi, Benn,
you better have a look in MM wiki. It will get you started. As a hint, you are looking for the SDBPlayer.PlaylistClear method.
Regards.

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Clear Now Playing Button

Post by Benn » Fri Aug 08, 2008 1:24 pm

Thanks Botijo, that'll be my project tomorrow. :)

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Clear Now Playing Button

Post by Benn » Sun Aug 10, 2008 7:06 am

Code: Select all

Clear_Now_Playing_Button

MediaMonkey Script

by Benn


Option Explicit

Sub OnStartup
  'add toolbar button
  Dim but : Set but = SDBPlayer.PlaylistClear("CNP-Button")
  If but Is Nothing Then
    Set but = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
    but.Caption = "Clear Now Playing"
    but.IconIndex = SDB.RegisterIcon("Scripts\AADJ.ico",0)
    but.UseScript = SDB.ApplicationPath&"Scripts\clear_now_playing.vbs"
    but.OnClickFunc = "Clear"
    but.Visible = SDB.IniFile.BoolValue("AutoAlbumDJ","Toolbar") 
    Set SDB.Objects("Clear_Now_Playing") = but
  End If
End Sub
This is my first attempt (ever). I had to use an already existing icon as I have no others, but where else am I going wrong?

1. There is no toolbar button
2. When I run it from the menu, I get the error message:
"Error #1024 - Mircosoft VBScript compilation error
Expected Statement
Option Explicit
File: C:\Program Files\Mediamonkey\Scriptszclear_now_playing.vbs, Line 8; column 0"

I have also just realised I may have posted this in the wrong section, my apologies. Thank you for any help you can offer.

botijo
Posts: 415
Joined: Fri Dec 07, 2007 3:20 am
Location: Ireland

Re: Clear Now Playing Button

Post by botijo » Sun Aug 10, 2008 7:33 am

I would say you forgot to comment your initial comments! See a probably fixed code:

Code: Select all

'Clear_Now_Playing_Button
'
'MediaMonkey Script
'
'by Benn
'
'
Option Explicit

Sub OnStartup
  'add toolbar button
  Dim but : Set but = SDBPlayer.PlaylistClear("CNP-Button")
  If but Is Nothing Then
    Set but = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
    but.Caption = "Clear Now Playing"
    but.IconIndex = SDB.RegisterIcon("Scripts\AADJ.ico",0)
    but.UseScript = SDB.ApplicationPath&"Scripts\clear_now_playing.vbs"
    but.OnClickFunc = "Clear"
    but.Visible = SDB.IniFile.BoolValue("AutoAlbumDJ","Toolbar") 
    Set SDB.Objects("Clear_Now_Playing") = but
  End If
End Sub
I did not run the code, so it might not work!

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Clear Now Playing Button

Post by Benn » Sun Aug 10, 2008 8:12 am

Ahh I see, I didnt know that was important. Tried your fix, but now get the error:

"Error #13 - Microsoft VBScript runtime error
Type Mismatch: 'Clear_Now_Playing'
File ............. Line 1, Column 0"

Still with no toolbar button. (although running it from tools is still quicker than the normal method :P

Thanks botijo :)

botijo
Posts: 415
Joined: Fri Dec 07, 2007 3:20 am
Location: Ireland

Re: Clear Now Playing Button

Post by botijo » Sun Aug 10, 2008 8:44 am

There are some strange things happening in your first lines:

Code: Select all

Dim but : Set but = SDBPlayer.PlaylistClear("CNP-Button")
First, you need to define SDBPlayer. That is done via...

Code: Select all

Dim SDBPlayer;
set SDBPlayer=SDB.Player;
Then, SDBPlayer.PlaylistClear is a subroutine with no arguments, so I wonder what you are trying to do here. The way it works, you want to create a button called but, and that is what you are doing after. You should not be able to assign a fuction directly to but (as what is but at that point?), the second approach looks like it could work.
As for the rest, I would try to call SDB.Player.PlaylistClear directly from the button. That might or might not work. So try it!
Regards.

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Clear Now Playing Button

Post by Benn » Sun Aug 10, 2008 9:17 am

I am really starting to get lost now. :( Having no previous experience, I read all of the other toolbar related scripts I have and tried to replicate them onto my one. So now when it comes to the specifics I do not understand. Thank you for all the hints you have tried to give me, but I now feel that I am out of my depth.. I may head over to the scripts forum and request this one though; it shouldn't take one of you experts too long :P

Thanks again, Benn


Grey
Posts: 2
Joined: Thu Nov 27, 2008 6:38 pm

Re: Clear Now Playing Button

Post by Grey » Sat Nov 29, 2008 12:01 am

Hey....

I love the Clear Button. It does the job. But.... the music of the current song playing continues.

Any chance of a patch that would also stop the music sound when depressing the Clear Button?

Grey

Peke
Posts: 11205
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: Clear Now Playing Button

Post by Peke » Sat Nov 29, 2008 9:20 pm

Sure just add:
SDB.Player.Stop

Where ever you need that Player stops.
Best regards,
Pavle
MediaMonkey lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add Images to forum

Post Reply