I need a gap! ~ How do I pause *after* a song?

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: I need a gap! ~ How do I pause *after* a song?

Re: I need a gap! ~ How do I pause *after* a song?

by onnotabak » Sat Apr 03, 2010 5:29 pm

With the new Sub OnTrackEnd possibility this is my enhancement of the original script.

Basically at the start of the song the StopAfterCurrent is triggered.
With the OnTrackEnd the timer is triggered after which the next song is started and everything starts over.
This also prevents that a portion of the next song is played.

I also made sure that at the end of the playing list it all stops.
Also included is that during the gap you can start another song which disables the timer.

Please note that you need at least MediaMonkey 3.1.0.1218.

Code: Select all

'======================================================================
' MediaMonkey\Scripts\Auto\Gap.vbs
'
' Creates a gap between each song.
' Can be turned on and off with a button on the toolbar.
'
' 2008-02-02 - Soren Werk - www.tangoman.dk
' 2010-04-03 - Onno Tabak
'
' ToDo:
'   Defaults configurable in Options.
'======================================================================

Option Explicit

Const GapSeconds = 5
Const GapDefaultOn = True

Dim GapButton
Dim GapProgress
Dim GapTimer

Sub OnStartUp()
  InitButton
  InitPlayer
  InitTimer
End Sub

Sub InitButton()
  Set GapButton = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard,0,0)
  GapButton.IconIndex = 2
  GapButton.Caption = "Turn " & GapSeconds & " seconds gap on and off"
  Script.RegisterEvent GapButton, "OnClick", "GapButtonOnClick"
  If GapDefaultOn Then
    GapButtonOnClick(GapButton)
  End If
End Sub

Sub InitPlayer()
  Script.RegisterEvent SDB, "OnPlay", "PlayerOnPlay"
  Script.RegisterEvent SDB, "OnTrackEnd", "AfterGap"
End Sub

Sub InitTimer()
  Set GapTimer = SDB.CreateTimer(1000)
  GapTimer.Enabled = False
  Script.RegisterEvent GapTimer, "OnTimer", "GapOnTimer"
End Sub

'======================================================================

Sub GapButtonOnClick(Button)
  Button.Checked = not Button.Checked
End Sub

Sub PlayerOnPlay()
  If GapButton.Checked Then
    SDB.Player.StopAfterCurrent = True
  End If
  If  GapTimer.Enabled = True Then  
    GapTimer.Enabled = False
    Set GapProgress = Nothing
  End If
End Sub

Sub AfterGap()
  If GapButton.Checked and SDB.Player.CurrentSongIndex+1 < SDB.Player.PlayListCount Then
    Set GapProgress = SDB.Progress
    GapProgress.MaxValue = GapSeconds
    GapProgress.Text="Gap " & GapSeconds & " seconds."
    GapTimer.Enabled = True
  Else
    GapTimer.Enabled = False
    Set GapProgress = Nothing
  End If
End Sub

Sub GapOnTimer(Timer)
  If GapTimer.Enabled = True Then
    GapProgress.Increase
    GapProgress.Text="Gap " & GapSeconds - GapProgress.Value & " seconds."
  End If
  If GapProgress.Value >= GapProgress.MaxValue Then
    SDB.Player.Next
    SDB.Player.Play  
    GapTimer.Enabled = False
    Set GapProgress = Nothing
  End If
End Sub

Re: I need a gap! ~ How do I pause *after* a song?

by agea » Thu Jul 09, 2009 8:38 pm

Thanks for the work on this script.
In 2009 new events have been added called "OnTrackEnd" and "OnPlaybackEnd".

from http://www.mediamonkey.com/wiki/index.p ... OnTrackEnd :
" Sub OnTrackEnd
Event description: This event is called when track playback is finished because the end of track is reached. Introduced in MediaMonkey 3.1.0.1218. "

from http://www.mediamonkey.com/wiki/index.p ... laybackEnd
" Sub OnPlaybackEnd
Event description: This event is called when track playback is finished regardless of reason, i.e. either end of track is reached, user presses Stop, Next or Previous button, or there's any other reason for stopping playback. Introduced in MediaMonkey 3.1.0.1223. "

See http://www.ventismedia.com/mantis/view. ... 106&nbn=21

Unfortunately I have not any knowledge about writing scripts but I would think these event could solve the problem that sometimes a fraction of the next song is played before the pause starts.

Re: I need a gap! ~ How do I pause *after* a song?

by rovingcowboy » Mon Aug 18, 2008 1:04 pm

