Previewer 2.9 - Updated 26/07/2014

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

jiri
Posts: 5419
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

If you are having problems, make sure that it isn't caused by another installed script, i.e. try as clean installation of MM as possible.

In case you can't find the reason, try to create a debug log (in MM 3.0 alpha it should be created automatically) and e-mail it to me, I'll look into it.

Jiri
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Post by Eyal »

Thanks guys, it's working now with the On_Startup code clip from Trixmoto above. Before that I had one I have created but did not include it in the Previewer script, but in a single file in scripts\auto. But I still not understand why it was able to call the Previewer script but its button functions. Anyway.
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Because the button sets the "UseScript" property to "Script.ScriptPath" - but if the script is actually being included into another file then this value is incorrect, hence it can't find the function.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Post by Eyal »

You are right. Now I understand.

Thanks!
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
chaussettdeguerr
Posts: 14
Joined: Thu Jul 19, 2007 7:58 am
Location: belgium

Post by chaussettdeguerr »

hello trixmoto
i tried to place the previewer.vbs in the auto directory, and paste the modif at the top of the file, but without a result. No more preview nor button.
can you say me where exactly to paste that code?
thanks a lot for your wonderful job.
chaussettdeguerr
Posts: 14
Joined: Thu Jul 19, 2007 7:58 am
Location: belgium

Post by chaussettdeguerr »

ok, i pasted it after

here is the result in my "preview.vbs" :

Code: Select all

'
' MediaMonkey Script
'
' NAME: Previewer 2.2
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 15/07/2006
'
' Thanks to Psyxonova for this help with the design of this script
' Thanks to MoDementia who added check/disable/re-enable for AutoDJ and AutoRateSongs
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' NOTE: This script switches off AutoDJ, AutoRateSongs, AutoAlbumDJ and ScrobblerDJ.
'       It restores their previous state afterwards though! :)
'
' FIXES: Temporarily switch off ScrobblerDJ and AutoAlbumDJ
'        Added trackbar to show song position
'
' [Previewer]
' FileName=Previewer.vbs
' ProcName=Previewer
' Order=10
' DisplayName=Previewer
' Description=Preview a track without disturbing now playing
' Language=VBScript
' ScriptType=0 
'

Option Explicit
Sub OnStartup 
    With SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard, 0, 0) 
        .Caption="Previewer" 
        .IconIndex=50 
        .UseScript=Script.ScriptPath 
        .OnClickFunc="DoPreviewer" 
    End With 
End Sub 

Sub DoPreviewer(obj) 
  Call Previewer 
