Jump to content

Embed MPlayer in AU GUI


KaFu
 Share

Recommended Posts

Just what the title says :)...

For controlling the embedded MPlayer instance look up the MPlayer docu for the -slave switch here

http://www.mplayerhq.hu/DOCS/tech/slave.txt

and send commands / receive replies with stdin / stdout on $i_mplayer_pid.

#cs ----------------------------------------------------------------------------
   
    AutoIt Version: 3.3.0.0
    Author:         KaFu
   
    Script Function:
        Embedded MPlayer Test v03 (09-Jan-24)
   
#ce ----------------------------------------------------------------------------

#include<Constants.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>

$h_GUI_Main = GUICreate("Embedded MPlayer Test - Main Window", 800, 600, Default, Default, $WS_CLIPCHILDREN)

$c_button_play = GUICtrlCreateButton("Pause",250,520,100,30)
$c_button_mute = GUICtrlCreateButton("Mute",450,520,100,30)

$a_Pos_GUI_Main = WinGetPos($h_GUI_Main)
$h_GUI_Slave = GUICreate("Embedded MPlayer Test - Slave Window", $a_Pos_GUI_Main[2] - 100, $a_Pos_GUI_Main[3] - 100, $a_Pos_GUI_Main[0] + 50, $a_Pos_GUI_Main[1] + 50, $WS_POPUP)

$s_mplayer_location = 'C:\Programme\SMplayer\MPlayer.exe'
$s_media_location = 'C:\movies\test.avi'

$i_mplayer_pid = Run('"' & $s_mplayer_location & '" -slave -vo directx:noaccel -wid ' & Number($h_GUI_Slave) & ' "' & $s_media_location & '"', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)

_embed_GUI($h_GUI_Main, $h_GUI_Slave, 100, 50, $a_Pos_GUI_Main[2] - 200, $a_Pos_GUI_Main[3] - 150)

GUISetState(@SW_SHOW, $h_GUI_Main)
GUISetState(@SW_SHOW, $h_GUI_Slave)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
            
        Case $msg = $c_button_play
            Select
                Case GUICtrlRead($c_button_play) = 'Play'
                    GUICtrlSetData($c_button_play,'Pause')
                Case Else
                    GUICtrlSetData($c_button_play,'Play')
            EndSelect
            StdinWrite($i_mplayer_pid, "pause" & @LF)
            
        Case $msg = $c_button_mute
            Select
                Case GUICtrlRead($c_button_mute) = 'Mute'
                    GUICtrlSetData($c_button_mute,'Unmute')
                Case Else
                    GUICtrlSetData($c_button_mute,'Mute')
            EndSelect
            StdinWrite($i_mplayer_pid, "mute" & @LF)
            
    EndSelect
WEnd

ProcessClose($i_mplayer_pid)
Exit

Func _embed_GUI($h_Wnd_outer, $h_Wnd_inner, $x, $y, $w = "", $h = "")
    $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $h_Wnd_inner, "int", -20)
    $nExStyle = $nExStyle[0]
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $h_Wnd_inner, "int", -20, "int", BitOR($nExStyle, $WS_EX_MDICHILD))
    DllCall("user32.dll", "int", "SetParent", "hwnd", $h_Wnd_inner, "hwnd", $h_Wnd_outer)
    WinMove($h_Wnd_inner, "", $x, $y, $w, $h)
EndFunc   ;==>_embed_GUI
Edited by KaFu
Link to comment
Share on other sites

hi great work :-)

i wanted to write a real player now from the whole mplayer code, along with playlists etc.

good thing about mplayer is it can read flv files natively..

i also need a new player to sort out my music library - features is need is to "delete this fiel from HD" and also "delete all files from this artist "--

evtl können wir da mal was zusammen machen?

gruss nobbe

Link to comment
Share on other sites

hi great work :-)

Thanks :lmao:

i wanted to write a real player now from the whole mplayer code, along with playlists etc.

good thing about mplayer is it can read flv files natively..

Generally I'm always open-minded to new ideas :) , but in this case I don't think its worth the effort to write a new MediaPlayer from the scratch, sorry, just to much work for the framework to add one or two extra features. Have you tried this frontend for MPlayer? It's currently my standard player (+ VLC for some files)

http://mulder.dummwiedeutsch.de/home/?page=projects#mplayer

Maybe it's more easy to ask them for an additional feature.

i also need a new player to sort out my music library - features is need is to "delete this file from HD" and also "delete all files from this artist "--

Here I can only recommend my program SMF to you :think:, analyze your media files with 'Extended File Attributes' checked, might take some time (maybe overnight?), but you can run it in the background and save the database for later use. In the report you can filter by all relevant criteria, incl. ID3 tags, folder and filenames, and than mass delete/erase your selection. That should suite your needs with already existing programs.

Best Regards, Gruss

Edited by KaFu
Link to comment
Share on other sites

Havent tested yet but looks much cleaner then the method i used in the GTplayer, created a Label there and used the label hwnd for the -wid option. Problem was if i entered fullscreen and then returned from it the mplayer window was hidden behind the label. I had to work around it by coloring the whole gui with mplayer colorkey. Good work :)

Link to comment
Share on other sites

Havent tested yet but looks much cleaner then the method i used in the GTplayer, created a Label there and

Thanks :). Didn't saw you're Player before, will take a deeper look later on. I always love this playing around with mplayer, great program.

used the label hwnd for the -wid option.

Tried it before and had problems too, guess the clue was as ProgAndy pointed out here

#633183

'you forgot to convert the hWnd to an Integer.' with something like Number($hWnd)

Cleaned and reduced the source to necessary parts in first post.

Best Regards

Edited by KaFu
Link to comment
Share on other sites

  • 2 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...