for some reason the last updates maybe from microsoft i can't find a way to get to the old ds plugin unless you have the old mm 2 installed in your system as well as mm 3. mm 2 uses the old one you can adjust the buffers in that one and it should being the same plugin also adjust them for mm 3.

but as for the numbers being adjustable for longer gaps that is also done by the configure button for the ds plugin that is used in mm 3, go to the control panel and click on output plugins and select the ds, then click the config button.

8)

Re: I need a gap! ~ How do I pause *after* a song?

by Soren Werk » Mon Aug 18, 2008 10:56 am

Soo...

Maybe one day the gap between songs will be a configurable number of seconds from -30 to +30. The negative numbers are of course cross-over - with or without fade.

Re: I need a gap! ~ How do I pause *after* a song?

by Nostradamus » Mon Aug 18, 2008 12:02 am

Thanks guys! The lack of a gap between songs was driving me nuts! Only started when I upgraded to MM3.

by rovingcowboy » Thu Jun 05, 2008 10:34 pm

go to the windows media player, set the buffer on that players direct sound plugin. monkey uses their own direct sound plugin but i think the buffers when set on the main windows direct sound plugin by wmp will also still work with the mm program its just you can't adjust them from in monkey, they made their own because of too many errors going on with the windows one. although not for certian they will work i seem to have had luck with adjusting that way.

8)

by Guest » Thu Jun 05, 2008 8:49 pm

I spoke too soon. I am still having the same problem. I tried switching to the second output plugin (waveOut) and playing with the buffer settings, but that only made the problem worse.
Maybe I'll try turning off the script and keeping "remove silence" off.

by Guest » Thu Jun 05, 2008 8:31 pm

Thanks. I didn't see a buffer option in the output plugin that I was using (although I did see buffer options in the second output plugin, which was deselected).
I turned off "remove space between tracks" and that seems to have resolved my issue.

by rovingcowboy » Wed Jun 04, 2008 12:01 am

Anonymous wrote:Thanks for this script. Let us know if you come up with the features you're looking for. Incidentally I'm starting to have the problem you described--MM cuts off a little bit of the prior song and play it after the gap. This is happening even though I'm using your latest script, which uses Player.Stop rather than Player.Pause.
try going in to the plugin controls for the output plugin, and set the buffer or the crossfade to a different amount. or turn off remove silent space from the song. then if it does cut some of the song off it will only cut off the silent space. 8)



:)

by Guest » Tue Jun 03, 2008 9:56 pm

Thanks for this script. Let us know if you come up with the features you're looking for. Incidentally I'm starting to have the problem you described--MM cuts off a little bit of the prior song and play it after the gap. This is happening even though I'm using your latest script, which uses Player.Stop rather than Player.Pause.

Same Script - New Name - New Method

by Soren Werk » Sat Feb 02, 2008 6:31 pm

Same Script - New Method - New Name

I am using Player.Stop now, instead of Player.Pause, because I have discovered that Player.Stop does not cut off a little bit of the prior song and play it after the gap, the way Player.Pause does. This is good! I also found out how to turn off the progress indicator when the user starts the next song manually (by pressing (>) during the gap). This is also good! The only thing I am missing now, is a way to suppress the gap when I manually start a new song or set of songs.

Any suggestions anyone?
Is there any way to detect changes to the next song of the now playing list?

I changed the name of the script, because the old name reflects the old method used to create the gap. I like the new name better.

Code: Select all

'======================================================================
' MediaMonkey\Scripts\Auto\Gap.vbs
'
' Creates a gap between each song.
' Can be turned on and off with a button on the toolbar.
'
' 2008-02-02 - Soren Werk - www.tangoman.dk
'
' ToDo:
'   Defaults configurable in Options.
'   No gap when manual start of new song or set of songs.
'   Gap after "this" song instead of before next.
'======================================================================

Option Explicit

Const GapSeconds = 15
Const GapDefaultOn = True

Dim GapButton
Dim GapProgress
Dim GapTimer
Dim FirstSong : FirstSong = True
Dim AfterGap : AfterGap = False

Sub OnStartUp()
  InitButton
  InitPlayer
  InitTimer
End Sub

Sub InitButton()
  Set GapButton = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard,0,0)
  GapButton.IconIndex = 2
  GapButton.Caption = "Turn " & GapSeconds & " seconds gap on and off"
  Script.RegisterEvent GapButton, "OnClick", "GapButtonOnClick"
  If GapDefaultOn Then
    GapButtonOnClick(GapButton)
  End If
