Jump to content

Recommended Posts


#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
    If TimerDiff($time1) > 5000 Then
        $srcFound = False
If Not $srcFound Or $width = 0 Then
    $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)

While 1
    $Msg = GUIGetMsg(1)
    Switch $Msg[0]
        Case $GUI_EVENT_CLOSE
            ;This is where I want to resize the video image to fit the new window size



How should I code the $GUI_EVENT_RESIZED portion to resize the video to fit the resized window? Your help will be greatly appreciated.


Edited by CYCho
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CYCho
      This file includes the source code for zPlayer, which is a stand-alone, simple, intuitive and easy-to-use, yet fully functional media player.  I made this to suit my purpose and you can tweak it to your taste. The source code is only about 1600 lines and only standard #include files were used. Also included in the attached zip file are some image files which are used for drawing the graphical media controls in the main window.
      As this forum does not recommend uploading an executable file, please use This Site to download the compiled exe file of this player. This file is not flagged by Windows Defender with latest Security Intelligence Update.
      This player has the following features:
      - Play back all formats of media files which can be played back by the Windows Media Player in your computer
      - Depending on the file types specified by the user in zPlayer.ini file this player can be either audio only, video only or both.
      - Video window is independent of other windows and, when maximized, increases the immersion of the user
      - Graphical media controls similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle function
      - Increase/decrease/mute sound volume
      - Change folders and create playlist for all media files in that folder and its subfolders, and support for manually-made playlists
      - Save play-back environment when terminating and resume that environment when restarting
      - 'Continue playback' option for a file you left off in the middle of playback
      - With one click, you can see internet search results for the file selected in playlist
      - With a double-click, you can play back an item in the playlist
      - Search strings in the playlist
      - Option to see long file names including folder names
      - Resize the playlist and video windows, and restore them to their default positions
      - Very small footprint: very low CPU and memory usage, with only about 1MB when compiled
      - You can even hide all the windows and manipulate the player with hotkeys only
      Note: zPlayer is the name I used when I introduced the early version of this player in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
    • By CYCho
      zPlayer is the name I used when I introduced the early version of this player in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
      After I retired from active duty in 2002 I spent much time listening to music. First I started with CD's and LP's, then quickly moved on to mp3 files. I converted many of my CD's to mp3 and I collected many more from various sources which were freely available at the time. As the number of my mp3 files grew, I put them in folders according to their genres and my favorite classifications. I mainly used Windows Media Player to listen to them and I slowly began to dislike wmp because it had massive user interface while I just wanted to listen to music in the background while I was doing other work in the foreground, hopping between folders from time to time. It was the time I was beginning to learn AutoIt and I thought I should make my own player with AutoIt. Coming from a sales career with no experience in programming, it was not an easy task. Somehow, after about 2 years of learning and trying, I had my own audio player which worked with only hotkeys without any graphical interface. I gave it to some of my friends who were not as computer-savvy as I. They liked it but definitely wanted something to clcik with mouse. So I came up with very rude gui which took a form similar to what it is now.
      The attached source files include one au3 file, one icon file and 14 jpg files. The jpg files are used for drawing a graphical player and are fileinstalled in @DocumentsCommonDir folder. This player uses WMPlayer.OCX as its engine and supports all audio file formats supported by wmp and additional codecs installed. I would like to thank @Bilgus for kind answers to my questions and would appreciate it if anyone could review the code and give me any suggestion. This player works for me, but I don't know whether the code is presentable as an example. I am posting this here with a hope to learn much from AutoIt community.
      PS: Video function was added in August 2020. Please see Downloads section of this forum for the latest version of this player.

    • By Emanoel
      Hi, I have a problem with GUICtrlCreatePic(). In topic WMPlayer.ocx how to change the shuttle picture? I wanted to replace the shuttle picture with a custom one (which I sent below the code) but got some weird results.
      #include <GuiConstants.au3> #include <Misc.au3> Global $Paused = False, $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) ;music name GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic($SliderButton, 0, 6, 30, 13) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) GUISetOnEvent($PauseButton, "PauseButton") $PlayButton = GUICtrlCreateButton("Play", 112, 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) $FilePath = "" ;your music path & .mp3 $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 control 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 While 1 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 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) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf If $Paused Then While $Paused Sleep(100) WEnd 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 AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func PauseButton() If $Paused = False Then $oPlayer.Controls.Pause AdlibUnRegister() $Paused = True GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") $Paused = False GUICtrlSetData($PauseButton, "Pause") EndIf EndFunc ;==>PauseButton Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider Also how can I set buttons to act like OnEvent button? I tried for $PauseButton but didn't make it. So I didn't do it for $PlayButton and $Shuttle. I want to add some lines from my main source to $PlayButton and since I used while loop in those lines (while the song is not over), I should control song (Pause/Resume, adjust position) anytime I want.

    • By nacerbaaziz
      hello autoit team
      please i need your help
      i found that the youtube provide a way to get any video informations with this link
      but it incoded i can not read it
      can any one tell me how to decode that please?
    • By nacerbaaziz
      goodmorning; autoit team
      please their are any youtube search way working?
      because i was using the get source and split it to get the result but know it does not working any way.
      is the youtube disabled that? and is their any other simple way to do that?
      i tested all examples found in this post but also it don't work
      and here is the example that i use to and it don't work any more
      local $hSearchOpenHNDL, $hSearchConnect, $sSearchGet local $a_UrlsArray[1][5] local $b_ButtonsDisabled = false, $b_SearchBTNFocus = false, $b_SearchListFocus, $h_SearchFocusHND local $Return = "0" local $s_OpenStringY = "/feed/trending" local $ChannelUrl = "", $channelName = "" if Not ($a_YoutubeSearchArray[0][0] = 0) then GUICtrlSetData($searchInp, $s_youtubeSearchLastSearch) $s_OpenStringY = "/results?search_query=" & StringReplace(GUICtrlRead($searchInp), " ", "+") $a_UrlsArray = $a_YoutubeSearchArray for $i = 1 to $a_UrlsArray[0][0] _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[$i][0] & $a_UrlsArray[$i][2] & $a_UrlsArray[$i][3]) next _GUICtrlListBox_SetCurSel($SearchList, $I_youtubeSearchLastIndex-1) GUICtrlSetState($SearchList, $GUI_focus) else if Ping("youtube.com", 1000) > 1 then $hSearchOpenHNDL = _WinHttpOpen('') if not (@Error) then $hSearchConnect = _WinHttpConnect($hSearchOpenHNDL, "youtube.com") if Not (@Error) then $sSearchGet = _WinHttpSimpleRequest($hSearchConnect, "get", $s_OpenStringY) if not (@Error) then local $a_strings = _StringBetween($sSearchGet, '<a href="/watch', "<ul") local $title = "" local $url = "" local $length = "" local $result = "" GUICtrlSetData($SearchList, "") ReDim $a_UrlsArray[1][5] for $i = 0 to UBound($a_strings)-1 $url = _StringBetween($a_strings[$i], "?", '"') if @error then ContinueLoop $url = "https://www.youtube.com/watch?" & $url[0] $title = _StringBetween($a_strings[$i], 'dir="', '</a>') if @error then ContinueLoop $title = $title[0] $title = StringRegExpReplace($title, '(.*\"\>)', "") if StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 2) elseIf StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 2) else $length = "" endIf if IsArray($length) then $length = ": (" & $length[0] & ")" else $length = "" endIf $ChannelUrl = stringRegexpReplace($a_strings[$i], '(^.*?<a.*?\"(\/user|\/channel))+', "$2") $channelName = stringRegexpReplace($ChannelUrl, '(.*?\".*?>)(.*</a>)+', "$2") $ChannelUrl = stringRegexpReplace($ChannelUrl, '(\".*)+', "") $channelName = stringRegexpReplace($channelName, '(</a>.*)+', "") $result &= $title & @crlf & $url & @crlf ReDim $a_UrlsArray[UBound($a_UrlsArray)+1][5] $a_UrlsArray[UBound($a_UrlsArray)-1][0] = $title $a_UrlsArray[UBound($a_UrlsArray)-1][1] = $url $a_UrlsArray[UBound($a_UrlsArray)-1][2] = $length if not ($channelName = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][3] = ", (" & $channelName & ")" if not ($channelUrl = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][4] = "https://www.youtube.com" & $channelUrl $a_UrlsArray[0][0] = UBound($a_UrlsArray)-1 _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[UBound($a_UrlsArray)-1][0] & $length & $a_UrlsArray[UBound($a_UrlsArray)-1][3]) next endIf endIf endIf endIf endIf  
      i hope any one can help me
      thanks in advance
  • Create New...