End Sub
Sub Previewer
  If SDB.SelectedSonglist.Count = 1 Then
  
    'get status and switch off other scripts
    Dim Regs : Set Regs = SDB.Registry
    If Regs.OpenKey("Auto Rating", True) Then 
      Dim autoratesongson : autoratesongson = Regs.IntValue("os00")
      If Regs.IntValue("os00") = 1 Then
        Regs.IntValue("os00") = 0
        Regs.CloseKey
      End If
    End If
    Dim autodj : autodj = SDB.Player.isAutoDJ 
    If autodj Then
      SDB.Player.isAutoDJ = False
    End If    
    Dim scrobbler : scrobbler = SDB.IniFile.StringValue("ScrobblerDJ","Enabled")
    If scrobbler = "1" Then
      SDB.IniFile.StringValue("ScrobblerDJ","Enabled") = "0"
    End If
    Dim autoalbum : autoalbum = SDB.IniFile.StringValue("AutoAlbumDJ","Enabled")
    If autoalbum = "1" Then
      SDB.IniFile.StringValue("AutoAlbumDJ","Enabled") = 0
    End If
    
    'store player status
    Dim playing : playing = SDB.Player.isPlaying
    Dim paused : paused = SDB.Player.isPaused
    If playing Or paused Then
      Dim curi : curi = SDB.Player.CurrentSongIndex
      Dim curp : curp = SDB.Player.PlaybackTime
      SDB.Player.Stop
    End If

    'play preview track
    Dim newi : newi = SDB.Player.PlaylistCount
    SDB.Player.PlaylistAddTrack(SDB.SelectedSonglist.Item(0))
    SDB.Player.CurrentSongIndex = newi
    SDB.Player.Play

    'create preview form
    Dim midp : midp = 200
    Dim bheight : bheight = 23
    Dim bwidth : bwidth = 35
    
    Dim Form : Set Form = SDB.UI.NewForm
    Form.Common.SetRect 100, 100, 2*midp, 200
    Form.BorderStyle  = 3   ' Non-Resizable
    Form.FormPosition = 4   ' Screen Center
    Form.Caption = "Previewer"

    Dim Label2 : Set Label2 = SDB.UI.NewLabel(Form)
    Label2.Caption = "Title: "&SDB.Player.CurrentSong.Title
    Label2.Common.Left = 10
    Label2.Common.Top = 14

    Dim Label1 : Set Label1 = SDB.UI.NewLabel(Form)
    Label1.Caption = "Artist: "&SDB.Player.CurrentSong.ArtistName
    Label1.Common.Left = 10
    Label1.Common.Top = Label2.Common.Top + Label2.Common.Height +10

    Dim Btn3 : Set Btn3 = SDB.UI.NewButton(Form)
    Btn3.Caption = "&Pause"
    Btn3.Common.Height = bheight
    Btn3.Common.Width = bwidth+20
    Btn3.Common.Top = Label1.Common.Top + Label1.Common.Height +10
    Btn3.Common.Left = midp - Int(Btn3.Common.Width/2)
    Btn3.Common.ControlName = "playButton"
    Btn3.UseScript = Script.ScriptPath
    Btn3.OnClickFunc = "playPause"

    Dim Btn2 : Set Btn2 = SDB.UI.NewButton(Form)
    Btn2.Caption = "-5s"
    Btn2.Common.Height = bheight
    Btn2.Common.Width = bwidth
    Btn2.Common.Top = Btn3.Common.Top
    Btn2.Common.Left = midp - Int(Btn3.Common.Width/2) - bwidth -10
    Btn2.UseScript = Script.ScriptPath
    Btn2.OnClickFunc = "seekB05"

    Dim Btn1 : Set Btn1 = SDB.UI.NewButton(Form)
    Btn1.Caption = "-30s"
    Btn1.Common.Height = bheight
    Btn1.Common.Width = bwidth
    Btn1.Common.Top = Btn3.Common.Top
    Btn1.Common.Left = midp - Int(Btn3.Common.Width/2) - (bwidth*2) -20
    Btn1.UseScript = Script.ScriptPath
    Btn1.OnClickFunc = "seekB30"

    Dim Btn4 : Set Btn4 = SDB.UI.NewButton(Form)
    Btn4.Caption = "+5s"
    Btn4.Common.Height = bheight
    Btn4.Common.Width = bwidth
    Btn4.Common.Top = Btn3.Common.Top
    Btn4.Common.Left = midp + Int(Btn3.Common.Width/2) +10
    Btn4.UseScript = Script.ScriptPath
    Btn4.OnClickFunc = "seekF05"

    Dim Btn5 : Set Btn5 = SDB.UI.NewButton(Form)
    Btn5.Caption = "+30s"
    Btn5.Common.Height = bheight
    Btn5.Common.Width = bwidth
    Btn5.Common.Top = Btn3.Common.Top
    Btn5.Common.Left = midp + Int(Btn3.Common.Width/2) + bwidth +20
    Btn5.UseScript = Script.ScriptPath
    Btn5.OnClickFunc = "seekF30"
    
    Dim PosBar : Set PosBar = SDB.UI.NewTrackBar(Form)
    PosBar.Horizontal = True
    PosBar.MinValue = 0
    PosBar.MaxValue = SDB.Player.CurrentSongLength
    PosBar.Value = 0
    PosBar.Common.Top = Btn3.Common.Top + bheight
    PosBar.Common.Left = 20
    PosBar.Common.Height = 25
    PosBar.Common.Width = (midp - PosBar.Common.Left)*2 
    PosBar.Common.Enabled = False
    Set SDB.Objects("PreviewerPosBar") = PosBar
   
    Dim BtnOk : Set BtnOk = SDB.UI.NewButton(Form)
    BtnOk.Caption = "&Add to Now Playing"
    BtnOk.Common.Height = bheight
    BtnOk.Common.Width = 150
    BtnOk.Common.Top = PosBar.Common.Top + PosBar.Common.Height +10
    BtnOK.Common.Left = midp - BtnOk.Common.Width -5
    BtnOk.UseScript = Script.ScriptPath
    BtnOk.Default = True
    BtnOk.ModalResult = 1
      
    Dim BtnCancel : Set BtnCancel = SDB.UI.NewButton(Form)
    BtnCancel.Caption = "&Remove from Now Playing"
    BtnCancel.Common.Height = bheight
    BtnCancel.Common.Width = 150
    BtnCancel.Common.Left = midp +5
    BtnCancel.Common.Top = BtnOK.Common.Top
    BtnCancel.UseScript = Script.ScriptPath
    BtnCancel.Cancel = True
    BtnCancel.ModalResult = 2

    'show preview form
    Form.Common.Height = BtnOk.Common.Top + bheight +40
    Dim Tmr : Set Tmr = SDB.CreateTimer(1000)
    Script.RegisterEvent Tmr, "OnTimer", "UpdatePosBar"
    If Form.showModal = 2 Then SDB.Player.PlaylistDelete(newi)
    Script.UnregisterEvents Tmr

    'restore player status
    SDB.Player.Stop
    SDB.Player.CurrentSongIndex = curi
    If playing Then SDB.Player.Play
    If paused Then SDB.Player.Pause
    SDB.Player.PlaybackTime = curp-1000
    
    'restore status of other scripts
    If Regs.OpenKey("Auto Rating", True) Then 
      Regs.IntValue("os00") = autoratesongson
      Regs.CloseKey
    End If
    If autodj Then
      SDB.Player.isAutoDJ = True
    End If
    If Not (scrobbler = "") Then
      SDB.IniFile.StringValue("ScrobblerDJ","Enabled") = scrobbler
    End If
    If Not (autoalbum = "") Then
      SDB.IniFile.StringValue("AutoAlbumDJ","Enabled") = autoalbum
    End If    
  Else
    Call SDB.MessageBox("You can only preview one track at a time.", mtError, Array(mbOk))
  End If
