Jump to content

"Media Player Object" question


Krol
 Share

Recommended Posts

Global $oPlayer = ObjCreate("WMPlayer.OCX")
Global $Player = GUICtrlCreateObj($oPlayer,203,15,510,460)

Create MP Object, 510x460

But if I do so:

$oPlayer.uiMode = "full"

for show controls.

Or :

$oPlayer.URL = "video.avi"

for play media.

MP Object resize :)

Link to comment
Share on other sites

Wow, thats one stubborn control..

GUICreate("My GUI", 510, 460)
$oPlayer = ObjCreate("WMPlayer.OCX")
$player = GUICtrlCreateObj($oPlayer, 0, 0, 510, 460)
$oPlayer.URL = "C:\Documents and Settings\Administrator\My Documents\sandbox\PORTALTrailer.avi"
$oPlayer.uiMode = "full"
GUISetState()
;~ GUICtrlSetPos($player, 510, 460)
While 1
    If GUIGetMsg() == -3 Then ExitLoop
WEnd
It dosn't like GUICtrlSetPos() or my avi file.. (need some extra codex Ill never download)

My google search didn't go so well either. Just info about how to use the classname to get an object to see if it is supported and then they use <object> tags :)

Just wondering.. Do you really need to imbed this into a GUI?

Link to comment
Share on other sites

@all

Maybe this can help you out.

But there are examples in the Example Script Section.

Please use SEARCH for this.

;===============================================================================

Global $oPlayer = ObjCreate("WMPlayer.OCX")

$song = @ScriptDir & "\test.wma" ; requires full path name ... 
$song = @ScriptDir & "\test1.wma" ; requires full path name ... 
$song = @ScriptDir & "\test.mp3" ; requires full path name ... 

$rc = WMLoadFile($oPlayer, $song)
MsgBox(0, "1 rc", $rc)

$rc = WMGetDuration($oPlayer);
MsgBox(0, "2 rc", $rc)

$rc = $oPlayer.currentmedia.durationstring() ; in   min:sec
MsgBox(0, "3 rc", $rc)

$rc = $oPlayer.mediaCollection.add($song) ; Full path required .. 
MsgBox(0, "4 rc", $rc) ; rc<> 0 ??

$rc = $oPlayer.currentmedia.name() ; name of file (from TAG !)
;MsgBox(0, "5 rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Artist"));
MsgBox(0, "6a rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Title")); 
MsgBox(0, "6b rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Album"));
MsgBox(0, "6c rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Bitrate"));
MsgBox(0, "6d rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("CreationDate"));
MsgBox(0, "6e rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Genre"));
MsgBox(0, "6f rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Copyright")); the copyright holder-- 
MsgBox(0, "6g rc", $rc)


; media player possible asks for upgrade on installed DRM system?
$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Is_Protected"));   0 = NO DRM / -1 = DRM
MsgBox(0, "6h rc", $rc) 

#cs
Audio Item Attributes

The following attributes are available for an audio item in the library.

    * AcquisitionTime Attribute
    * AlbumID Attribute
    * AlbumIDAlbumArtist Attribute
    * Author Attribute
    * AverageLevel Attribute
    * Bitrate Attribute
    * BuyNow Attribute
    * BuyTickets Attribute
    * Channels Attribute
    * Copyright Attribute
    * CurrentBitrate Attribute
    * Duration Attribute
    * FileSize Attribute
    * FileType Attribute
    * Is_Protected
    * IsVBR Attribute
    * MediaType Attribute
    * MoreInfo Attribute
    * PartOfSet Attribute
    * PeakValue Attribute
    * PlaylistIndex Attribute
    * ProviderLogoURL Attribute
    * ProviderURL Attribute
    * RecordingTime Attribute
    * RecordingTimeDay Attribute
    * RecordingTimeMonth Attribute
    * RecordingTimeYear Attribute
    * RecordingTimeYearMonth Attribute
    * RecordingTimeYearMonthDay Attribute
    * ReleaseDate Attribute
    * ReleaseDateDay Attribute
    * ReleaseDateMonth Attribute
    * ReleaseDateYear Attribute
    * ReleaseDateYearMonth Attribute
    * ReleaseDateYearMonthDay Attribute
    * RequestState Attribute
    * ShadowFilePath Attribute
    * SourceURL Attribute
    * SyncState Attribute
    * Title Attribute
    * TrackingID Attribute
    * UserCustom1 Attribute
    * UserCustom2 Attribute
    * UserEffectiveRating Attribute
    * UserLastPlayedTime Attribute
    * UserPlayCount Attribute
    * UserPlaycountAfternoon Attribute
    * UserPlaycountEvening Attribute
    * UserPlaycountMorning Attribute
    * UserPlaycountNight Attribute
    * UserPlaycountWeekday Attribute
    * UserPlaycountWeekend Attribute
    * UserRating Attribute
    * UserServiceRating Attribute
    * WM/AlbumArtist Attribute
    * WM/AlbumTitle Attribute
    * WM/Category Attribute
    * WM/Composer Attribute
    * WM/Conductor Attribute
    * WM/ContentDistributor Attribute
    * WM/ContentGroupDescription Attribute
    * WM/EncodingTime Attribute
    * WM/Genre Attribute
    * WM/GenreID Attribute
    * WM/InitialKey Attribute
    * WM/Language Attribute
    * WM/Lyrics Attribute
    * WM/MCDI Attribute
    * WM/MediaClassPrimaryID Attribute
    * WM/MediaClassSecondaryID Attribute
    * WM/Mood Attribute
    * WM/ParentalRating Attribute
    * WM/Period Attribute
    * WM/ProtectionType Attribute
    * WM/Provider Attribute
    * WM/ProviderRating Attribute
    * WM/ProviderStyle Attribute
    * WM/Publisher Attribute
    * WM/SubscriptionContentID Attribute
    * WM/SubTitle Attribute
    * WM/TrackNumber Attribute
    * WM/UniqueFileIdentifier Attribute
    * WM/WMCollectionGroupID Attribute
    * WM/WMCollectionID Attribute
    * WM/WMContentID Attribute
    * WM/Writer Attribute
    * WM/Year Attribute


