Resume Play or Pause at MM start-up v2.2/3.1 [Script]

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

Moderators: Peke, Gurus

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Resume Play or Pause at MM start-up v2.2/3.1 [Script]

Post by DiddeLeeDoo »

Resume Pause or Play at startup of MediaMonkey

If you left a song playing when MediaMonkey closed, it will resume playing if you start MediaMonkey within a timeout period set for 30 minutes, otherwise song will be paused at the position you left it.

==============================================
MediaMonkey v2.5

Changelog:
2.10 - 2.20 : Tuned up to do as little as possible (12 December 2006)

Install ResumePlay for MM 2.5
Open zip, and just double click the install file.

Uninstall = Remove file \Program Files\MediaMonkey\Scripts\Auto\ResumePlay.vbs

==============================================
MediaMonkey v3.0

Changelog:
3.0 Added delay timer due to slow reaction from MM3
3.1 Replaced delay timer with dynamic timer, to allow for various delay needs.

Install ResumePlay for MM 3.0

==============================================


The timeout period can be set in this line in the script

Code: Select all

TimeOut=30 'in Minutes

Code: Select all

'---------------------------------------------------------------
' \Program Files\MediaMonkey\Scripts\Auto\ResumePlay.vbs
'
' Version: 3.1 
' Date: 7 January 2008
' By DiddeLeeDoo
'---------------------------------------------------------------
Sub OnStartUp
    Set TMR=SDB.CreateTimer(100)
    With SDB.Registry
        If .OpenKey("Resume Play", False) Then
            If  .BoolValue("Unfinished") Then
                .BoolValue("Unfinished")=False
                If .BoolValue("Played") And _
                    DateDiff("s",Now,.StringValue("TimeOut"))>0 Then
                    SDB.Player.Play
                    Script.RegisterEvent TMR, "OnTimer","WasPlaying" 
                Else
                    SDB.Player.Play
                    Script.RegisterEvent TMR, "OnTimer","WasPaused" 
                End If
            End If
           .CloseKey
        End If
    End With
    Script.RegisterEvent SDB,"OnShutdown","CheckPlaying"
End Sub

Sub WasPlaying(TMR)
    With SDB.Registry
        If .OpenKey("Resume Play", False) Then
         x=.IntValue("StoppedAt")
            SDB.Player.PlayBackTime=x
            
           .CloseKey
        End If
    End With
    If SDB.Player.PlayBackTime=>x Then Script.UnregisterEvents TMR
End Sub

Sub WasPaused(TMR)
    With SDB.Registry
        If .OpenKey("Resume Play", False) Then
         x=.IntValue("StoppedAt")
            SDB.Player.PlayBackTime=x
            SDB.Player.Pause
           .CloseKey
        End If
    End With
    If SDB.Player.PlayBackTime=>x Then Script.UnregisterEvents TMR
End Sub

Sub CheckPlaying
    If  SDB.Player.isPlaying Then
        Played=Not SDB.Player.isPaused
        TimeOut=30 'in Minutes
        With SDB.Registry
            If .OpenKey("Resume Play", True) Then
               .BoolValue("Unfinished")=True
               .BoolValue("Played")    =Played
               .IntValue("StoppedAt")  =SDB.Player.PlaybackTime
               .StringValue("TimeOut") =DateAdd("n",TimeOut,Now)
               .CloseKey
            End If
        End With
    End If
End Sub
Last edited by DiddeLeeDoo on Mon Jan 07, 2008 9:44 am, edited 32 times in total.
Image
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Nice simple script - I like it!

I also like the fact that you use the registry. At first I thought this was bad because my MM is installed on an external harddrive so each computer I used it on would start from the last place that computer was. But as the Now Playing list is stored individually on each computer, this actually works perfectly! :)
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.
westis
Posts: 4
Joined: Wed May 24, 2006 3:53 pm

Post by westis »

Thanks indeed! Works great! :)
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

