Jump to content

Embedded activex component - Realplayer...


kjactive
 Share

Recommended Posts

Just another embedded activeX object to play around with - RealPlayer

A small interfase with controls to link you up on tags page and example on how to control the medieplay component...

; Author:   Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding Real's RealPlayer object 
; Date: 3 jul 2005

#include <GUIConstants.au3>

$oRP = ObjCreate("rmocx.RealPlayer G2 Control.1")

GUICreate ( "Embedded Web control Test", 320, 200, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('About',105,177,70,20)
$PrefsC = GUICtrlCreateButton('Preferences',175,177,70,20)
$StatC = GUICtrlCreateButton('Statistics',245,177,70,20)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 300 , 160 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","FolderView"); this is a dummy event handle

GUISetState ();Show GUI

With $oRP; Object tag pool
;.Source = "http://cinecast.capcave.com/streams/SkyRadio/SkyRadio.asx" 
    .Source = "C:\Music\track 00.mpga" 
    .DoPlay()
;.DoPause()
    .SetNumLoop(2)
    .SetVolume(100) 
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={3B46067C-FD87-49B6-8DDD-12F0D687035F}','', @SW_HIDE)
        Case $msg = $AboutC
            $oRP.AboutBox()
        Case $msg = $PrefsC
            $oRP.EditPreferences() 
        Case $msg = $StatC
            $oRP.HideShowStatistics() 
    EndSelect
WEnd

GUIDelete ()
Exit

The example needs RealPlayer ( free to download ) and something like beta 3.1.55

and a mp3 song or something to play, almost no limits...

kjactive :)

Link to comment
Share on other sites

  • 9 months later...

kjactive.....I'm playing around with your realplayer code (which I think is pretty cool...) and modified it a bit...I'm having a problem with command line arguments. The strange thing is everything works fine in script mode, but when I complie, it flips an ocx error.. The error comes in because the ocx doesn't see the 3rd command line argument (url of ram file)...I hope you can help..Thanks

run examples in dos box:

play.au3 /play http://www.soul-patrol.net/brew1.ram ->>>Works great

play.exe /play http://www.soul-patrol.net/brew1.ram ->>>ocx can adjust sound vol ( looks like it can't find url and fails)

;Use Beta
#include <GUIConstants.au3>
#include <File.au3>
#include <GuiListView.au3>

Global $cancelbutton, $msg, $__msgbox, $oIE, $GUIActiveX
Global $TagsPageC, $AboutC, $PrefsC, $StatC, $Pause_Button, $PLAY, $LinkoRP, $URL_FILE
Global $oRP, $title, $trackview, $tracks, $tracklist, $RA

$URL_FILE = $CmdLine[$CmdLine[0]]
Opt("GUICloseOnESC", 1)

$oRP = ObjCreate("rmocx.RealPlayer G2 Control.1")

$RA = GUICreate ( "Embedded Web control Test", 320, 200, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('About',105,177,70,20)
$PrefsC = GUICtrlCreateButton('Preferences',175,177,70,20)
$StatC = GUICtrlCreateButton('Statistics',245,177,70,20)
$Pause_Button = GUICtrlCreateButton('Pause',45,150,70,20)
$PLAY = GUICtrlCreateButton('Play',130,150,70,20)

$LinkoRP = ObjEvent($oRP,"IEEvent_","FolderView"); this is a dummy event handle
$running = "true"
GUISetState ();Show GUI

With $oRP; Object tag pool
    .Source = $CmdLine[$CmdLine[0]]
    .DoPlay()
    .SetVolume(100) 
EndWith

While 1
    If $oRP.GetPacketsReceived  > 100 Then
        $title = StringSplit($oRP.GetEntryAbstract(1), ":")
        If @error Then
            $title = StringSplit($oRP.GetEntryTitle(1), "-")
            If Not @error Then
                _make_real_gui($title)
            Else
                GuiCtrlCreateLabel("Soul-Patrol.net Radio Show" & @CRLF & @CRLF & "No Listings Available", 18, 30, 220, 120)
            EndIf
        Else
        _make_real_gui($title)
        EndIf
        ExitLoop
    EndIf
WEnd

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $oRP.DoStop()
            GUIDelete ($RA)
            $running = "false"
            ExitLoop
            Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B46067C-FD87-49B6-8DDD-12F0D687035F}','', @SW_HIDE)
        Case $msg = $AboutC
            $oRP.AboutBox()
        Case $msg = $PrefsC
            $oRP.EditPreferences() 
        Case $msg = $StatC
            $oRP.HideShowStatistics() 
        Case $msg = $Pause_Button
            $oRP.DoPause()
        Case $msg = $PLAY
            $oRP.DoPlay()
    EndSelect
WEnd

GUIDelete ()
Exit


Func _make_real_gui($title)
GuiCtrlCreateLabel($title[1],15, 10, 170, 12)
$trackview = GuiCtrlCreateListView ("Tracks |",18, 30, 270, 102, $LVS_EX_FLATSB)
_GUICtrlListViewSetColumnWidth($trackview,0,220)
$tracks = StringSplit($title[2],",")
For $t = 1 To $tracks[0]
    $tracklist = GuiCtrlCreateListViewItem($tracks[$t],$trackview)
Next
EndFunc
Link to comment
Share on other sites

@ralnee

If you use an ActiveX component you should include proper Error handling. This makes life easier in case of proplems.

To start the scritp use this

#include <GUIConstants.au3>

Dim $oMyError
$oRP = ObjCreate("rmocx.RealPlayer G2 Control.1")

; Check if object creation succeeded
If Not IsObj($oRP) Then
   MsgBox(16, "ActiveX Error", "Real Player Object creation failed." & @CRLF & _
              "Please verify the installation of Real Player.")
  Exit
EndIf

To End the script

;This is Sven P's custom error handler
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"     & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "       & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
  SetError(1) ; to check for after this function returns
Endfunc

Enjoy

Link to comment
Share on other sites

Thanks for your help.. When I added the error checking , it comes up with this COM error:

error.windescription: "No such interface supported"

error.number is: 80004002

I tried looking this error number up on the web, but really go nothing....So, I said what the heck and complied your script, unmodified (hard coding the url for the rm file), and got the same error......

Any ideas would be welcome :think:

Thanks

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...