Previewer 2.7 [MM2+3]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Previewer 2.7 [MM2+3]

Postby trixmoto on Wed Nov 23, 2005 4:06 pm

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!

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.7
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 21/12/2008
'
' 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, 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: Fixed behaviour if no button is clicked
'        Fixed resuming paused track not working
'        Added disable and re-enable of RatePlayedSong
'

Option Explicit

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, 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 = 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(SDB.Player.PlaylistCount-1)
    End If
    Script.UnregisterEvents Tmr

    'restore player status
    SDB.Player.Stop
    SDB.Player.CurrentSongIndex = curi
    SDB.Player.PlaybackTime = curp-1000
    If playing Then
      SDB.Player.Play
    End If
    If SDB.VersionHi > 2 Then
      While SDB.Player.IsStartingPlayback
        SDB.ProcessMessages
      WEnd
      SDB.Player.PlaybackTime = curp-1000
    End If   
    If paused Then
      SDB.Player.Pause 
    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("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     
    PosBar.Value = (SDB.Player.PlayBackTime*1000)\SDB.Player.CurrentSongLength
  End If
  If SDB.Player.CurrentSongLength < SDB.Player.PlayBackTime+1000 Then
    Dim shell : Set shell = CreateObject("WScript.Shell")
    shell.SendKeys "%R"
  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 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 9:34 pm, edited 14 times in total.
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby rovingcowboy on Wed Nov 23, 2005 9: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. just a user of media monkey not a programmer. give us all the info pertaining to your errors and someone can help you more correctly.
If you don't know what info to give then check item 14 on the helpful messages link for an idea.

Monkey's helpful messages at viewtopic.php?p=44008#44008
MY SYSTEMS.
1.Xp pro sp3, vers 3.2 jukebox, built by me) 2.WinXP pro sp3, vers 2.5.5 and vers 3.2 backup storage, put together by me.)
3.lenovo toasted motherboard so its gone.) 4.Dell is gone cause its loosing drivers and stuff. 5.WinXp pro sp3, vers 2.5.5, moms computer. Sony vaio.)
rovingcowboy
 
Posts: 9759
Joined: Sat Oct 25, 2003 12:57 pm
Location: (Texas)

Postby trixmoto on Wed Nov 23, 2005 9: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! :)
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby trixmoto on Mon Nov 28, 2005 12:11 pm

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 11:55 pm, edited 1 time in total.
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

works good

Postby slyr on Wed Dec 07, 2005 10: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 on Wed Dec 07, 2005 10:45 am

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

Postby trixmoto on Wed Dec 07, 2005 10: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!) :)
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

works great

Postby slyr on Wed Dec 07, 2005 11: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 on Wed Dec 07, 2005 12:10 pm

Glad you like the script. With a little help from psyxonova there should be an improved and more stable version coming out soon. :)
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

shortcut

Postby Bandolero on Fri Dec 16, 2005 12:49 pm

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: 22
Joined: Mon Mar 28, 2005 9:21 am
Location: New York City

Postby powerpill-pacman on Sun Jan 22, 2006 8:49 am

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

Postby Philby on Tue Jan 24, 2006 1:06 am

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 12:49 pm

Postby Philby on Tue Jan 24, 2006 1:36 am

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 12:49 pm

Postby trixmoto on Thu Jun 29, 2006 11: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.
Loving the Monkey? - Get Gold
Check out my scripts at http://trixmoto.net including my top ten
Subscribe to my rss feed for all the latest news
trixmoto
 
Posts: 7913
Joined: Fri Aug 26, 2005 8:28 am
Location: England

Postby MoDementia on Fri Jun 30, 2006 12:54 am

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: 1319
Joined: Thu Jun 15, 2006 8:26 pm
Location: Geelong, Victoria, Australia

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: julial49, Owyn and 9 guests