End Sub

Sub InitPlayer()
  Script.RegisterEvent SDB, "OnPlay", "PlayerOnPlay"
'  Script.RegisterEvent SDB, "WhichEvent??", "SetFirstSong"
End Sub

Sub InitTimer()
  Set GapTimer = SDB.CreateTimer(1000)
  GapTimer.Enabled = False
  Script.RegisterEvent GapTimer, "OnTimer", "GapOnTimer"
End Sub

'======================================================================

Sub GapButtonOnClick(Button)
  Button.Checked = not Button.Checked
End Sub

Sub PlayerOnPlay()
  GapTimer.Enabled = False
  Set GapProgress = Nothing
  If GapButton.Checked and not FirstSong and not AfterGap Then
    SDB.Player.Stop
    AfterGap = True
    Set GapProgress = SDB.Progress
    GapProgress.MaxValue = GapSeconds
    GapProgress.Text="Gap " & GapSeconds & " seconds."
    GapTimer.Enabled = True
  Else
    AfterGap = False
  End If
  FirstSong = False
End Sub

Sub SetFirstSong()
  FirstSong = True
End Sub

Sub GapOnTimer(Timer)
  GapProgress.Increase
  GapProgress.Text="Gap " & GapSeconds - GapProgress.Value & " seconds."
  If GapProgress.Value >= GapProgress.MaxValue Then
    If not SDB.Player.isPlaying Then
      SDB.Player.Play
    End If
    GapTimer.Enabled = False
    Set GapProgress = Nothing
  End If
End Sub

Getting better all the time!

by Soren Werk » Thu Jan 31, 2008 4:39 pm

Getting better all the time!

Allright - so I learned some more about UnRegistrerEvents from this Topic by Teknojnky with very relevant postings by trixmoto and jiri. Thank you very much!

I have only one problem left: How do I turn off the progress indicator when I click (>) to manually start a song during the pause? How do I detect a click on the (>) button.

Code: Select all

'======================================================================
' MediaMonkey\Scripts\Auto\PauseBefore.vbs
'
' Pauses a few seconds before each song, thus creating a gap between songs.
' Must be activated by clicking the PauseBefore button on the standard toolbar.
' Activate during first song play to avoid pause before the first song.
'
' 2008-01-31 - Soren Werk - www.tangoman.dk
'
' ToDo:
'   Turn off progress indicator when pressing (>) during the pause.
'   Cuts off a bit of the prior song and plays it after the pause.
'   Pause time should be configurable in Options.
'   Should pause *after* song instead of before.
'======================================================================

Option Explicit

Const PauseBeforeSeconds = 15

Dim PauseBeforeOn
Dim PauseBeforeButton
Dim PauseBeforeProgress
Dim PauseBeforeTimer
Dim FirstSongStarted

Sub OnStartUp()
  InitButton
  InitOnPlay
  InitTimer
End Sub

Sub InitButton()
  Set PauseBeforeButton = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard,0,0)
  PauseBeforeButton.IconIndex = 2
  PauseBeforeButton.Caption = "Turn 'PauseBefore' on and off"
  Script.RegisterEvent PauseBeforeButton, "OnClick", "OnPauseBeforeButtonClick"
  OnPauseBeforeButtonClick(PauseBeforeButton) ' Activate button
End Sub

Sub InitOnPlay()
  Script.RegisterEvent SDB, "OnPlay", "OnPlay"
End Sub

Sub InitTimer()
  Set PauseBeforeTimer = SDB.CreateTimer(1000)
  PauseBeforeTimer.Enabled = False
  Script.RegisterEvent PauseBeforeTimer, "OnTimer", "OnPauseBeforeTimer"
End Sub

'======================================================================

Sub OnPauseBeforeButtonClick(Button)
  Button.Checked = not Button.Checked
  PauseBeforeOn = Button.Checked
End Sub

Sub OnPlay()
  If PauseBeforeOn Then
    If FirstSongStarted Then
      SDB.Player.Pause
      Set PauseBeforeProgress = SDB.Progress
      PauseBeforeProgress.MaxValue = PauseBeforeSeconds
      PauseBeforeProgress.Text="Pause " & PauseBeforeSeconds & " seconds."
      PauseBeforeTimer.Enabled = True
    End If
  End If
  FirstSongStarted = True
End Sub

