Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to catch data from VLC StatusBar Text (time)


  • Please log in to reply
6 replies to this topic
Cher
  • Members
  • 2 posts
  • Last active: Jan 22 2011 10:35 PM
  • Joined: 22 Jan 2011
I am building a observation-timer-script.
The script will start the film and when i see something interesting i can push on AHK button, then this will pause the film and then i write the time and the observation to a csv file.
How can i catch the time from the playing/pause film (VLC) ?
(data form VLC Status bar)
/* 
	2011-01-19
	Cher Adamczyk
	observation timer program
	
	small part for testing
	<test  get_time from VLC ??>

*/
; Generated using SmartGUI Creator 4.0
;==========GUI 1:=========================================================
Gui, Add, Button,  x020 y020  w070 h030               , Start
Gui, Add, Button,  x020 y060  w070 h030               , Finish
Gui, Add, Button,  x020 y100  w120 h030  vPauzeOnOff  , PauzeOnOff
  PauzeH = Pauze-OFF
  GuiControl, Text, PauzeOnOff, %PauzeH%
Gui, Add, Button,  x020 y140  w120 h030               , VLCtestCom
Gui, Add, Button,  x020 y200  w120 h030               , VLCGetTime
  
Gui, Show, x000 y000 w200 h240, Cher(NL) test how to get time from VLC
Return

;=====How can I get the actual time from VLC like get_time on console=======================;
;=====I want to write this to cher.csv =====================================================;
ButtonVLCGetTime:
    gosub ButtonPauzeOnOff
    inputbox, Chertime, ,What is the observation time?
    inputbox, Cherobserv, ,Wich observation?   
	MsgBox, record  %Chertime%  %Cherobserv%
	FileAppend, %Chertime%`,%Cherobservation%`n , %WorkingDir%Cher.csv  	
    gosub ButtonPauzeOnOff	
  return

/*
    
	;     get_time    {t}  
	;  ControlGet, vlcHwnd, hwnd, , ToolbarWindow321, VLC media player 
	;    ControlSend, CherGetTime , {t}, ahk_id %vlcHwnd%
	WinGetText, wText, VLC media player 
	;WinGet, wText, id, VLC media player 
	MsgBox, %wText%
	Loop, Parse, wText, `n, `r 
	{ 
	  if A_Index = 1 
	    Var1:=A_LoopField 
	  if A_Index = 3 
	  { 
	    Var2:=A_LoopField 
	    break 
	  } 
	} 
	MsgBox % Var1 "`n" Var2

	  MsgBox, CherGetTime  %CherGetTime%
	  FileAppend, CherGetTime`;%CherGetTime%`n , %WorkingDir%Cher.csv  

  return  		
*/  
  
;==========================================================================================;
ButtonVLCtestCom:
  InputBox, HlpVLC, type VLC comand, "space/t/get_time/..."  
  ControlGet, vlcHwnd, hwnd, , ToolbarWindow321, VLC media player 
    ControlSend, , %HlpVLC%, ahk_id %vlcHwnd%
    msgbox, ButtonVLCtestCom timeout    
  return
;  
Buttonstart:      ; start VLC & film
  IfWinExist, VLC 
    WinClose, VLC  
           ; put your own path and film    
  runwait, %WorkingDir%#VLC\Exec\VLCPortable.exe %WorkingDir%#film\2007_0717Lefkas0261.AVI
  Return
;
ButtonFinish:     ;===close VLC====
  IfWinExist, VLC 
    WinClose, VLC
  MsgBox, 4, , Finish = Yes  restart = No  ; 'new' video or finish
  IfMsgBox, Yes      
    GuiClose:
    ExitApp
  return   
;
ButtonPauzeOnOff: ;----Pauze/Play -- {space}
  ControlGet, vlcHwnd, hwnd, , ToolbarWindow321, VLC media player 
    ControlSend, , {space}, ahk_id %vlcHwnd%  
  If PauzeH = Pauze-ON
     PauzeH = Pauze-OFF
  Else
     PauzeH = Pauze-ON
  GuiControl, Text, PauzeOnOff, %PauzeH%   
  return


specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
I think this will help you. A few weeks ago I figured out how to use AHK to control VLC using the HTTP interface. I posted a partial list of available commands.
http://www.autohotke...6527&highlight=

Notice the commands all use the AHK command Download to File. Any time you send a command to VLC through HTTP it writes a log file to your computer. In this file is all the data about VLC'S status at the moment the command was issued, including the current position and total length of media. I have not payed much attention to this file but I'm almost positive it's returned for every command, if not there is a command to call it.

The information written to the file is a very specific format and every time you call the file it overwrites the last information so the information is always on the same line of the file every time you read it. Using a FileReadLine can easily retrieve your data.

One of the possibilities of this file is to have a playing position in your gui that is reading VLC's information in real time.

Al I said this is only a short list of basic commands but the full list is in the HTTP file in VLC's program folder and my example will show you the way to use it. Hope this works for you.

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
This code will retrieve the time from VLC.
gui, add, text, vvlcTime, AHK VLC Time view:  00:00/--:-- 
gui show

loop {
  setTitleMatchMode, Slow
  winGetText, winText, ahk_class QWidget
  guiControl, text, vlcTime, % "AHK VLC Time view: "
				. subStr( winText, 1, inStr( winText, "`r" ) )
}

esc::exitapp ; <- press escape to exit.
Posted Image

Note: VLC must be in 'control show' mode.
To invoke controls, show a docked playlist.

hth

Posted Image

don't duplicate, iterate!


Cher
  • Members
  • 2 posts
  • Last active: Jan 22 2011 10:35 PM
  • Joined: 22 Jan 2011
Thanks for the shearing information.
I had read this information earlier but I didn’t understand it enough.
Also the portable version of VLC that I had downloaded time ago didn’t work with HTTP.
So after download the latest version of VLC and change my program it works.
This is the solution that works for me.
/* 
	2011-01-19
	Cher Adamczyk
	observation timer program
	
	small part for testing
	<test  get_time from VLC ??>

*/
;=====How can I get the actual time from VLC like get_time on console=======================;
;=====I want to write this to cher.csv =====================================================;

; Generated using SmartGUI Creator 4.0
; initiele waarde
  PauzeH = Pauze-OFF
;==========GUI 1:=========================================================
Gui, Add, Button,  x020 y020  w070 h030               , Start
Gui, Add, Button,  x020 y060  w070 h030               , Finish
Gui, Add, Button,  x020 y100  w120 h030  vPauzeOnOff  , PauzeOnOff
  PauzeH = Pauze-OFF
  GuiControl, Text, PauzeOnOff, %PauzeH%
Gui, Add, Button,  x020 y200  w120 h030               , GetTime

Gui, Add, Button,  x020 y260  w120 h030               , Trashfile

Gui, Add, Button,  x020 y300  w120 h030               , SeekRelative

Gui, Add, Button,  x020 y340  w120 h030               , SeekAbselute
Gui, Show, x000 y000 w600 h440, Cher(NL) test how to get time from VLC
Return
;==========================================================================================;
ButtonStart:  ; start VLC film
VLC-start:
  run, %WorkingDir%#VLC\VLC.exe --intf qt --extraintf http %WorkingDir%#film\2007_0717Lefkas0261.AVI     
;  run, %WorkingDir%#VLC\VLC.exe vlc --intf qt --extraintf http %WorkingDir%#film\2007_0717Lefkas0261.AVI  
  sleep, 7000 ; wait until film is started 
  Return 

ButtonFinish:
VLC-Finish:
  IfWinExist, VLC 
    WinClose, VLC
  UrlDownloadToFile, http://127.0.0.1:8080/?control=stop, trashfile
  UrlDownloadToFile, http://127.0.0.1:8080/?control=shutdown, trashfile
  GuiClose:
  ExitApp  
  return

