Can I create a custom pop-up display?
Can I create a custom pop-up display?
Hello,
I would like to create a custom pop-up display in a script (i.e. a message window that appears for a few seconds in specific cases, like the built-in pop-up display on track change). Is this possible? I didn't find info on this in the wiki.
Thanks!
Rycher
I would like to create a custom pop-up display in a script (i.e. a message window that appears for a few seconds in specific cases, like the built-in pop-up display on track change). Is this possible? I didn't find info on this in the wiki.
Thanks!
Rycher
-
- Posts: 14163
- Joined: Sat Oct 25, 2003 7:57 am
- Location: (Texas)
- Contact:
Re: Can I create a custom pop-up display?
you can use toaster in mm 3. there are instructions on how to set up toaster in the artwork forum. 
http://www.mediamonkey.com/forum/viewto ... it=toaster


http://www.mediamonkey.com/forum/viewto ... it=toaster

roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
-
- Posts: 401
- Joined: Thu Sep 27, 2007 4:19 pm
- Location: Connecticut
Re: Can I create a custom pop-up display?
I haven't used toaster so maybe this isn't what you're looking for but you could create a form with a single label and set the caption to the message. Then trigger a timer where you call a subroutine in which you set the form to be invisible. Just a thought.
Here's some code segment which you could add to your script which will pop (make visible) a panel for 5 seconds and then disappear (make invisible). The panel should be initially docked to the bottom of the window. You can then drag it to your
position of choice.
A side benefit of using this for a debug tool is that in the event you get into a loop you can exit MM. Using MSGBOX method the message boxes stack up and you can't exit MM - just end process with task manager.
Anywhere in your script where you wish the pop up to display, just call it like this:
Here's some code segment which you could add to your script which will pop (make visible) a panel for 5 seconds and then disappear (make invisible). The panel should be initially docked to the bottom of the window. You can then drag it to your
position of choice.
A side benefit of using this for a debug tool is that in the event you get into a loop you can exit MM. Using MSGBOX method the message boxes stack up and you can't exit MM - just end process with task manager.
Anywhere in your script where you wish the pop up to display, just call it like this:
Code: Select all
DebugDisplay("Your text/data goes here")
Code: Select all
Dim DebugPanel,DebugLabel ' Must be set globally - at the beginning of the script
Sub OnStartup
Main code here
Set DebugPanel = SDB.UI.NewDockablePersistentPanel("DebugPanel")
DebugPanel.Common.Visible=False
DebugPanel.Common.ControlName="DBugPanel"
If DebugPanel.IsNew Then
DebugPanel.DockedTo = 4
End If
DebugPanel.Common.SetRect 300,400,300,50
Set DebugLabel = SDB.UI.NewLabel(DebugPanel)
DebugLabel.Common.SetRect 10,5,250,21
Set DebugTimer = SDB.CreateTimer( 5000) ' 5 sec Debug Timer
DebugTimer.Enabled=False
Script.RegisterEvent DebugTimer, "OnTimer", "Event_DebugTimer"
End Sub
Sub Event_DebugTimer(x) ' Makes the panel invisible when the timer triggers and shuts off the timer
DebugPanel.Common.Visible=False
DebugTimer.Enabled=False
End Sub
Sub DebugDisplay(t)
DebugTimer.Enabled=False ' Cancel any timer currently triggered
DebugLabel.Caption=t ' Set the text to display
DebugPanel.Common.Visible=True ' Make it visible
DebugTimer.Enabled=True ' Start the timer
End Sub
Re: Can I create a custom pop-up display?
Neatto! I didn't think of that trick!
I haven't looked at toaster yet, but raybeau528 what you suggested is what I'm looking for... almost.
I want to do this while I'm in the miniplayer. It works if I have the full player, but nothing appears in miniplayer mode. I read the description of NewDockablePersistentPanel and it specifically says that it adds a panel to the main window. So it explained my situation.
I wanted to try NewPanel instead, but I don't know what to pass as the parent control. And I tried NewForm, but MM gives an error message: Object doesn't support this property or method: "SDB.UI.NewForm". I guess the wiki is ahead of the functionnality...
I don't have time right now, I'll dig more later to see if I can make it work with another type of window. But if you know what I should put as a parameter to NewPanel it will be greatly appreciated.
Thanks!
Rycher-
I haven't looked at toaster yet, but raybeau528 what you suggested is what I'm looking for... almost.
I want to do this while I'm in the miniplayer. It works if I have the full player, but nothing appears in miniplayer mode. I read the description of NewDockablePersistentPanel and it specifically says that it adds a panel to the main window. So it explained my situation.
I wanted to try NewPanel instead, but I don't know what to pass as the parent control. And I tried NewForm, but MM gives an error message: Object doesn't support this property or method: "SDB.UI.NewForm". I guess the wiki is ahead of the functionnality...
I don't have time right now, I'll dig more later to see if I can make it work with another type of window. But if you know what I should put as a parameter to NewPanel it will be greatly appreciated.
Thanks!
Rycher-
-
- Posts: 401
- Joined: Thu Sep 27, 2007 4:19 pm
- Location: Connecticut
Re: Can I create a custom pop-up display?
If I understand it correctly myself, NewPanel expects to be a child of a form. So you'd have to create a form first and then create a panel with the name of the form as the argument.
something like:
Set YourForm = SDB.UI.NewForm
Set YourPanel = SDB.UI.NewPanel(YourForm)
something like:
Set YourForm = SDB.UI.NewForm
Set YourPanel = SDB.UI.NewPanel(YourForm)
-
- Posts: 401
- Joined: Thu Sep 27, 2007 4:19 pm
- Location: Connecticut
Re: Can I create a custom pop-up display?
Thought I'd add a little interest to the above timer-enabled pop up. This code segment includes an OnPlay event which causes the pop up to display the artist,album,title every time a song starts playing. I expanded the panel to include 3 'labels' and the display sub to accept 3 arguments. The panel size is automatically adjusted if some of the arguments are null.
Note that the panel could still be used as a debug window simultaneously with the OnPlay event, or for different data.
Note that the panel could still be used as a debug window simultaneously with the OnPlay event, or for different data.
Code: Select all
Dim DebugPanel,DebugLabel1,DebugLabel2,DebugLabel3
Set DebugPanel = SDB.UI.NewDockablePersistentPanel("InfoPanel")
DebugPanel.Common.Visible=False
If DebugPanel.IsNew Then
DebugPanel.DockedTo = 2
End If
DebugPanel.Common.Width=300
Set DebugLabel1 = SDB.UI.NewLabel(DebugPanel)
DebugLabel1.Common.SetRect 10,10,280,21
Set DebugLabel2 = SDB.UI.NewLabel(DebugPanel)
DebugLabel2.Common.SetRect 10,35,280,21
Set DebugLabel3 = SDB.UI.NewLabel(DebugPanel)
DebugLabel3.Common.SetRect 10,60,280,21
Set DebugTimer = SDB.CreateTimer( 5000) ' 5 sec Debug Timer
DebugTimer.Enabled=False
Script.RegisterEvent DebugTimer, "OnTimer", "Event_DebugTimer"
Script.RegisterEvent SDB, "OnPlay","Event_OnPlay"
End Sub
Call DebugDisplay("Enter some debug info here","","")
Sub Event_DebugTimer(x)
DebugPanel.Common.Visible=False
DebugTimer.Enabled=False
End Sub
Sub DebugDisplay(t1,t2,t3)
DebugTimer.Enabled=False ' Cancel any timer currently triggered
If t2="" and t3 = "" Then
DebugPanel.Common.Height = 30
End If
If t2<>"" and t3="" Then
DebugPanel.Common.Height=60
End If
If t2<>"" and t3<>"" Then
DebugPanel.Common.Height=90
End If
DebugLabel1.Caption=t1 ' Set the text to display
DebugLabel2.Caption=t2
DebugLabel3.Caption=t3
DebugPanel.Common.Visible=True ' Make it visible
DebugTimer.Enabled=True ' Start the timer
End Sub
Sub Event_OnPlay
Dim t1,t2,t3
t1="Artist: " & SDB.Player.CurrentSong.ArtistName
t2=" Album: " & SDB.Player.CurrentSong.AlbumName
t3=" Title: " & SDB.Player.CurrentSong.Title
Call DebugDisplay(t1,t2,t3)
End Sub
Re: Can I create a custom pop-up display?
Thanks a lot, I was able to do what I wanted!
Rycher-
Rycher-
-
- Posts: 401
- Joined: Thu Sep 27, 2007 4:19 pm
- Location: Connecticut
Re: Can I create a custom pop-up display?
Great! How did you do it? Perhaps others could use your implementation.
Ray
Ray
Re: Can I create a custom pop-up display?
Ok, so here is what I wanted: I use an auto-dj script that can insert whole albums. And when I'm in "by album" mode, I wanted to know what was the album coming up. So the script I did with your help does this: when in album mode (custom made by another script, see http://www.mediamonkey.com/forum/viewto ... 15#p173715), when the last track of an album starts playing, it pops a window with the next album (title+artist).raybeau528 wrote:Great! How did you do it? Perhaps others could use your implementation.
Ray
This window is customized to appear just below the mini player where I use it. I didn't see how to associate it to the miniplayer, or get the miniplayer position to adjust its position accordingly. So the position and size are hard coded to my needs. Also, I don't understand why the width of the panel has to be 24 less than the width of the form, otherwise the frame of the panel doesn't appear properly (right side is outside the form). But it does.
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: ComingUp
' DESCRIPTION:
' When playing AutoDJ by album (using script DJTiedSongsGroups), displays the next album
' on playing the last track of the previous.
'
' AUTHOR: Rycher
' DATE : 31.10.2008
'
' Thanks to raybeau528 for his help with the time-delayed window display.
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts" folder
' - Add an script entry to file Scripts.ini (example shown below)
'
' [ComingUp]
' FileName=ComingUp.vbs
' ProcName=OnSongStartsPlaying
' Order=1
' DisplayName=Coming Up...
' Description=Album coming up
' Language=VBScript
' ScriptType=2
'
'==========================================================================
Dim NextUpForm, NextUpPanel, NextUpLabel, NextUpTimer
Sub OnSongStartsPlaying
Set NextUpForm = SDB.UI.NewForm
NextUpForm.Common.Visible=False
NextUpForm.Common.ControlName=""
'NextUpForm.Common.SetRect 0,0,400,27
NextUpForm.Common.Top = 25
NextUpForm.Common.Left =492
NextUpForm.Common.Width =400
NextUpForm.Common.Height =27
NextUpForm.FormPosition = 0
NextUpForm.BorderStyle = 0
NextUpForm.StayOnTop = true
Set NextUpPanel = SDB.UI.NewPanel(NextUpForm)
NextUpPanel.Common.ControlName=""
NextUpPanel.Common.SetRect 0,0,376,27
Set NextUpLabel = SDB.UI.NewLabel(NextUpPanel)
NextUpLabel.Common.SetRect 6,6,400,27
Set NextUpTimer = SDB.CreateTimer(7000) ' 7 sec Timer
NextUpTimer.Enabled=False
Script.RegisterEvent NextUpTimer, "OnTimer", "Event_NextUpTimer"
if SDB.Player.isAutoDJ AND SDB.IniFile.BoolValue("TagGroup", "ByAlbum") AND SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 Then
dim NextUp : Set NextUp = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1)
If SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex).Album.Id <> NextUp.Album.Id Then
NextUpDisplay("Coming up : " & NextUp.AlbumName & " - " & NextUp.AlbumArtistName)
End If
End If
End Sub
Sub Event_NextUpTimer(x) ' Makes the panel invisible when the timer triggers and shuts off the timer
NextUpForm.Common.Visible=False
NextUpTimer.Enabled=False
End Sub
Sub NextUpDisplay(Msg)
NextUpTimer.Enabled=False ' Cancel any timer currently triggered
NextUpLabel.Caption=Msg ' Set the text to display
NextUpForm.Common.Visible=True
NextUpTimer.Enabled=True ' Start the timer
End Sub
If you have an idea on how to fix that let me know.
Rycher-
-
- Posts: 401
- Joined: Thu Sep 27, 2007 4:19 pm
- Location: Connecticut
Re: Can I create a custom pop-up display?
Cool! Glad it works for you.
Ray
I'm not sure about that either but I did notice that your label is wider than the panel it is in. Your form has a width of 400, the panel has a width of 376 and then your label has a width of 400. Perhaps you don't need the panel at all. You could associate the label directly with the form. The 24 pixel difference might be the width of the border around the form. I believe the Wiki description for the common object includes let/get methods for the interior dimensions of a form. As such, I would think a panel within a form should be smaller than the form. Same with a label, or Edit Field, etc. they probably need to be smaller than the form or panel in which they reside. Might have to experiment more but I would try eliminating the panel within the form and reducing the width of the label.Also, I don't understand why the width of the panel has to be 24 less than the width of the form, otherwise the frame of the panel doesn't appear properly (right side is outside the form). But it does.
Ray
Re: Can I create a custom pop-up display?
I tried without a panel, this is what I get:Might have to experiment more but I would try eliminating the panel within the form and reducing the width of the label.

