Sign in to follow this  
Followers 0
nobbe

Mplayer GUI

7 posts in this topic

#1 ·  Posted (edited)

a simple gui to control MPLAYER and retrieve information from it too

; www.mplayerhq.hu/
; http://www3.mplayerhq.hu/MPlayer/releases/win32/MPlayer-mingw32-1.0rc2.zip
;

#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>

$GUI = GUICreate("Mplayer Gui", 633, 233, 193, 115)
$btn_back = GUICtrlCreateButton("<<", 16, 132, 75, 25, 0)
$lbl_artist = GUICtrlCreateLabel("lbl_artist", 28, 8, 442, 17)
$lbl_titel = GUICtrlCreateLabel("lbl_titel", 28, 36, 436, 17)
$lbl_time = GUICtrlCreateLabel("lbl_time", 28, 84, 223, 17)
$btn_pause = GUICtrlCreateButton("pause", 100, 132, 75, 25, 0)
$btn_forward = GUICtrlCreateButton(">>", 180, 132, 75, 25, 0)
GUISetState(@SW_SHOW)

Global $pause = 0;

AdlibEnable("_my_timer_adlib", 300) ; every 1/3 sec


$mplayerpid = Run('mplayer.exe -slave -quiet test.mp3', @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        
        Case $btn_forward ;
                StdinWrite($mplayerpid, "seek +10" & @LF) ;
            

        Case $btn_back ;
            
            StdinWrite($mplayerpid, "seek -10" & @LF) ; 


        Case $btn_pause

            ; toggle
            If $pause = 0 Then
                
                StdinWrite($mplayerpid, "pause" & @LF) ;
                
                If @error = -1 Then
                    ConsoleWrite("error sending pause" & @CRLF);
                EndIf
                
                $pause = 1
                
            ElseIf $pause = 1 Then
                
                StdinWrite($mplayerpid, "pause" & @LF) ;
                
                If @error = -1 Then
                    ConsoleWrite("error sending pause" & @CRLF);
                EndIf
                
                $pause = 0
            EndIf
            
            
        Case $GUI_EVENT_CLOSE ;ok
            ProcessClose($mplayerpid)
            Exit

    EndSwitch
    
WEnd

;
;
;
Func _my_timer_adlib()
    
        $pos = 0
        $max = 0
    
    If $mplayerpid And $pause = 0 Then
        StdinWrite($mplayerpid, "get_meta_artist" & @LF) ; right arrow
        StdinWrite($mplayerpid, "get_meta_title" & @LF) ; right arrow
        StdinWrite($mplayerpid, "get_time_pos" & @LF) ; right arrow
        StdinWrite($mplayerpid, "get_time_length" & @LF) ; right arrow
        $c = StdoutRead($mplayerpid)
        ConsoleWrite($c & @LF);-- for debugging only
        

        
        If StringInStr($c, "ANS_META_ARTIST") > 0 Then
            
            $tmp = _StringBetween($c, "ANS_META_ARTIST='", "'")
            $artist = StringStripWS($tmp[0], 7)
            GUICtrlSetData($lbl_artist, $artist)

        EndIf


        If StringInStr($c, "ANS_META_TITLE") > 0 Then

            $tmp = _StringBetween($c, "ANS_META_TITLE='", "'")
            $title = StringStripWS($tmp[0], 7)
            
            GUICtrlSetData($lbl_titel, $title)
        EndIf


        ;; time ?
        If StringInStr($c, "ANS_TIME_POSITION") > 0 Then

            $tmp = _StringBetween($c, "ANS_TIME_POSITION=", @CRLF)
            $pos = StringStripWS($tmp[0], 7)
            
        EndIf

        ;; time ?
        If StringInStr($c, "ANS_LENGTH=") > 0 Then

            $tmp = _StringBetween($c, "ANS_LENGTH=", @CRLF)
            $max = StringStripWS($tmp[0], 7)
            
        EndIf


        ;; set only if we have the time 
        GUICtrlSetData($lbl_time, $pos & " - " & $max)
    EndIf

EndFunc   ;==>_my_timer_adlib
Edited by nobbe

Share this post


Link to post
Share on other sites



Sorry, I thought I had Mplayer but was wrong. I found many different downloads. Which was your script written around? Do you have a download link you can share?

Share this post


Link to post
Share on other sites

i update script

Share this post


Link to post
Share on other sites

Does anyone know if this runs with wine?

Or if mplayer.exe runs with wine, or how to use system-commands? ^^

Share this post


Link to post
Share on other sites

OK I just tested it - it also works with wine!

Know I'm able to create a playengine for PPlayer running on Linux ^^

thanks :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

I just came upon this topic, installed MPlayer and run the script.

Unfortunatly I get an error at line 20:

'AdlibEnable("_my_timer_adlib", 300)

^ ERROR

Error: Unknown function name.'

I can't figure out where the error could come from, as the "_my_timer_adlib" function is defined from line 75 downwards.

Does anyone else get the same error message and have an idea where the problem comes from?

Kaba

Edited by Kaba

Share this post


Link to post
Share on other sites

this is an old topic, using an earlier version of autoit. that function has been removed and replaced.


ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0