It would be nice if this script is put in the TweakMonkey script.
(see http://www.mediamonkey.com/forum/viewto ... 3930#43930 and next)

At least, that's my philosophy too (many of my old "scripts" are now integrated in the TweakMonkey script :cry: :D (mixed feeling)).

If Teknojnky is nice (and he usually is :P), he should put your name together with the piece of code, if that would be an issue.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Thank you for your comment on that. I already use an improved version of this script, but haven't bothered posting it here yet.

Hopefully over time the scripting ‘bank’ will have an improved layout in order to make it more attractive to do contributions.
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Just a little note about that I changed the Script Page above. Now when I feel I have a script I can nurture, and look after.

I improved it by adding a Timeout period for Resume Play at start-up.
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Just another note, since I try to keep the script at the beginning of this thread.

Added Fade-In to the script too... so now I start to feel it's more a complete stand alone script.
Image
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Nice, nice, nice. A must-have for my collection :D.

One remark: please make the "Fade-In" optional (so it can be enabled/disabled in the beginning of the script, as also the timeout can be set). This is because my output plugin already does the fading in, so I don't want the script to do it too.

BTW: I already had a fading-in idea for the "tts sa". But maybe the fading period there is to short to notice. (and I thought the fast volume changing would take "too much" performance)

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I thought this 1.2 seconds with fade-in should not be that much of a big problem as several conditions have to be met for it to actually start playing and fading in.

Firstly you have to close MediaMonkey when a song is playing. Secondly you have to restart MediaMonkey within half an hour for the fade-in and play starts. Otherwise the script do nothing at all.

But it's easy to make options, and I'm thinking about another feature too, so I'll include that in next version.
Image
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Ok, I can't seem to see where the initial registry key is set.

"Resume Play" ???

How does this ever get set "True"?

edit:

Nevermind, I think I understand now, "Resume Play" is the key, the other things are values under the key.

"Resume Play" is always true if windows can open or create it (I am assuming).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I saw you already have some volume control in your script Teknojnky, or is it Steegy's script? Steegy have mentioned the value of keeping things separate, and I agree with that.

I would find it confusing if all of Trixmoto's scripts were in TweakMonkey too for example.

To some extent you leave me feeling like a bird laying eggs, and you collect the eggs. I feel this take away my motivation for laying eggs and nurture them, as it is after all it is a totally voluntaire thing to do.

I try to do things that’s not done before, which makes this forum of limited value to me in regards to finding how to do things.

Hopefully the future ‘Easy Find & Install Script’ will reduce the need for an ‘All in One’ script, which I know you’re motivated for.

This is not meant as bad criticism, but more a ‘Let the bird who laid the egg, nurture the egg’ sort of thing, which I believe long term will benefit all of us.
Image
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

There is a start up volume control in tweakmonkey, I don't think it has anything from Steegy's scripts.. not intentionally anyway.

You can remove the volume 'pop' by setting the volume to zero, setting the play position, then restoring the previous volume.

Code: Select all

Sub OnStartUp 
Set Regs = SDB.Registry 
 If Regs.OpenKey("Resume Play", True) Then 
  If Regs.BoolValue("Unfinished") Then 
     If Regs.BoolValue("Played") Then 
        TempVolume = SDB.Player.Volume
        SDB.Player.Volume = 0
        SDB.Player.Play 
        SDB.Player.PlayBackTime=Regs.IntValue("StoppedAt") 
        SDB.Player.Volume = TempVolume
     Else 
        TempVolume = SDB.Player.Volume
        SDB.Player.Play 
        SDB.Player.PlayBackTime=Regs.IntValue("StoppedAt") 
        SDB.Player.Pause 
        SDB.Player.Volume = TempVolume
     End If 
  End if 
  Regs.CloseKey 
 End If 
Script.RegisterEvent SDB,"OnShutdown", "CheckPlaying" 
End Sub 
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I haven't tried this variation Teknojnky. If you say it is an alternative I take your word for it.

I have yet to find any problems with that this very simple fade-in. It does about 10 tiny volume changes over 1.2 seconds, which should be a piece of cake for even a 386 computer.

Nice to see there's an alternative to the start-up play function though. Thanks.
Image
uncl-nis
Posts: 9
Joined: Thu Apr 20, 2006 1:22 pm

MM freezes when using Ozone

Post by uncl-nis »

hey DiddeLeeDoo,

it was very nice to see that someone made a script like this for MM, something like this seems so required.
But i have a problem with it when using OZONE dsp ustility

http://www.quinnware.com/list_plugins.php?plugin=103

MM simply freezes unitl i kill it with Task Manager. if i turn OZONE off the script works just fine. have you any suggestions?

Thanks, Rudy
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

:o Don't use OZone?

i use the old wide & dynamic dsp plug in . of course i use 16 bit sound cards but that plugin does not mess with anything.

i think the ozone plugin might be hogging ram. or resources.

8)
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.
Post Reply