It looks like something is missing, like a ghost window when a program freeze up.
With a panel, it adds a little border that give a nicer look:

And I don't want the big border of a regular window. So I'm going to keep the panel.
As far as label rectangle is concerned (NextUpLabel.Common.SetRect), top and left do specify where to start within the label. But width and height seem to have no impact at all. Wether I put a very small or very large width it still displays the full label without going outside the form.
So there are a few parameters that do not seem to matter, but in the end I got the look I want so I'm not going to worry about them...
If I can just keep the current transparency when it pops up I will be completely happy with it (I'm 99% happy with it as is).
Rycher-
Re: Can I create a custom pop-up display?
Here is a revised version of the script, that sets the form width to the width of the message displayed, giving a nicer look:
Rycher-
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: ComingUp
' DESCRIPTION:
' When playing AutoDJ by album (using script DJTiedSongsGroups), displays the next album
' on playing the last track of the previous.
'
' AUTHOR: Rycher
' DATE : 31.10.2008
'
' Thanks to raybeau528 for his help with the time-delayed window display.
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts" folder
' - Add an script entry to file Scripts.ini (example shown below)
'
' [ComingUp]
' FileName=ComingUp.vbs
' ProcName=OnSongStartsPlaying
' Order=1
' DisplayName=Coming Up...
' Description=Album coming up
' Language=VBScript
' ScriptType=2
'
'==========================================================================
Dim NextUpForm, NextUpPanel, NextUpLabel, NextUpTimer
Sub OnSongStartsPlaying
if SDB.Player.isAutoDJ AND SDB.IniFile.BoolValue("TagGroup", "ByAlbum") AND SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 Then
dim NextUp : Set NextUp = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1)
If SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex).Album.Id <> NextUp.Album.Id Then
Set NextUpForm = SDB.UI.NewForm
NextUpForm.Common.Visible=False
NextUpForm.Common.Top = 25
NextUpForm.Common.Left =492
NextUpForm.Common.Height =27
NextUpForm.FormPosition = 0
NextUpForm.BorderStyle = 0
NextUpForm.StayOnTop = true
Set NextUpPanel = SDB.UI.NewPanel(NextUpForm)
NextUpPanel.Common.Height = NextUpForm.Common.Height
Set NextUpLabel = SDB.UI.NewLabel(NextUpPanel)
NextUpLabel.Common.Top = 6
NextUpLabel.Common.Left = 6
NextUpLabel.Autosize = true
Set NextUpTimer = SDB.CreateTimer(7000) ' 7 sec Timer
NextUpTimer.Enabled=False
Script.RegisterEvent NextUpTimer, "OnTimer", "Event_NextUpTimer"
NextUpDisplay("Coming up : " & NextUp.AlbumName & " - " & NextUp.AlbumArtistName)
End If
End If
End Sub
Sub Event_NextUpTimer(x) ' Makes the panel invisible when the timer triggers and shuts off the timer
NextUpForm.Common.Visible=False
NextUpTimer.Enabled=False
End Sub
Sub NextUpDisplay(Msg)
NextUpTimer.Enabled=False ' Cancel any timer currently triggered
NextUpLabel.Caption=Msg ' Set the text to display
NextUpPanel.Common.Width=NextUpLabel.Common.Width + 12
NextUpForm.Common.Width=NextUpLabel.Common.Width + 12
NextUpForm.Common.Visible=True
NextUpTimer.Enabled=True ' Start the timer
End Sub