I've been primitively banging code around for a long day and am not getting anywhere (because I don't actually know what I'm doing!). So, I am going to reach out for some aid from the educated talents here. I think what I'm after is simple, but if I can't find an example of a similar script by others, then I'm almost just guessing.
Dockable panel I'm trying to generate:
Two buttons (potentially several), when pressed writes specific tags "King" & "Kong" to the TEMPO field.
Beside these buttons is a RADIO BUTTON pair;
one when selected (by default) causes the King/Kong button to write to the CURRENTLY PLAYING song.
The other when selected causes the King/Kong button to write to any SELECTED songs.
I'm hung up at the radio button action - but its a key piece of the practicality I'm after.
--((And while I'm posting, can anyone recommend a vbs editor that assists in MediaMonkey oriented code? I tried Admin Script Editor; but it seems like the syntax/etc that it helps to craft is slightly off from what MediaMonkey needs to see. I intend to get good at this fast, as I've found several other powerful programs I'm using also have implemented this scripting aspect, and man does it change everything! I love it.))--
I've been working from this basic framework, which I post in case I'm making some error from the getgo. Thanks for taking an interest:
Code: Select all
Dim Mnu, Pnl, Lbl, Lbl2
Sub OnStartup
Set UI = SDB.UI
Set Pnl = UI.NewDockablePersistentPanel("AddToTempo")
If Pnl.IsNew Then
Pnl.DockedTo = 3
Pnl.Common.Width = 250
End If
Pnl.Caption = "AddToTempo"
Script.RegisterEvent Pnl, "OnClose", "PnlClose"
Set Lbl = UI.NewLabel(Pnl)
Lbl.Autosize = False
Lbl.Multiline = True
Lbl.Common.SetRect 10, 10, Pnl.Common.Width - 20, Pnl.Common.Height - 20
Lbl.Common.Anchors = 15 '1+2+4+8
' ----------------------buttons------------------------------
Set Btn = UI.NewButton(Pnl)
Btn.Common.ControlName = "Btn"
Btn.Common.SetRect 9, 6, 34, 20
Btn.Caption = "KING"
Script.RegisterEvent Btn.Common, "OnClick", "BtnClick"
Set Btn = UI.NewButton(Pnl)
Btn.Common.ControlName = "Btn"
Btn.Common.SetRect 9, 6, 34, 20
Btn.Caption = "KONG"
Script.RegisterEvent Btn.Common, "OnClick", "BtnClick"
Dim RadioButton1 : Set RadioButton1 = SDB.UI.NewRadioButton(Pnl)
RadioButton1.Caption = "Selected Music"
RadioButton1.Common.SetRect 700, 3, 80, 17
RadioButton1.Common.ControlName = "choose1" ' not sure how to use this element
Script.RegisterEvent RadioButton1.Common, "OnClick", "MyAction1"
Dim RadioButton2 : Set RadioButton2 = SDB.UI.NewRadioButton(Pnl)
RadioButton2.Caption = "Now Playing"
RadioButton2.Checked = True
RadioButton2.Common.SetRect 700, 23, 80, 17
RadioButton2.Common.ControlName = "choose2"
Script.RegisterEvent RadioButton2.Common, "OnClick", "MyAction2" ' should this be OnChange?
' If Pnl.Common.ChildControl("Choose1").Checked Then -- use this avenue?
' ------------------------menu option-----------------
Set Sep = SDB.UI.AddMenuItemSep(SDB.UI.Menu_View, 0, 0)
Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View, 0, 0)
Mnu.Caption = "Add To Tempo"
Mnu.Shortcut = "Ctrl+Alt+Shift+3"
Mnu.Checked = Pnl.Common.Visible
Script.RegisterEvent Mnu, "OnClick", "ShowPanel"
Script.RegisterEvent SDB, "OnChangedSelection", "OnSelection"
End Sub
' -------------------------------panel actions ----------------------
Sub ShowPanel(Item)
Pnl.Common.Visible = Not Pnl.Common.Visible
Mnu.Checked = Pnl.Common.Visible
End Sub
Sub PnlClose(Item)
Mnu.Checked = False
End Sub
Sub OnSelection
End Sub
' -------------------------------Button action ----------------------
' use OnClick action?
' Sub MyAction1(Control)
' Dim objSongData
' Set objSongData = SDB.Player.CurrentSong ' for now playing
' End Sub
' Sub MyAction2(Control)
' Dim objSongData
' Set objSongData = SDB.Player.CurrentSongList ' for selected - should be SelectedSongList?
' If objSongData.Count = 0 Then
' Exit Sub
' End If
' End Sub
Sub BtnClick(Btn)
Dim objSongData, objSongList
Set objSongList = SDB.NewSongList
Set objSongData = SDB.Player.CurrentSong
' Use what-if to get action?
' If WHAT = WHAT Then -cant figure out how to tool this
' Set objSongData = SDB.Player.CurrentSong
' End If
' If WHAT = WHAT Then
' Set objSongData = SDB.Player.CurrentSongList -- should this be SelectedSongList?
' If objSongData.Count = 0 Then
' Exit Sub
' End If
' ----------------------------for multivalue TEMPO field -----------------
objSongList.Add(objSongData)
Dim StringTempo, StringNewTempo, StringAddTempo
StringTempo = objSongData.Tempo
StringAddTempo = "; " & Btn.Caption
If InStr(StringTempo, Btn.Caption) = 0 Then
StringNewTempo = StringTempo & StringAddTempo
objSongData.Tempo = StringNewTempo
objSonglist.UpdateAll
End If
End Sub