Sign in to follow this  
Followers 0
svennie

Windows Media Player Object

14 posts in this topic

Is it possible with the new Object functions (ObjCreate, GUICtrlCreateObj etc.) to play a video in a GUI using Windows Media Player?

It needs to play files on the web and my script must can select the position... More would be great.

Oh yeah, i not want to create my own Media Player.

Just want to view some little movies on the web but some times they are to big so i want to play already even if its not done with loading (like in WMP, that the reasons i want to use that).

Thanks already B) .


Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites



yes it is possible

; Open the MediaPlayer on a computer
$oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1")

If not @error then
    Msgbox(0,"Remote ObjCreate Test","ObjCreate() of a Mediaplayer Object successfull !")
    $oRemoteMedia.Open("c:\windows\media\Windows XP Startup.wav")   ; Play sound if file is present
Else
    Msgbox(0,"Remote ObjCreate Test","Failed to open Object. Error code: " & hex(@error,8))
Endif

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

forget that

this is what you want... its one of my favorites also

#include <GUIConstants.au3>
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; The full example is available in the test\ActiveX directory (TestXInternet.au3)
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp

$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
GUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX      = GUICtrlCreateObj   ( $oIE,     10, 40 , 600 , 360 )
$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     10, 420, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 120, 420, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    230, 420, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    330, 420, 100,  30)

GUISetState ()    ;Show GUI

$oIE.navigate("http://www.flurl.com/featured/Home_made_stickman_clip_89.html")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

forget that

this is what you want... its one of my favorites also

#include <GUIConstants.au3>
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; The full example is available in the test\ActiveX directory (TestXInternet.au3)
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp

$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
GUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX         = GUICtrlCreateObj      ( $oIE,      10, 40 , 600 , 360 )
$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     10, 420, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 120, 420, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    230, 420, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    330, 420, 100,  30)

GUISetState ()      ;Show GUI

$oIE.navigate("http://www.flurl.com/featured/Home_made_stickman_clip_89.html")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit

8)

This just embeds a HTML page with a video, but i need to go to a position in the file.

This is not possible at this way.


Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

This just embeds a HTML page with a video, but i need to go to a position in the file.

This is not possible at this way.

The VideoLAN media player can play incomplete media files, and supports a large range of codecs. Give it a try.

I'm not sure how well it will take to being scripted however...

Share this post


Link to post
Share on other sites

The VideoLAN media player can play incomplete media files, and supports a large range of codecs. Give it a try.

I'm not sure how well it will take to being scripted however...

The problem is not i dont know any media player, i want to use Windows Media Player but i don't know how to embed this in a GUI B) .

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

Can really nobody help me? :o

I really need it.

Thanks already B) .


Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

You can use manny different embedded objects in autoit3 gui - Shockwave, MS Media player, Quicktime, Realplayer, VCL...

The trouble is to locate real documentations, here is a quick maplayer example, Note there is the documentation GUIDE link attached...

; Author:   Kåre Johansson
; AutoIt Version: 3.1.1.84
; Description: Very Simple example: Embedding MSPlayer object
; Date: 25 Oct 2005

#include <GUIConstants.au3>

GUICreate ("Embed MSWebDVD control", 670,405, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 0, 385, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)

$1C = GUICtrlCreateButton('Play',105,382,70,20)
$2C = GUICtrlCreateButton('Pause',175,382,70,20)
$3C = GUICtrlCreateButton('Showmenu',245,382,70,20)

$oRP = ObjCreate("WMPlayer.OCX.7")
GUICtrlCreateObj( $oRP, 10, 10 , 650 , 365 )
GUISetState();Show GUI

With $oRP; Object tag pool
    
    .fullscreen = false
    .LaunchURL('?.wmv')
;.openplayer('?.wmv')
EndWith

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={6BF52A52-394A-11D3-B153-00C04F79FAA6}','', @SW_HIDE)
        Case $msg = $1C
        
        Case $msg = $2C
        
        Case $msg = $3C
    EndSelect
