[MPlayer-users] resume playback after closing mplayer

Paul Bartlett paul.bartlett at ozemail.com.au
Thu Jul 14 14:19:46 CEST 2005


Thankyou all for your assistance.  I found that my config file had quiet=yes
in it so I wasn't getting the frame count in my stdout.

Now that I have found and turned that off, I now get the frame count and I
have managed to put together a vb script to record the completion time and
be able to start again at that point.

Here it is if anyone else is interested (bit of a hack but it works for me:






Function TrapEndFrameFromRunningMplayer(FileToPlay,ss)
	Dim WshShell, oExec
	Set WshShell = CreateObject("WScript.Shell")
	TrapEndFrameFromRunningMplayer = 0
	GroupMembership = ""
	
	Set oExec = WshShell.Exec("""C:\Program Files\mplayer\MPlayer.exe""
-fs -osdlevel 3 -ss " & ss & " """ & FileToPlay & """")
	'wait for programme to finish
	LastLine=""
	Do While oExec.Status = 0
		WScript.Sleep 100		'delay for 1/10 of a second
		Do While Not oExec.StdOut.AtEndOfStream
			LastLine=oExec.StdOut.Readline()
			If left(LastLine,2)="A:" Then
				RelevantLine=LastLine
			end If
		Loop

	Loop

'	wscript.echo "LastLine " & LastLine
'	wscript.echo "RelevantLine " & RelevantLine
	SlashPoint=instrrev(RelevantLine,"/")
'	wscript.echo SlashPoint
	SpacePoint=instr(SlashPoint,RelevantLine," ",1)
'	wscript.echo SpacePoint
	TrapEndFrameFromRunningMplayer =
mid(RelevantLine,SlashPoint+1,SpacePoint-SlashPoint-1)
End Function

'---------------------------------------------------------------------------
----------------

Sub RecordStopPoint(MediaFile,StopSeconds)
	Set WshShell = WScript.CreateObject("WScript.Shell")

	strResumeKey = "HKCU\Software\paul_ahb scripting\MPlayer\Resume\" &
MediaFile & "\"
	StopPointValue = strResumeKey & "Stop Point"
	LastViewedValue = strResumeKey & "Last Viewed"
	LastViewedIntegerValue = strResumeKey & "Last Viewed Integer"
	
	
	WshShell.RegWrite StopPointValue, StopSeconds, "REG_DWORD"
	WshShell.RegWrite LastViewedValue, now(), "REG_SZ"
	WshShell.RegWrite LastViewedIntegerValue, now(), "REG_DWORD"
End Sub

'---------------------------------------------------------------------------
----------------

Function GetStartSeconds(MediaFile)
	On Error Resume Next
	GetStartSeconds="0"
	Set WshShell = WScript.CreateObject("WScript.Shell")

	GetStartSeconds = WshShell.RegRead("HKCU\Software\paul_ahb
scripting\MPlayer\Resume\" & MediaFile & "\Stop Point")

End Function

'---------------------------------------------------------------------------
----------------

Sub Main()
	
	If WScript.Arguments.count > 0 Then
	
		PlayFile=WScript.Arguments.Item(0)
		
		StartSeconds=GetStartSeconds(PlayFile)
		
	
EndFrame=TrapEndFrameFromRunningMplayer(PlayFile,StartSeconds)
		StopSeconds=int(EndFrame/25)
		RecordStopPoint PlayFile,StopSeconds
	Else
		wscript.echo "No file specified to play"
	End If

End Sub

'---------------------------------------------------------------------------
----------------

main()





More information about the MPlayer-users mailing list