End Sub 

Sub UpdatePosBar(PosTimer)
  Dim PosBar : Set PosBar = SDB.Objects("PreviewerPosBar")  
  PosBar.Value = SDB.Player.PlayBackTime
End Sub

Sub playPause (ClickedBtn)
  If SDB.Player.isPaused Then
    ClickedBtn.Caption = "&Pause"
    SDB.Player.Play
    Exit Sub
  End If   
  If SDB.Player.isPlaying Then
    ClickedBtn.Caption = "&Play"
    SDB.Player.Pause
    Exit Sub
  End If
End Sub

Sub seekB30 (ClickedBtn)
  SDB.Player.PlaybackTime = SDB.Player.PlaybackTime - 30000
End Sub

Sub seekB05 (ClickedBtn)
  SDB.Player.PlaybackTime = SDB.Player.PlaybackTime - 5000
End Sub

Sub seekF05 (ClickedBtn)
  SDB.Player.PlaybackTime = SDB.Player.PlaybackTime + 5000
End Sub

Sub seekF30 (ClickedBtn)
  SDB.Player.PlaybackTime = SDB.Player.PlaybackTime + 30000
End Sub
it's good now.
thanks a lot.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

An MM3 installer is now available from my website for this script! :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
The Crow
Posts: 44
Joined: Wed Nov 28, 2007 4:05 pm

Problems with Previewer2.2 / PreviewerButton script

Post by The Crow »

1. I use MM 3.0.1.1109 and installed Previewer 2.2 with installer. The actual position of the previewed track is not shown on the slide bar, the cursor always starts at the beginning and then directly jumps to the end of the bar. It seems that there are only two positions possibile (beginning, end). Moreover, if I leave preview mode the interrupted track doesn't restart at its old position but from the beginning.

2. If I run previewer with PreviewerButton script (http://www.mediamonkey.com/forum/viewtopic.php?t=13606) it's the same but additionally when I want to change the positions by +5, +30 etc. I get the error message "Error happened during script execution: Unknown Name".

To make it clear, the first problem also occurs if PreviewerButton script is not installed.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

1) I believe this is a bug with MM3, but I forgot to report it. I'll let the devs know.

2) This is because the button script you talk about doesn't really work in this case. Because all the script has actually been included into another script the "UseScript" properties of the buttons point to the wrong script.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

New version (2.3) is now available to download from my website.

I have fixed the trackbar in MM3 so that it is now correctly displaying the track position.

@The Crow - about the addition of the button, try this... http://www.mediamonkey.com/forum/viewto ... 3301#83301
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
The Crow
Posts: 44
Joined: Wed Nov 28, 2007 4:05 pm

Post by The Crow »

The trackbar and the implemented button work fine now. :)

However I seem to have other problems with the script. When starting it the actual Now playling list gets deleted before the preview starts and when exiting (regardless of which button I use (Add/Remove)) the previewed track is replayed from the beginning.
I actually took a fresh MM 3 installation to check that so there can't be a correlation with other scripts.

In MM 2.5 it's about the same but there the previewed track doesn't start from the beginning but from the point when the previous track has been interrupted. It's sort of weird...
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

This is very bizarre, I can't replicate any of this behaviour. Do you have any other scripts installed that could be conflicting? If so, try uninstalling them all (or at least disabling them) and see if that sorts it out or not.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
The Crow
Posts: 44
Joined: Wed Nov 28, 2007 4:05 pm

Post by The Crow »

O.K., I tried with fresh MM 3 RC 4. The script works partly (remove/add previewed song to playlist goes correctly) in shuffle mode (perhaps it did also before, I didn't check shuffle mode). However with "shuffle tracks off" the playlist gets deleted before running the script and remove/add can't work because of this.

Moreover the correct (interrupted) song is replayed then but always from the beginning and not from the last position.

I'll keep on testing it.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

There is absolutely no code in this script to remove tracks from the Now Playing list, unless you click the "Remove..." button in which case a single track (the one you're previewing) gets removed. I can only imagine this behaviour is being caused by another script.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
The Crow
Posts: 44
Joined: Wed Nov 28, 2007 4:05 pm

Post by The Crow »

I found the reason. If "Automatically retain X previous tracks in Now Playing" in Now Playing setting is not set to "All" then the playlist gets deleted automatically except for the X tracks at the end (!) of the current playlist before running the previewer script. And as the interrupted track isn't part of these tracks the script can't jump back to it. In shuffle mode this doesn't happen.

If it's set to "All" the script works fine in MM 2.5, it also restarts the interrupted track at the correct position.
In MM 3 the interrupted track always restarts from the beginning.
Post Reply