WEnd
$oRP = 0; free the embedded object
GUIDelete ()
Exit

Hope this would help you...

kjactive B)

Share this post


Link to post
Share on other sites

You can use manny different embedded objects in autoit3 gui - Shockwave, MS Media player, Quicktime, Realplayer, VCL...

The trouble is to locate real documentations, here is a quick maplayer example, Note there is the documentation GUIDE link attached...

; Author:    Kåre Johansson
; AutoIt Version: 3.1.1.84
; Description: Very Simple example: Embedding MSPlayer object
; Date:    25 Oct 2005

#include <GUIConstants.au3>

GUICreate ("Embed MSWebDVD control", 670,405, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 0, 385, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)

$1C = GUICtrlCreateButton('Play',105,382,70,20)
$2C = GUICtrlCreateButton('Pause',175,382,70,20)
$3C = GUICtrlCreateButton('Showmenu',245,382,70,20)

$oRP = ObjCreate("WMPlayer.OCX.7")
GUICtrlCreateObj( $oRP, 10, 10 , 650 , 365 )
GUISetState();Show GUI

With $oRP; Object tag pool
    
    .fullscreen = false
    .LaunchURL('?.wmv')
;.openplayer('?.wmv')
EndWith

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={6BF52A52-394A-11D3-B153-00C04F79FAA6}','', @SW_HIDE)
        Case $msg = $1C
        
        Case $msg = $2C
        
        Case $msg = $3C
    EndSelect
WEnd
$oRP = 0; free the embedded object
GUIDelete ()
Exit

Hope this would help you...

kjactive B)

When i play it runs WMP and doesnt show it in the GUI, also the pause function doesnt work :o .

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

That's true - MS Media player is build to be embedded into HTML and as that so to speak a bit 'self configurated' - but it's posible to embed and show the video but not to control the display size as this is self configurated...

; Author:    Kåre Johansson
; AutoIt Version: 3.1.1.56
; Description: Very Simple example: Embedding MSMedia Player object displying a .WMV video

#include <GUIConstants.au3>
$oRP = ObjCreate("WMPlayer.OCX.7")

