Jump to content

_guictrlcreatemediaembed (embed WMP with visulizations + controls )


emoyasha
 Share

Recommended Posts

i dont know i f this has already been done but here is a way to embed a full windows media player into your gui

[or a cool way to add streaming music to your application]

Basically this function allows you to fully utalize windows media player in your autoit applications (to make invisible set with and height to 1 not 0, 0 will make it appear at 100x100 pixels)

Screen shot:

post-31056-1219632816_thumb.png

usage:

_guictrlcreatemediaembed("media here",x location,y location, width , height, background color)

_guictrlcreatemediaembed("http://98.28.10.188:8000",0,0,320,215,999999)

function:(set to my live streaming radio)

Func _guictrlcreatemediaembed($_song,$_sX,$_sY,$_sWidth,$_sHeight,$_sBGColor=-1)
    Local $_sString='<object id="player" height="100%" width="100%" align="middle" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> '
    $_sString&=' <param name="URL" value="'&$_song&'">'
    $_sString&=' <param name="uiMode" value="full"> '
    $_sString&=' <param name="ShowControls" value="true"> '
    $_sString&=' <param name="ShowStatusBar" value="true"> '
    $_sString&=' <param name="ShowDisplay" value="true"> '
    $_sString&=' <embed type="application/x-mplayer2" '
    $_sString&=' pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" '
    $_sString&=' SRC="'&$_song&'"'
    $_sString&=' name="player" '
    $_sString&=' width="100%" '
    $_sString&=' height="100%" '
    $_sString&=' showcontrols="1" '
    $_sString&=' showstatusbar="1" '
    $_sString&=' showdisplay="1" '
    $_sString&=' uiMode="full" '
    $_sString&=' visual="1"> '
    $_sString &= '</embed></object>'
    Local $_sIE = ObjCreate("Shell.Explorer")
    Local $_sReturn = GUICtrlCreateObj($_sIE,$_sX,$_sY,$_swidth,$_sHeight)
    $_sIE.navigate("about:blank")
    $_sIE.document.body.topmargin=0
    $_sIE.document.body.leftmargin=0
    $_sIE.document.body.scroll="no"
    $_sIE.document.body.bgcolor=$_sBGColor
    $_sIE.document.body.innerHTML = $_sString
    
    $_sIE=0
    Return $_sReturn
