Previewer 2.9 - Updated 26/07/2014

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Previewer 2.9 - Updated 26/07/2014

Postby trixmoto » Wed Nov 23, 2005 11:06 am

This script previews a song. If you are playing a song (or have one paused) it remembers this song and position. It then adds the selected song to the end of your now playing list (remembering where it added it) and plays it. When the song has finished, it removes it from your now playing list, and plays the previous song from where it left off. Genius! One limitation is that if the interrupted track is a stream then the position cannot be restored, so it will restart from the beginning.

An installer for this script can be downloaded from my website which I suggest because there are mutiple files as well an ini entry.

Code: Select all
'
' MediaMonkey Script
'
' NAME: Previewer 2.9
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 26/07/2014
'
' 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
' Thanks to Nanya who helped make the progress bar editable during preview
'
' 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, ScrobblerDJ and RatePlayedSong
'       It restores their previous state afterwards though! :)
'
' [Previewer]
' FileName=Previewer.vbs
' ProcName=Previewer
' Order=10
' DisplayName=Previewer
' Description=Preview a track without disturbing now playing
' Language=VBScript
' ScriptType=0
'
' FIXES: Added ability to move progress bar during preview (thanks to Nanya)
'

Option Explicit

Dim ManualChange : ManualChange = True

Sub Toolbar(but)
  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
    Dim crossfade : crossfade = SDB.Player.isCrossfade
    If crossfade Then
      SDB.Player.isCrossfade = False
    End If
    Dim ratesong : ratesong = SDB.IniFile.BoolValue("RatePlayedSong","Enabled")
    If ratesong Then
      SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = False
    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)+15, 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 = 1000
    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 = True
    Call Script.RegisterEvent(PosBar,"OnChange","OnSeek")
    Set SDB.Objects("PreviewerPosBar") = PosBar
   
    Dim BtnPlayNow : Set BtnPlayNow = SDB.UI.NewButton(Form)
    BtnPlayNow.Caption = "Play &Now"
    BtnPlayNow.Common.Height = bheight
    BtnPlayNow.Common.Width = 70
    BtnPlayNow.Common.Top = PosBar.Common.Top + PosBar.Common.Height +10
    BtnPlayNow.Common.Left = midp -155
    BtnPlayNow.UseScript = Script.ScriptPath
    BtnPlayNow.ModalResult = 3
   
    Dim BtnPlayNext : Set BtnPlayNext = SDB.UI.NewButton(Form)
    BtnPlayNext.Caption = "Play N&ext"
    BtnPlayNext.Common.Height = bheight
    BtnPlayNext.Common.Width = 70
    BtnPlayNext.Common.Top = BtnPlayNow.Common.Top
    BtnPlayNext.Common.Left = midp -75
    BtnPlayNext.UseScript = Script.ScriptPath
    BtnPlayNext.ModalResult = 4
   
    Dim BtnPlayLast : Set BtnPlayLast = SDB.UI.NewButton(Form)
    BtnPlayLast.Caption = "Play &Last"
    BtnPlayLast.Common.Height = bheight
    BtnPlayLast.Common.Width = 70
    BtnPlayLast.Common.Top = BtnPlayNow.Common.Top
    BtnPlayLast.Common.Left = midp +5
    BtnPlayLast.UseScript = Script.ScriptPath
    BtnPlayLast.Default = True
    BtnPlayLast.ModalResult = 1   
     
    Dim BtnCancel : Set BtnCancel = SDB.UI.NewButton(Form)
    BtnCancel.Caption = "&Cancel"
    BtnCancel.Common.Height = bheight
    BtnCancel.Common.Width = 70
    BtnCancel.Common.Left = midp +85
    BtnCancel.Common.Top = BtnPlayLast.Common.Top
    BtnCancel.UseScript = Script.ScriptPath
    BtnCancel.Cancel = True
    BtnCancel.ModalResult = 2

    'show preview form
    Form.Common.Height = BtnCancel.Common.Top + bheight +40
    Dim Tmr : Set Tmr = SDB.CreateTimer(1000)
    Call Script.RegisterEvent(Tmr,"OnTimer","UpdatePosBar")
    Dim res : res = Form.ShowModal
    Dim lst : lst = SDB.Player.PlaylistCount-1
    Call Script.UnregisterEvents(Tmr)
    Select Case res
      Case 1 'play last
        'do nothing   
      Case 2 'cancel
        Call SDB.Player.PlaylistDelete(lst)
      Case 3 'play now
        If lst <> curi Then
          Call SDB.Player.PlaylistMoveTrack(lst,curi)
        End If
      Case 4 'play next
        If lst <> curi+1 Then
          Call SDB.Player.PlaylistMoveTrack(lst,curi+1)
        End If               
    End Select

    'restore player status
    If res <> 3 Then
      SDB.Player.Stop
      SDB.Player.CurrentSongIndex = curi
      SDB.Player.PlaybackTime = curp-1000
      If playing Then
        SDB.Player.Play
      End If
      While SDB.Player.IsStartingPlayback
        SDB.ProcessMessages
      WEnd
      If Not (UCase(Left(SDB.Player.CurrentSong.Path,4)) = "HTTP") Then
        SDB.Player.PlaybackTime = curp-1000
      End If   
      If paused Then
        SDB.Player.Pause 
      End If
    End If   
   
    '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   
    If crossfade Then
      SDB.Player.isCrossfade = True
    End If   
    If ratesong Then
      SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = True
    End If
  Else
    Call SDB.MessageBox("Previewer - 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") 
  If SDB.Player.CurrentSongLength > 0 Then     
    ManualChange = False
    PosBar.Value = (SDB.Player.PlayBackTime*1000)\SDB.Player.CurrentSongLength
    ManualChange = True
  End If
  If SDB.Player.CurrentSongLength < SDB.Player.PlayBackTime+2000 Then
    Dim wsh : Set wsh = CreateObject("WScript.Shell")
    Call wsh.SendKeys("%C")
  End If
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