ButtonPauzeOnOff: ;----Pauze/Play -- {space}
VLC-Pauze-On-Off:
  UrlDownloadToFile, http://127.0.0.1:8080/?control=pause, trashfile
  return 
  
ButtonTrashfile:
VLC-Trashfile:
  FileRead, TrashfileH, trashfile
  MsgBox, trashfile `n `n%TrashfileH%  
return


ButtonSeekRelative:       ;start via button
VLC-Seek-Relative:
  InputBox, SeekV, VLC positie, Film vooruit/achteruit seek time, , , , , , , ,0 
  if errorLevel = 1
     return     
  If SeekV > 0  
     UrlDownloadToFile, http://127.0.0.1:8080/requests/status.xml?command=seek&val=`%2B%SeekV%, trashfile
  If SeekV < 0
     UrlDownloadToFile, http://127.0.0.1:8080/requests/status.xml?command=seek&val=%SeekV%, trashfile
  return

ButtonSeekAbselute:         ;start via button
VLC-Seek-Absolut:
  InputBox, SeekV, VLC positie, Film spring naar seek time, , , , , , , ,0
  if errorLevel = 1
     return     
  UrlDownloadToFile, http://127.0.0.1:8080/requests/status.xml?command=seek&val=%SeekV%, trashfile   
  return

ButtonGetTime:         ;start via button
VLC-GetTime:
  UrlDownloadToFile, http://127.0.0.1:8080/requests/status.xml?command=volume&val=`%2B10.24,  trashfile ;  
  RecTel = 0
RecTelTime:
  RecTel := RecTel + 1
  if rectel >200  
    return
  FileReadLine, Trashrec,     trashfile, %RecTel%  
  if ErrorLevel
    {
    msgbox %LeesSchrijfFile% -error reading- %A_Index%
    return
    }
  IfInString, Trashrec, </time>   ;  <time>15</time>
    {      
     StringGetPos, RecPos1, Trashrec, <time> 
     RecPos1 := RecPos1 + 7
     StringGetPos, RecPos2, Trashrec, </time> 
     RecPos2 := RecPos2 - RecPos1 + 1
     StringMid, CatchTime, Trashrec, %RecPos1%, %RecPos2% 
     msgbox, CatchTime %CatchTime%  trashrec %trasrec%
     return
    }
  goto RecTelTime
  return


specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
Glad I could help. If your interested I started making a library of the VLC Http commands although I haven't gotten any farther than the same commands I had already documented.
https://ahknet.autoh...VLC/VLCHTTP.ahk

The only difference between this and what you have already is instead of using the entire command in your script a simple library call does the same thing. The commands I have so far are,
VLCHTTP_Pause()
VLCHTTP_Play()
VLCHTTP_Stop()
VLCHTTP_FullScreen()
VLCHTTP_JumpForward()
VLCHTTP_JumpBackward()
VLCHTTP_VolumeUp()
VLCHTTP_VolumeDown()
So you could simply use one of these calls anywhere you have the entire command in your script.

Also just to be clear I used the term "trashfile" while figuring out the commands, before I knew what would be contained in the return data file. It's actually just a text file so it could be named anything.txt although in the library I called it "return.vlc". This gives it a VLC icon and lets you know it related to VLC media player although it is still just a text file.

Good job on your script, glad this worked for you.

Jebus
  • Members
  • 5 posts
  • Last active: Nov 13 2015 03:38 PM
  • Joined: 14 Aug 2015

Sorry to bring up an ancient thread, but I was just wondering if anyone knows of a simple way to copy VLC's current time position to the clipboard using AHK?

 

I've tried messing around with some of what is posted above, but haven't been able to get anything to work properly. Thanks



Jebus
  • Members
  • 5 posts
  • Last active: Nov 13 2015 03:38 PM
  • Joined: 14 Aug 2015

Anyone?