EndFuncoÝ÷ ÙìZ^
^±ëm¢l¥÷¬¶·)à­§b¡«­¢+ÙU%
ÉÑ ÅÕ½ÐíÕ¥ÑɱÉѵ¥µÅÕ½Ðì°ÌÈÀ°ÈÐÀ°´Ä°´Ä°ÁàÐÀÀÀÀ¤(ÀÌØìÄô}Õ¥ÑɱÉѵ¥µ ÅÕ½Ðí¡ÑÑÀè¼¼äà¸Èà¸ÄÀ¸ÄààèàÀÀÀÅÕ½Ðì°À°À°ÌÈÀ°ÈÄÔ°ääääää¤)U%
ÑɱMÑIͥ饹 ´Ä°ÄÀȤ)U%MÑMÑÑ ¤()]¡¥±U%Ñ5Í ¤±ÐìÐì´Ì)]¹()Õ¹}Õ¥ÑɱÉѵ¥µ ÀÌØí}ͽ¹°ÀÌØí}Í`°ÀÌØí}Íd°ÀÌØí}Í]¥Ñ °ÀÌØí}Í!¥¡Ð°ÀÌØí}Í   
½±½Èô´Ä¤(1½°ÀÌØí}ÍMÑÉ¥¹ôÌäì±Ðí½©Ð¥ôÅÕ½ÐíÁ±åÈÅÕ½Ðì¡¥¡ÐôÅÕ½ÐìÄÀÀÅÕ½ÐìÝ¥Ñ ôÅÕ½ÐìÄÀÀÅÕ½Ðì±¥¸ôÅÕ½Ðíµ¥±ÅÕ½Ðì±ÍÍ¥ôÅÕ½Ðí
1M%èÙ ÔÉÔÈ´ÌäÑ´ÄÅ̵ÄÔÌ´ÀÁÀÑÜåØÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíÁÉ´¹µôÅÕ½ÐíUI0ÅÕ½ÐìÙ±ÕôÅÕ½ÐìÌäìµÀìÀÌØí}ͽ¹µÀìÌäìÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíÁÉ´¹µôÅÕ½ÐíÕ¥5½ÅÕ½ÐìÙ±ÕôÅÕ½ÐíÕ±°ÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíÁÉ´¹µôÅÕ½ÐíM¡½Ý
½¹Ñɽ±ÌÅÕ½ÐìÙ±ÕôÅÕ½ÐíÑÉÕÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíÁÉ´¹µôÅÕ½ÐíM¡½ÝMÑÑÕÍ    ÈÅÕ½ÐìÙ±ÕôÅÕ½ÐíÑÉÕÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíÁÉ´¹µôÅÕ½ÐíM¡½Ý¥ÍÁ±äÅÕ½ÐìÙ±ÕôÅÕ½ÐíÑÉÕÅÕ½ÐìÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±ÐíµÑåÁôÅÕ½ÐíÁÁ±¥Ñ¥½¸½àµµÁ±åÈÈÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÁ±Õ¥¹ÍÁôÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹµ¥É½Í½Ð¹½´½]¥¹½Ý̽5¥A±åȼÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìMIôÅÕ½ÐìÌäìµÀìÀÌØí}ͽ¹µÀìÌäìÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì¹µôÅÕ½ÐíÁ±åÈÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÝ¥Ñ ôÅÕ½ÐìÄÀÀÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì¡¥¡ÐôÅÕ½ÐìÄÀÀÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÍ¡½Ý½¹Ñɽ±ÌôÅÕ½ÐìÄÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÍ¡½ÝÍÑÑÕÍÈôÅÕ½ÐìÄÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÍ¡½Ý¥ÍÁ±äôÅÕ½ÐìÄÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÕ¥5½ôÅÕ½ÐíÕ±°ÅÕ½ÐìÌäì($ÀÌØí}ÍMÑÉ¥¹µÀìôÌäìÙ¥ÍÕ°ôÅÕ½ÐìÄÅÕ½ÐìÐìÌäì(ÀÌØí}ÍMÑÉ¥¹µÀìôÌäì±Ðì½µÐì±Ðì½½©ÐÐìÌäì(1½°ÀÌØí}Í%ô=©
ÉÑ ÅÕ½ÐíM¡±°¹áÁ±½ÉÈÅÕ½Ðì¤(1½°ÀÌØí}ÍIÑÕɸôU%
Ñɱ
ÉÑ=¨ ÀÌØí}Í%°ÀÌØí}Í`°ÀÌØí}Íd°ÀÌØí}ÍÝ¥Ñ °ÀÌØí}Í!¥¡Ð¤(ÀÌØí}Í%¹¹Ù¥Ñ ÅÕ½Ðí½ÕÐé±¹¬ÅÕ½Ðì¤(ÀÌØí}Í%¹½Õµ¹Ð¹½ä¹Ñ½ÁµÉ¥¸ôÀ(ÀÌØí}Í%¹½Õµ¹Ð¹½ä¹±ÑµÉ¥¸ôÀ(ÀÌØí}Í%¹½Õµ¹Ð¹½ä¹Íɽ±°ôÅÕ½Ðí¹¼ÅÕ½Ðì(ÀÌØí}Í%¹½Õµ¹Ð¹½ä¹½±½ÈôÀÌØí}Í   
½±½È(ÀÌØí}Í%¹½Õµ¹Ð¹½ä¹¥¹¹É!Q50ôÀÌØí}ÍMÑÉ¥¹($(ÀÌØí}Í%ôÀ(IÑÕɸÀÌØí}ÍIÑÕɸ)¹Õ¹
Spoiler

Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------

 

Link to comment
Share on other sites

[sorry to double post, last post messed up autoit code when attempted to edit it]

but any comments, ideas, or suggestions would be appreciated.

Spoiler

Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------

 

Link to comment
Share on other sites

Hello!

I have a small question, lets say I play a video from my local hardrive and want my script to automatically exit when the video has finished playing, how could I do that?

Edited by AdmiralAlkex
Link to comment
Share on other sites

here ya go, small example, commented

GUICreate("guictrlcreatemediaembed",320,240,-1,-1,0x40000)
$1 = _guictrlcreatemediaembed("http://98.28.10.188:8000",-2,-2,322,217,999999)
MsgBox(0, $1, $1)
GUICtrlSetResizing(-1,102)
GUISetState()

;get the length of the media file(any format)
$ms = _gettime("C:\Documents and Settings\you\My Documents\My Videos\your video.wmv")
;start a timer
$timer = TimerInit()    
While GUIGetMsg() <> -3
Do
    ;get how logn the script has ran
    $end = TimerDiff($timer)
    ;run until script has ran same nubmer of millaseconds a media file
until $ms < $end

