Jump to content

Search the Community

Showing results for tags 'wmplayer.ocx'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 2 results

  1. When sound files have to be played, Sound.au3 UDF comes to our mind immediately. It is simple and easy to use. But WMPlayer.ocx has a lot more features: it can play video clips and flac audio files, which Sound.au3 UDF cannot. Below are quick and dirty comparison of codes utilizing two different methods. Both of them do exactly the same thing: play back a playlist of audio files, with a simple slider control. 1. Use Sound.au3 UDF #include <GUIConstants.au3> #include <Sound.au3> #include <Misc.au3> $hGui = GUICreate("Sound.au3", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic(StringReplace(@AutoItExe, "autoit3.exe", "\examples\gui\msoobe.jpg"), 0, 0, 20, 20) $Pause = GUICtrlCreateButton("Pause", 160, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) Local $aPlayList[3] ; Put your own mp3 file paths in this playlist $aPlayList[0] = 2 ; number of files in the playlist $aPlayList[1] = "D:\Music - Classics\Beethoven - Piano Concerto 5 in Eb Major Allegro.mp3" $aPlayList[2] = "D:\Music - Pops\Adele - Hello.mp3" $nFiles = 0 For $i = 1 To $aPlayList[0] If Not FileExists($aPlayList[$i]) Then $nFiles += 1 EndIf Next If $nFiles = $aPlayList[0] Then MsgBox(0, "Sound.au3", "None of the files listed in $aPlayList array exists.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle cntrol in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $nFile = 0 While 1 $nFile += 1 If $nFile > $aPlayList[0] Then $nFile = 1 EndIf $sFullPath = $aPlayList[$nFile] $aSound = _SoundOpen($sFullPath) If $aSound = 0 Then MsgBox(0, "Sound.au3", $sFullPath & @CRLF & @CRLF & "Cannot open this file.", 5) ContinueLoop EndIf _SoundPlay($aSound) $sFile = StringMid($sFullPath, StringInStr($sFullPath, "\", 0, -1)+1) GUICtrlSetData($Label1, $sFile) $mediaLength = _SoundLength($aSound, 2) / 1000 ; in seconds GUICtrlSetData($Length, Int($mediaLength/60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose($aSound) Exit Case $Pause If GUICtrlRead($Pause) = "Pause" Then _SoundPause($aSound) AdlibUnRegister() GUICtrlSetData($Pause, "Resume") Else _SoundResume($aSound) AdlibRegister("Slider") GUICtrlSetData($Pause, "Pause") EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380+$xOffset Then $x = 380+$xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = Round($iPos/$sliderLength*$mediaLength) $iHour = Int($mediaPos/3600) $iMin = Int(Mod($mediaPos, 3600)/60) $iSec = Mod($mediaPos, 60) _SoundSeek($aSound, $iHour, $iMin, $iSec) _SoundPlay($aSound) AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($Pause, "Pause") EndSwitch If _SoundStatus($aSound) = "stopped" Then ; playing, paused, stopped ExitLoop EndIf WEnd WEnd Func Slider() $mediaPos = _SoundPos($aSound, 2)/1000 $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos/60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc 2. Use of WMPlayer.ocx #include <GuiConstants.au3> #include <Misc.au3> $hGui = GUICreate("WMPlayer.OCX", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic(StringReplace(@AutoItExe, "autoit3.exe", "examples\gui\msoobe.jpg"), 0, 0, 20, 20) $Pause = GUICtrlCreateButton("Pause", 160, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) Local $aPlayList[3] ; Put your own mp3 file paths in this playlist $aPlayList[0] = 2 ; number of files in the playlist $aPlayList[1] = "D:\Music - Classics\Beethoven - Piano Concerto 5 in Eb Major Allegro.mp3" $aPlayList[2] = "D:\Music - Pops\Adele - Hello.mp3" $nFiles = 0 For $i = 1 To $aPlayList[0] If Not FileExists($aPlayList[$i]) Then $nFiles += 1 EndIf Next If $nFiles = $aPlayList[0] Then MsgBox(0, "WMPlayer.ocx", "None of the files listed in $aPlayList array exists.", 5) GUIDelete($hGui) Exit EndIf $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle cntrol in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.Settings.Volume = 100 $nFile = 0 While 1 $nFile += 1 If $nFile > $aPlayList[0] Then $nFile = 1 EndIf $sFullPath = $aPlayList[$nFile] $oPlayer.URL = $sFullPath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $sFullPath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($sFullPath, StringInStr($sFullPath, "\", 0, -1)+1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength/60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $Pause If GUICtrlRead($Pause) = "Pause" Then $oPlayer.Controls.Pause AdlibUnRegister() GUICtrlSetData($Pause, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($Pause, "Pause") EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380+$xOffset Then $x = 380+$xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos/$sliderLength*$mediaLength $oPlayer.Controls.currentPosition = $mediaPos $oPlayer.Controls.Play AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($Pause, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos/60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc
  2. #include <GUIConstants.au3> #include <WindowsConstants.au3> Local $oPlayer, $gVideo, $width, $height $oPlayer = ObjCreate("WMPlayer.OCX.7") $oPlayer.URL = 'http://www.clubbalcony.com/upload/culture/yong(2).wmv' Local $srcFound = True Local $time1 = TimerInit() While 1 If $oPlayer.playState() = 3 Then $width = $oPlayer.currentMedia.imageSourceWidth $height = $oPlayer.currentMedia.imageSourceHeight ExitLoop EndIf If TimerDiff($time1) > 5000 Then $srcFound = False ExitLoop EndIf Sleep(50) WEnd If Not $srcFound Or $width = 0 Then $oPlayer.Close() Exit Else $gVideo = GUICreate("Video Control", $width, $height+63, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX), $WS_EX_TOPMOST) GUICtrlCreateObj($oPlayer, 0, 0, $width, $height+63) $oPlayer.uiMode = "Full" $oPlayer.stretchToFit = True GUISetState(@SW_SHOW, $gVideo) EndIf While 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESIZED ;This is where I want to resize the video image to fit the new window size EndSwitch WEnd $oPlayer.Close() How should I code the $GUI_EVENT_RESIZED portion to resize the video to fit the resized window? Your help will be greatly appreciated.
×
×
  • Create New...