by Steegy » Fri Nov 04, 2005 9:39 am
Hello
Here's a simple script (the first vbs that I made) that adds hotkeys to MediaMonkey so you can let it play songs based on Genre, Playlist, Mood, ... very easily.
You can download it from
http://home.tiscali.be/ruben.castelein/ ... s_v1.0.vbs
Just put it in the MediaMonkey\Scripts\Auto folder and (re)start MM.
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: Play Hotkeys v1.0
' DESCRIPTION:
' Predefines shortcuts to start playing songs of a specific Genre, from a
' specific Playlist, or with specific Song Information (Tempo, Mood, Quality, ...)
'
' AUTHOR: Steegy aka RC
' DATE : 19.10.2005
'
' NOTE: Idea taken from Pekes "Predefined Genre Script v1.0"
'
' INSTALL:
' - If wanted, change defaults in the "Variable Configuration" section of this file
' - Copy script to MM directory scripts\auto
'
' USE:
' - Press key CTRL 0 ...5 (default) to start playing the wanted genre/playlist/...
'
'==========================================================================
'==========================================================================
' Variable Definition (Do Not Change)
'==========================================================================
Dim EGenre
Dim Counter
'==========================================================================
' Variable Configuration (EDIT HERE IF YOU WANT)
'==========================================================================
'The code has some "sharp edges" (it's messy sometimes, especcially variable names), I'm sorry for that.
Sub AddItemsToMenu
'Change genres According to your needs
'(The number is the IconIndex value)
' Playlist 17 <= OK ==> Playlists
' "Notes" 14 <= OK ==> Song Information (Tempo, Mood, Quality, ...)
' Genre 58 <= OK ==> Genres
' Artist 60
' Rating star 64
'(The Y/N means Yes or No and sets the use of Shift, Crtl, Alt in the HotKey)
AddItemToMenu("58|NYN|Trance")
AddItemToMenu("58|NYN|Dance")
AddItemToMenu("58|NYN|Rock")
AddItemToMenu("58|NYN|Pop")
AddItemToMenu("58|NYN|Disco")
AddItemToMenu("14|NYN|Party")
AddItemToMenu("14|NYN|Rustig en Traag")
AddItemToMenu("17|NYN|Zachte Trance")
End Sub
'==========================================================================
' MediaMonkey On Start Procedure
'==========================================================================
Sub OnStartup
Counter = 0
SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit,0,0
Set EGenre = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0)
EGenre.caption = "Play Hotkeys"
EGenre.IconIndex = 58
EGenre.useScript = Script.ScriptPath
AddItemsToMenu
End Sub
Sub AddItemToMenu(Str_Item)
Counter = Counter + 1
Dim GenreA
Set GenreA = SDB.UI.AddMenuItem(EGenre,0,0)
GenreA.Caption = Right(Str_Item,Len(Str_Item)-7)
GenreA.OnClickFunc = "PlayCategory"
GenreA.UseScript = Script.ScriptPath
GenreA.IconIndex = Left(Str_Item,2)
GenreA.ShortCut = ShortCut(Str_Item)&Counter
End Sub
Function ShortCut(Caption)
ShortCut = ""
If Mid(Caption,4,1)="Y" Then
ShortCut = ShortCut&"Shift+"
End if
If Mid(Caption,5,1)="Y" Then
ShortCut = ShortCut&"Ctrl+"
End if
If Mid(Caption,6,1)="Y" Then
ShortCut = ShortCut&"Alt+"
End if
End Function
Sub PlayCategory(Item)
SDB.Player.PlaylistClear
Select Case Item.IconIndex
Case 58:
PlayGenre(Item.Caption)
Case 14:
PlayInfoInt(Item.Caption)
Case 17:
PlayPlaylist(Item.Caption)
Case Else:
SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
End Select
SDB.Player.Next
SDB.Player.Play
End Sub
'==========================================================================
' Adding the specified category to the Now Playing playlist
'==========================================================================
Sub PlayInfoInt(Name)
Dim MyInfoNumber
Set MyInfoNumber = SDB.Database.OpenSQL("SELECT Lists.ID FROM Lists WHERE TextData = '" & Name & "'")
If Not MyInfoNumber.EOF Then
Dim MySongNumber
Set MySongNumber = SDB.Database.OpenSQL("SELECT AddSongInfoInt.IDSong FROM AddSongInfoInt WHERE AddSongInfoInt.IntData = " & MyInfoNumber.StringByIndex(0))
While Not MySongNumber.EOF
SDB.Player.PlaylistAddTrack(SDB.Database.QuerySongs("AND Songs.ID = " & MySongNumber.StringByIndex(0)).Item)
MySongNumber.Next
WEnd
Else
SDB.MessageBox "PlayHotkeys: The specified song information doesn't exist!", mtError, Array(mbOk)
End If
End Sub
Sub PlayPlaylist(Playlist)
Dim MyPlaylist
Set MyPlaylist = SDB.PlaylistByTitle(Playlist)
If Not MyPlaylist.Title = "" Then
SDB.Player.PlaylistAddTracks(MyPlaylist.Tracks)
Else
SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
End If
End Sub
Sub PlayGenre(Genre)
Dim MyGenreNumber
Set MyGenreNumber = SDB.Database.OpenSQL("SELECT Genres.IDGenre FROM Genres WHERE Genres.GenreName = '" & Genre & "'")
If Not MyGenreNumber.EOF Then
MyGenreNumber = MyGenreNumber.StringByIndex(0)
Dim MyTrack
Set MyTrack = SDB.Database.QuerySongs("AND Songs.Genre = " & MyGenreNumber)
While Not MyTrack.EOF
SDB.Player.PlaylistAddTrack(MyTrack.Item)
MyTrack.Next
WEnd
Else
SDB.MessageBox "PlayHotkeys: The specified genre doesn't exist!", mtError, Array(mbOk)
End If
End Sub
Cheers
Steegy (aka RC)
Hello
Here's a simple script (the first vbs that I made) that adds hotkeys to MediaMonkey so you can let it play songs based on Genre, Playlist, Mood, ... very easily.
You can download it from [url]http://home.tiscali.be/ruben.castelein/filestore/PlayHotkeys_v1.0.vbs[/url]
Just put it in the MediaMonkey\Scripts\Auto folder and (re)start MM.
[code]'==========================================================================
'
' MediaMonkey Script
'
' NAME: Play Hotkeys v1.0
' DESCRIPTION:
' Predefines shortcuts to start playing songs of a specific Genre, from a
' specific Playlist, or with specific Song Information (Tempo, Mood, Quality, ...)
'
' AUTHOR: Steegy aka RC
' DATE : 19.10.2005
'
' NOTE: Idea taken from Pekes "Predefined Genre Script v1.0"
'
' INSTALL:
' - If wanted, change defaults in the "Variable Configuration" section of this file
' - Copy script to MM directory scripts\auto
'
' USE:
' - Press key CTRL 0 ...5 (default) to start playing the wanted genre/playlist/...
'
'==========================================================================
'==========================================================================
' Variable Definition (Do Not Change)
'==========================================================================
Dim EGenre
Dim Counter
'==========================================================================
' Variable Configuration (EDIT HERE IF YOU WANT)
'==========================================================================
'The code has some "sharp edges" (it's messy sometimes, especcially variable names), I'm sorry for that.
Sub AddItemsToMenu
'Change genres According to your needs
'(The number is the IconIndex value)
' Playlist 17 <= OK ==> Playlists
' "Notes" 14 <= OK ==> Song Information (Tempo, Mood, Quality, ...)
' Genre 58 <= OK ==> Genres
' Artist 60
' Rating star 64
'(The Y/N means Yes or No and sets the use of Shift, Crtl, Alt in the HotKey)
AddItemToMenu("58|NYN|Trance")
AddItemToMenu("58|NYN|Dance")
AddItemToMenu("58|NYN|Rock")
AddItemToMenu("58|NYN|Pop")
AddItemToMenu("58|NYN|Disco")
AddItemToMenu("14|NYN|Party")
AddItemToMenu("14|NYN|Rustig en Traag")
AddItemToMenu("17|NYN|Zachte Trance")
End Sub
'==========================================================================
' MediaMonkey On Start Procedure
'==========================================================================
Sub OnStartup
Counter = 0
SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit,0,0
Set EGenre = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0)
EGenre.caption = "Play Hotkeys"
EGenre.IconIndex = 58
EGenre.useScript = Script.ScriptPath
AddItemsToMenu
End Sub
Sub AddItemToMenu(Str_Item)
Counter = Counter + 1
Dim GenreA
Set GenreA = SDB.UI.AddMenuItem(EGenre,0,0)
GenreA.Caption = Right(Str_Item,Len(Str_Item)-7)
GenreA.OnClickFunc = "PlayCategory"
GenreA.UseScript = Script.ScriptPath
GenreA.IconIndex = Left(Str_Item,2)
GenreA.ShortCut = ShortCut(Str_Item)&Counter
End Sub
Function ShortCut(Caption)
ShortCut = ""
If Mid(Caption,4,1)="Y" Then
ShortCut = ShortCut&"Shift+"
End if
If Mid(Caption,5,1)="Y" Then
ShortCut = ShortCut&"Ctrl+"
End if
If Mid(Caption,6,1)="Y" Then
ShortCut = ShortCut&"Alt+"
End if
End Function
Sub PlayCategory(Item)
SDB.Player.PlaylistClear
Select Case Item.IconIndex
Case 58:
PlayGenre(Item.Caption)
Case 14:
PlayInfoInt(Item.Caption)
Case 17:
PlayPlaylist(Item.Caption)
Case Else:
SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
End Select
SDB.Player.Next
SDB.Player.Play
End Sub
'==========================================================================
' Adding the specified category to the Now Playing playlist
'==========================================================================
Sub PlayInfoInt(Name)
Dim MyInfoNumber
Set MyInfoNumber = SDB.Database.OpenSQL("SELECT Lists.ID FROM Lists WHERE TextData = '" & Name & "'")
If Not MyInfoNumber.EOF Then
Dim MySongNumber
Set MySongNumber = SDB.Database.OpenSQL("SELECT AddSongInfoInt.IDSong FROM AddSongInfoInt WHERE AddSongInfoInt.IntData = " & MyInfoNumber.StringByIndex(0))
While Not MySongNumber.EOF
SDB.Player.PlaylistAddTrack(SDB.Database.QuerySongs("AND Songs.ID = " & MySongNumber.StringByIndex(0)).Item)
MySongNumber.Next
WEnd
Else
SDB.MessageBox "PlayHotkeys: The specified song information doesn't exist!", mtError, Array(mbOk)
End If
End Sub
Sub PlayPlaylist(Playlist)
Dim MyPlaylist
Set MyPlaylist = SDB.PlaylistByTitle(Playlist)
If Not MyPlaylist.Title = "" Then
SDB.Player.PlaylistAddTracks(MyPlaylist.Tracks)
Else
SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
End If
End Sub
Sub PlayGenre(Genre)
Dim MyGenreNumber
Set MyGenreNumber = SDB.Database.OpenSQL("SELECT Genres.IDGenre FROM Genres WHERE Genres.GenreName = '" & Genre & "'")
If Not MyGenreNumber.EOF Then
MyGenreNumber = MyGenreNumber.StringByIndex(0)
Dim MyTrack
Set MyTrack = SDB.Database.QuerySongs("AND Songs.Genre = " & MyGenreNumber)
While Not MyTrack.EOF
SDB.Player.PlaylistAddTrack(MyTrack.Item)
MyTrack.Next
WEnd
Else
SDB.MessageBox "PlayHotkeys: The specified genre doesn't exist!", mtError, Array(mbOk)
End If
End Sub [/code]
Cheers
Steegy (aka RC)