Func _guictrlcreatemediaembed($_song,$_sX,$_sY,$_sWidth,$_sHeight,$_sBGColor=-1)
    Local $_sString='<object id="player" height="100%" width="100%" align="middle" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> '
    $_sString&=' <param name="URL" value="'&$_song&'">'
    $_sString&=' <param name="uiMode" value="full"> '
    $_sString&=' <param name="ShowControls" value="true"> '
    $_sString&=' <param name="ShowStatusBar" value="true"> '
    $_sString&=' <param name="ShowDisplay" value="true"> '
    $_sString&=' <embed type="application/x-mplayer2" '
    $_sString&=' pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" '
    $_sString&=' SRC="'&$_song&'"'
    $_sString&=' name="player" '
    $_sString&=' width="100%" '
    $_sString&=' height="100%" '
    $_sString&=' showcontrols="1" '
    $_sString&=' showstatusbar="1" '
    $_sString&=' showdisplay="1" '
    $_sString&=' uiMode="full" '
    $_sString&=' visual="1"> '
    $_sString &= '</embed></object>'
    Local $_sIE = ObjCreate("Shell.Explorer")
    Local $_sReturn = GUICtrlCreateObj($_sIE,$_sX,$_sY,$_swidth,$_sHeight)
    $_sIE.navigate("about:blank")
    $_sIE.document.body.topmargin=0
    $_sIE.document.body.leftmargin=0
    $_sIE.document.body.scroll="no"
    $_sIE.document.body.bgcolor=$_sBGColor
    $_sIE.document.body.innerHTML = $_sString
    
    $_sIE=0
    Return $_sReturn
EndFunc

func _gettime($file)
mciSendString("open " & FileGetShortName($file) & " alias " & FileGetShortName("go"))
mciSendString("set " & FileGetShortName("go") & " time format miliseconds")
$time = mciSendString("status " & FileGetShortName("go") & " length", 255)
return $time
EndFunc
    
func mciSendString($string, $iLen = 0)
    Local $y
    $y = DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "long", $iLen, "long", 0)
    If Not @error Then Return $y[2]
EndFunc

enjoy ;)

Spoiler

Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------

 

Link to comment
Share on other sites

cumbersome....how?

Spoiler

Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------

 

Link to comment
Share on other sites

cumbersome....how?

compared to working directly with wmp's com object it looks cumbersome (atleast for videos, don't care about the rest), see here Edited by AdmiralAlkex
Link to comment
Share on other sites

Hey, I just shortened it a bit so if you want to look at it (did this for my own purposes) here it is.

Func _GUICtrlCreateMediaEmbed($_sSong,$_iX,$_iY,$_iWidth,$_iHeight,$_hBGColor=-1)
    Global $_oIE
    $_sString= '<object id="player" height="100%" width="100%" align="middle" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> <param name="URL" value="'&$_sSong&'"> <param name="uiMode" value="full"> <param name="ShowControls" value="true"> <param name="ShowStatusBar" value="true"> <param name="ShowDisplay" value="true"> <embed type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" SRC="'&$_sSong&'" name="player" width="100%" height="100%" showcontrols="1" showstatusbar="1" showdisplay="1" uiMode="full" visual="1"></embed></object>'
    If $_oIE = 0 Then
        $_oIE = _IECreateEmbedded()
        $_sReturn = GUICtrlCreateObj($_oIE,$_iX,$_iY,$_iWidth,$_iHeight)
    EndIf
    _IENavigate($_oIE,"about:blank")
    _IEBodyWriteHTML($_oIE,$_sString)
EndFunc

Edit: Fixed redundant Global

Edited by dbzfanatic
Link to comment
Share on other sites

assigning two times to a global variable is not a good way, instead i would recommend changing Global $_oIE = _IECreateEmbedded() to $_oIE = _IECreateEmbedded() cause Global $_oIE is already defined.

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

assigning two times to a global variable is not a good way, instead i would recommend changing Global $_oIE = _IECreateEmbedded() to $_oIE = _IECreateEmbedded() cause Global $_oIE is already defined.

It was just a mistype, I was messing with it in more than one way and I guess I forgot to take out the redundant Global declaration. Thanks for pointing that out.

Link to comment
Share on other sites

ahhh but have you compared your code's output to mine?

you will notice your code leaves about 10-20 pixels of whitespace on either size of the player,

mine allows the player to fill the while space.

Spoiler

Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------

 

Link to comment
Share on other sites

You Might Not Need This But Here ;)

Func _MediaGet_Length ($Media_Path)
Local $Dll_Open, $Return
$Dll_Open = DllOpen ('WinMM.dll')
$Return = DllCall ($Dll_Open, 'Int','mciSendStringA','Str','Status ' & FileGetShortName ($Media_Path) & ' Length','Str','','Long','255','Long','0')
If Not @Error Then Return $Return['2']
EndFunc

- John (:D)

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
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
 Share

  • Recently Browsing   0 members

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