Sub OnPauseBeforeTimer(Timer)
  PauseBeforeProgress.Increase
  PauseBeforeProgress.Text="Pause " & PauseBeforeSeconds - PauseBeforeProgress.Value & " seconds."
  If PauseBeforeProgress.Value >= PauseBeforeProgress.MaxValue Then
    If SDB.Player.isPaused Then
      SDB.Player.Pause ' Start player again
    End If
    PauseBeforeTimer.Enabled = False
    Set PauseBeforeProgress = Nothing
  End If
End Sub

by Soren Werk » Thu Jan 24, 2008 6:27 pm

Thanks for the countdown bar Teknojnky - it works just fine!

Now I'm wondering why I can't turn off the PauseBefore effect? I thought Script.UnRegisterEvents SDB was supposed to take care of that - but it's not working! I guess I'll have to read more about Script.UnRegisterEvents and Script.UnRegisterAllEvents somewhere. It doesn't say much in the wiki.

By the way - I stopped using SDB.Objects as a container for my Button and I don't see any adverse effects of that.

Code: Select all

'======================================================================
' MediaMonkey AutoScript - GapBefore.vbs
'
' Pauses a few seconds before each song, thus creating a gap between songs.
' Must be activated by the new PauseBefore button on the standard toolbar.
' Should be activated during song play to avoid pause before the first song.
'
' 2008-01-24 - Soren Werk - www.tangoman.dk
'
' TODO:
'   PauseBefore cannot be turned off!!
'   Should pause *after* song instead of before
'   Pause time should be configurable in Options
'   Cuts off a bit of the prior song and plays it after the pause
'======================================================================

Option Explicit

Const GapSeconds = 10
Const OnIcon = 1
Const OffIcon = 2
Const OnCaption = "Turn off 'PauseBefore'"
Const OffCaption = "Turn on 'PauseBefore' (Pauses a few seconds before each song)"

Dim PauseProgress

Sub OnStartUp()
  AddToolbarButton_PauseBefore
End Sub

Sub AddToolbarButton_PauseBefore ()
  Dim Button : Set Button = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard,0,0)
  Button.IconIndex = OffIcon
  Button.Caption = OffCaption
  Button.OnClickFunc = "OnClickPauseBefore"
  Button.UseScript = Script.ScriptPath
End Sub

Sub OnClickPauseBefore(Button)
  Button.Checked = not Button.Checked
  If Button.Checked Then
    Button.IconIndex = OnIcon
    Button.Caption = OnCaption
    Script.RegisterEvent SDB, "OnPlay", "PauseBefore"
  Else
    Button.IconIndex = OffIcon
    Button.Caption = OffCaption
    Script.UnRegisterEvents SDB
  End If
End Sub

Sub PauseBefore()
  SDB.Player.Pause
  Dim Timer : Set Timer = SDB.CreateTimer(1000)
  Script.RegisterEvent Timer, "OnTimer", "UnPause"

  Set PauseProgress = SDB.Progress
  PauseProgress.MaxValue = GapSeconds
  SetProgressText
End Sub

Sub UnPause(Timer)
  PauseProgress.Increase
  SetProgressText

  If PauseProgress.Value = PauseProgress.MaxValue Then
    If SDB.Player.isPaused Then
      SDB.Player.Pause ' Turn off pause
    End If
    
    Script.UnregisterEvents Timer
    Set Timer = nothing
    Set PauseProgress = nothing
  End If
End Sub

Sub SetProgressText
  PauseProgress.Text="Pause between songs " & GapSeconds - PauseProgress.Value & " seconds."
End Sub

by Teknojnky » Wed Jan 23, 2008 6:01 pm

try this, should work (haven't tested)

Code: Select all

Sub PauseBefore() 
  SDB.Player.Pause 
  Dim Timer : Set Timer = SDB.CreateTimer(1000) 
  Script.RegisterEvent Timer, "OnTimer", "UnPause" 
  Dim Countdown : Set Countdown = SDB.Progress
  Countdown.Value = 0
  Countdown.MaxValue = GapSeconds+1
  Countdown.Text="Paused: " & Progress.Value & " of " Progress.MaxValue-1
End Sub 

Sub UnPause(Timer) 
  Countdown.Increase
  Countdown.Text="Paused: " & Countdown.Value & " of " Countdown.MaxValue-1

  If Coundown.Value = GapSeconds Then
    SDB.Player.Pause 
    Script.UnregisterEvents Timer 
  End If
End Sub 
edit: whoops fixed to countdown object not progress object :o

Countdown display?

by Soren Werk » Wed Jan 23, 2008 5:47 pm

Now I would like to display a countdown during the gap. 5 - 4 - 3 - 2 - 1
Any sugestions?

Top