Dim $w = 720, $h = 670
GUICreate ("Embed MSWebDVD control", $w, $h, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, $h - 20, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$1C = GUICtrlCreateButton('Play',105,$h - 23,70,20)
$2C = GUICtrlCreateButton('Pause',175,$h - 23,70,20)
$3C = GUICtrlCreateButton('Showmenu',245,$h - 23,70,20)

$ActiveX = GUICtrlCreateObj($oRP, 0, 0 , $w, $h )

With $oRP; Object tag pool
    .URL = '?.wmv'; embed the display in the current player
    .windowlessVideo = True
    .fullscreen = True
    .stretchToFit = True
;.openplayer('?.wmv'); open media player in a new window
    .uiMode = 'Full'; None, mini, full
    .enableContextMenu = False; true
EndWith

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={6BF52A52-394A-11D3-B153-00C04F79FAA6}','', @SW_HIDE)
        Case $msg = $1C
            $oRP.Close
        Case $msg = $2C
            GUICtrlSetPos($ActiveX,0,0, 200,300)
        Case $msg = $3C
            $oRP.URL = 'D:\Video\Anne\Anne_Mette.wmv'
    EndSelect
WEnd

$oRP = 0
GUIDelete ()
Exit

This is just an example to embed but normally I use the CWebPage library from Jeff Glatt as this library do has some superiour posibillities as to use params and html code both as in string mode as in page mode...

Small CWebPage example in sting mode as I use mostly...

#include <GUIConstants.au3>
HotKeySet("ESC", "Exits")
$dll = DLLOpen("cwebpage.dll"); load in the Html library
If $dll = -1 then; check library load okay status or bust
    MsgBox(48,"ERROR...","CWebpage library failed...")
    Exit
EndIf

$Main = GUICreate("Graphics...",-1,-1,200,200,$WS_POPUP)
DLLCall($dll,"long","EmbedBrowserObject","hwnd",$Main); attach the browser object from library
GUISetState()
$a = '<BODY scroll=no><IMG style="position:absolute;left:0;top:0;width:110%;height:110%;padding:10;cursor:none" src="C:\UpLoad\HtmlStrings\Tul.jpg" alt="Help">'
$a = $a & '<STYLE>.alpFilter {background-color:blue;filter:light();color:white}</STYLE><script>window.onload=fnInit;function fnInit(){'
$a = $a & 'var iX2=Alp.offsetWidth;var iY2=Alp.offsetHeight;Alp.filters[0].addCone(0,0,1,iX2,iY2,255,250,90,50,180)}</SCRIPT>'
$a = $a & '<A HREF=str:1><DIV class="alpFilter" ID=Alp style="position:absolute;left:291;top:110;width:100;height:20;border:1 solid red;cursor:hand;text-decoration:none;text-align:center"'
$a = $a & ' onmousedown="this.style.left=293;this.style.top=112" onmouseup="this.style.left=291;this.style.top=110">Text highlighted by a Cone</DIV></A></BODY>'

DLLCall($dll,"long","DisplayHTMLStr","hwnd",$Main,"str",$a); display the html code in the browser control

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = -3
        ExitLoop
    EndSelect
WEnd

Func Exits()
    DLLCall($dll,"long","UnEmbedBrowserObject","hwnd",$Main)
    DLLClose($dll)
    Exit
EndFunc

Look up one of my first attempt to write an autoit3 gui - Media player that uses CWebPage library...

http://www.sitecenter.dk/latenight/nss-folder/au3medie/

The CWebPage library can display almost every filetype available embedded in a autoit3 gui and provide all parametres related with MSMediaPlayer - CWebPage library most be available in your windows System(32) path...

CWebPage library has 6 functions ( with documentation ) - the string funcrion is the one to look up in this relations...

Hope this can help you on...

kjactive B)

Edited by kjactive

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

That's true - MS Media player is build to be embedded into HTML and as that so to speak a bit 'self configurated' - but it's posible to embed and show the video but not to control the display size as this is self configurated...

; Author:    Kåre Johansson
; AutoIt Version: 3.1.1.56
; Description: Very Simple example: Embedding MSMedia Player object displying a .WMV video

#include <GUIConstants.au3>
$oRP = ObjCreate("WMPlayer.OCX.7")