#ce

; turns the volume down and back up slowly...
For $i = 100 To 0 Step - 1
    WMSetVolume($oPlayer, $i)
    Sleep(10)
Next
For $i = 0 To 100
    WMSetVolume($oPlayer, $i)
    Sleep(10)
Next

MsgBox(0, "pause", "")

WMPause($oPlayer)

Sleep(300)

MsgBox(0, "play", "")


$rc = WMGetPosition($oPlayer)
MsgBox(0, "POS", $rc)


WMPlay($oPlayer)

Sleep(3000)

MsgBox(0, "stop","")
WMStop($oPlayer)

exit ; ----------------------------


; some functions
Func WMLoadFile($wm_obj, $sFilename)
    $wm_obj.url = $sFilename
    While Not WMGetState($wm_obj) = "Playing"
        Sleep(100)
    WEnd
EndFunc   ;==>WMLoadFile

Func WMSetVolume($wm_obj, $iVol)
    ;iVol can be between 0 and 100
    $wm_obj.settings.volume = $iVol
EndFunc   ;==>WMSetVolume

Func WMFastForward($wm_obj)
    $wm_obj.controls.fastForward()
EndFunc   ;==>WMFastForward

Func WMReverse($wm_obj)
    $wm_obj.controls.fastReverse()
EndFunc   ;==>WMReverse

Func WMPause($wm_obj)
    $wm_obj.controls.pause()
EndFunc   ;==>WMPause

Func WMPlay($wm_obj)
    $wm_obj.controls.play()
EndFunc   ;==>WMPlay

Func WMStop($wm_obj)
    $wm_obj.controls.stop()
EndFunc   ;==>WMStop

Func WMGetPosition($wm_obj)
    local $pos
    $pos = $wm_obj.controls.currentPosition ()
    return $pos
EndFunc   ;==>WMGetPosition

Func WMGetDuration($wm_obj)
    Local $len
    $len = $wm_obj.currentMedia.duration
    Return $len

EndFunc   ;==>WMGetDuration



Func WMGetState($wm_obj)
    local $sStates = "Undefined,Stopped,Paused,Playing,ScanForward,ScanReverse,Buffering,"
    $sStates &= "Waiting,MediaEnded,Transitioning,Ready,Reconnecting"
    local $aStates = StringSplit($sStates, ",")
    $iState = $wm_obj.playState ()
    Return $aStates[$iState]
EndFunc   ;==>WMGetState

regards

ptrex

Link to comment
Share on other sites

@all

OK here you go

$WMP = ObjCreate("wmplayer.ocx")
GUICtrlCreateObj($WMP,10,10,433,289);<----------------------------- ??
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
$btn1 = GUICtrlCreateButton("Load mp3",32,320,60,30)
GUICtrlSetOnEvent($btn1,"open")
$btn_stop = GUICtrlCreateButton("Stop",400,320,60,30)
GUICtrlSetOnEvent($btn_stop,"stop")

With $WMP
.windowlessVideo = True
.fullscreen = False
.stretchToFit = False
.uiMode = 'None'; None, mini, full
.enableContextMenu = False
EndWith

GUISetState(@SW_show)

while 1
sleep(1000)
WEnd

Func open()
$get_mp3 = FileOpenDialog("open .mp3 file","c:\","(*.mp3)",1)
$WMP.url = $get_mp3
EndFunc

Func stop()
$WMP.controls.stop
EndFunc

Func _restart()
    If @Compiled = 1 Then
        Run( FileGetShortName(@ScriptFullPath))
    Else
        Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc

Func CLOSE()
Exit
EndFunc

regards

ptrex

Link to comment
Share on other sites

@ptrex

No :P

On an example it is shown as the size changes at opening video.

But it is necessary for me that this size did not change! :)

Anybody help?

#include <GUIConstants.au3>

GUICreate("",500,400,-1,-1)
$WMP = ObjCreate("wmplayer.ocx")
GUICtrlCreateObj($WMP,10,10,433,289)

With $WMP
.windowlessVideo = True
.fullscreen = False
.stretchToFit = False
.uiMode = 'full'; None, mini, full
.enableContextMenu = False
EndWith
GUISetState(@SW_SHOW)
MsgBox(0,"before avi open","one size...")
$WMP.url = @WindowsDir&"\clock.avi"
Sleep(3000)
MsgBox(0,"after avi open","resize :(")

while 1
$Msg = GUIGetMsg()
If $Msg=$GUI_EVENT_CLOSE Then Exit  
WEnd
Link to comment
Share on other sites

Yeah! :)

$oPlayer.url = @WindowsDir&"\clock.avi" 
Sleep(5000)
$width = $oPlayer.currentMedia.imageSourceWidth
$height = $oPlayer.currentMedia.imageSourceHeight
GUICreate("",$width,$height+60,-1,-1)
Edited by Krol
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...