Sub OnSeek(PosBar)
  If ManualChange = True Then
    SDB.Player.PlayBackTime = (PosBar.Value*SDB.Player.CurrentSongLength)\1000
  End If
End Sub

Sub Install()
  Dim inip : inip = SDB.ApplicationPath&"Scripts\Scripts.ini"
  Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
  If Not (inif Is Nothing) Then
    inif.StringValue("Previewer","Filename") = "Previewer.vbs"
    inif.StringValue("Previewer","Procname") = "Previewer"
    inif.StringValue("Previewer","Order") = "10"
    inif.StringValue("Previewer","DisplayName") = "Previewer"
    inif.StringValue("Previewer","Description") = "Preview a track without disturbing now playing"
    inif.StringValue("Previewer","Language") = "VBScript"
    inif.StringValue("Previewer","ScriptType") = "0"
    SDB.RefreshScriptItems
  End If
End Sub
Last edited by trixmoto on Mon Apr 28, 2008 4:34 pm, edited 14 times in total.
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

Postby rovingcowboy » Wed Nov 23, 2005 4:07 pm

please explain the use for this script trixmoto because i am lost?

i just play the song and click on the next song and so on and so fourth when i want to preview songs.

what does this script do for me that i should use it? i really am not trying to be sarcastic i am lost as to why this is here?

:o
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#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 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 14149
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Postby trixmoto » Wed Nov 23, 2005 4:34 pm

Sorry I should have posted this link: http://www.mediamonkey.com/forum/viewtopic.php?t=6589. This is where the idea came from.

The script should allow you to preview a song without affecting your Now Playing list, so it stops what you're currently listening to, and then continues from that point after you've previewed the song you wanted to. The script is currently in it's very early stages though! :)
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

Postby trixmoto » Mon Nov 28, 2005 7:11 am

Ok, this new version (2.0) has a form ("mini player") which opens up to allow you to control your preview. Thanks very much to psyxonova who has been helping with this project.

:o New version below :o
Last edited by trixmoto on Thu Jun 29, 2006 6:55 pm, edited 1 time in total.
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

works good

Postby slyr » Wed Dec 07, 2005 5:38 am

works great, maybe you could add a short cut crt + something,
to make it even easier to preview !!

this is realy usefull when creating a playlist,

thanks alot
slyr
 

Postby slyr » Wed Dec 07, 2005 5:45 am

i tried to add shortcut in the ini file (i'm very optimistic :-? ) , but i didn't work. :(
slyr
 

Postby trixmoto » Wed Dec 07, 2005 5:48 am

Your INI entry should look like this if you want a shortcut:
Code: Select all
[Previewer]
FileName=Previewer.vbs
ProcName=Previewer
Order=10
DisplayName=&Previewer
Description=Preview a track without disturbing now playing
Language=VBScript
ScriptType=0
Shortcut=Shift+Alt+P

(Obviously you can use any shortcut you want, this is the one I use!) :)
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

works great

Postby slyr » Wed Dec 07, 2005 6:56 am

ok thanks alot

i think i had put it between " " , but now it works. :D
thanks alot for the fast assistance and a great script.
slyr
 

Postby trixmoto » Wed Dec 07, 2005 7:10 am

Glad you like the script. With a little help from psyxonova there should be an improved and more stable version coming out soon. :)
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

shortcut

Postby Bandolero » Fri Dec 16, 2005 7:49 am

Thanks for this great script. I've been trying to do this for a while.

I use Alt+Q for a shortcut and it works great.
Bandolero
 
Posts: 23
Joined: Mon Mar 28, 2005 4:21 am
Location: New York City

Postby powerpill-pacman » Sun Jan 22, 2006 3:49 am

This script is absolutely great, didn't even think that this would be possible. Thank you so much. :D
powerpill-pacman
 
Posts: 154
Joined: Mon Feb 21, 2005 1:07 pm
Location: berlin, germany

Postby Philby » Mon Jan 23, 2006 8:06 pm

Excellent script Trixmoto. One of the neatest I have come across. Well done.

I can see opportunities for further enhancements - like selecting next and previous songs to also preview - skipping quickly thru a list without leaving the script.

I am sure with more use I will think of more.
Regards
Philby
Philby
 
Posts: 155
Joined: Wed Aug 10, 2005 7:49 am

Postby Philby » Mon Jan 23, 2006 8:36 pm

Didnt take long !

How about also a progress bar to show whereabouts you are in the song ?
This would complement the forward and backward movement by time buttons.
Regards
Philby
Philby
 
Posts: 155
Joined: Wed Aug 10, 2005 7:49 am

Postby trixmoto » Thu Jun 29, 2006 6:54 pm

New version (2.1) is now available from my website.

Thanks to MoDementia who added check/disable/re-enable for AutoDJ and AutoRateSongs.

I've just seen some of your suggestions which I'd forgotten so I will implement some of these soon.
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

Postby MoDementia » Thu Jun 29, 2006 7:54 pm

Philby wrote:Excellent script Trixmoto. One of the neatest I have come across. Well done.

I can see opportunities for further enhancements - like selecting next and previous songs to also preview - skipping quickly thru a list without leaving the script.


I didn't see this thread before (just browsed your website) but I agree with Philby :)

I did have in mind to add his enhancement later but I'm sure you could do it alot faster/better :wink:
MoDementia
 
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 19 guests