Dim $w = 720, $h = 670
GUICreate ("Embed MSWebDVD control", $w, $h, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, $h - 20, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$1C = GUICtrlCreateButton('Play',105,$h - 23,70,20)
$2C = GUICtrlCreateButton('Pause',175,$h - 23,70,20)
$3C = GUICtrlCreateButton('Showmenu',245,$h - 23,70,20)

$ActiveX = GUICtrlCreateObj($oRP, 0, 0 , $w, $h )

With $oRP; Object tag pool
    .URL = '?.wmv'; embed the display in the current player
    .windowlessVideo = True
    .fullscreen = True
    .stretchToFit = True
;.openplayer('?.wmv'); open media player in a new window
    .uiMode = 'Full'; None, mini, full
    .enableContextMenu = False; true
EndWith

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={6BF52A52-394A-11D3-B153-00C04F79FAA6}','', @SW_HIDE)
        Case $msg = $1C
            $oRP.Close
        Case $msg = $2C
            GUICtrlSetPos($ActiveX,0,0, 200,300)
        Case $msg = $3C
            $oRP.URL = 'D:\Video\Anne\Anne_Mette.wmv'
    EndSelect
WEnd

$oRP = 0
GUIDelete ()
Exit

This is just an example to embed but normally I use the CWebPage library from Jeff Glatt as this library do has some superiour posibillities as to use params and html code both as in string mode as in page mode...

Small CWebPage example in sting mode as I use mostly...

#include <GUIConstants.au3>
HotKeySet("ESC", "Exits")
$dll = DLLOpen("cwebpage.dll"); load in the Html library
If $dll = -1 then; check library load okay status or bust
    MsgBox(48,"ERROR...","CWebpage library failed...")
    Exit
EndIf

$Main = GUICreate("Graphics...",-1,-1,200,200,$WS_POPUP)
DLLCall($dll,"long","EmbedBrowserObject","hwnd",$Main); attach the browser object from library
GUISetState()
$a = '<BODY scroll=no><IMG style="position:absolute;left:0;top:0;width:110%;height:110%;padding:10;cursor:none" src="C:\UpLoad\HtmlStrings\Tul.jpg" alt="Help">'
$a = $a & '<STYLE>.alpFilter {background-color:blue;filter:light();color:white}</STYLE><script>window.onload=fnInit;function fnInit(){'
$a = $a & 'var iX2=Alp.offsetWidth;var iY2=Alp.offsetHeight;Alp.filters[0].addCone(0,0,1,iX2,iY2,255,250,90,50,180)}</SCRIPT>'
$a = $a & '<A HREF=str:1><DIV class="alpFilter" ID=Alp style="position:absolute;left:291;top:110;width:100;height:20;border:1 solid red;cursor:hand;text-decoration:none;text-align:center"'
$a = $a & ' onmousedown="this.style.left=293;this.style.top=112" onmouseup="this.style.left=291;this.style.top=110">Text highlighted by a Cone</DIV></A></BODY>'

DLLCall($dll,"long","DisplayHTMLStr","hwnd",$Main,"str",$a); display the html code in the browser control

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = -3
        ExitLoop
    EndSelect
WEnd

Func Exits()
    DLLCall($dll,"long","UnEmbedBrowserObject","hwnd",$Main)
    DLLClose($dll)
    Exit
EndFunc

Look up one of my first attempt to write an autoit3 gui - Media player that uses CWebPage library...

http://www.sitecenter.dk/latenight/nss-folder/au3medie/

The CWebPage library can display almost every filetype available embedded in a autoit3 gui and provide all parametres related with MSMediaPlayer - CWebPage library most be available in your windows System(32) path...

CWebPage library has 6 functions ( with documentation ) - the string funcrion is the one to look up in this relations...

Hope this can help you on...

kjactive :o

cwebpage.dll is not located in my system or system32 directory B) (or do you must put it there yourself?)

Where can i get it?

B.T.W. How can i seek in a media object that is embedded in a webpage?

Edited by svennie

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

No CWebpage is a embedded browser library written by an old friend of mine Jeff Glatt and can be downloaded from link last on this page ( Download source - 48KB ):

http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4379

Place the library in your system(32) path and read documentation ( especially the string command )

This library can put html, dhtml, smil, java, xml etc. into a plain browser embedded with an autoit3 gui and

the media browser code looks like this...

<OBJECT ID=MPlayer style="width:400;height:300;border:1 solid red" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
 <PARAM  name=URL value="Windows Movie.wmv">
 <PARAM name=autostart value=false></OBJECT>

and play all kind of filetypes - there is a lot of posibilliites with this library, look up my attemt to write a media player as an example...

kjactive B)

Share this post


Link to post
Share on other sites

No CWebpage is a embedded browser library written by an old friend of mine Jeff Glatt and can be downloaded from link last on this page ( Download source - 48KB ):

http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4379

Place the library in your system(32) path and read documentation ( especially the string command )

This library can put html, dhtml, smil, java, xml etc. into a plain browser embedded with an autoit3 gui and

the media browser code looks like this...

<OBJECT ID=MPlayer style="width:400;height:300;border:1 solid red" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
 <PARAM  name=URL value="Windows Movie.wmv">
 <PARAM name=autostart value=false></OBJECT>

and play all kind of filetypes - there is a lot of posibilliites with this library, look up my attemt to write a media player as an example...

kjactive B)

Sorry for the late answer but Thanks it works!

After some googling i have found that parameters are avaible.

Thanks!


Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

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