About This File
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 source code file are some image files which are used for drawing the graphical media controls in the main window.
As of its release date, the compiled exe file of this player, as attached hereto, 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
- View file properties for any file in the playlist and copy their values
- 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.
CHANGE LOGS
Version 5.0.0.1 - May 2, 2023
1. Divided MyAdlib function into AdlibProgressBar and AdlibTimer functions. MyAdlib function, called every 250 milliseconds, handled both progress bar and timer functions and, as a result, the timer in mm:ss format flickered frequently. Now AdlibTimer function, called once a second, updates only the timer. It still flickers but far less frequently.
2. Changed the way GUISetState(@SW_SHOW, $vcGUI) is triggered. Previously, it was triggered when the mouse entered the zone where the client area of the video window was located, regardless of the z-order. Now it is triggered only when the video window is visible, whether active or not.
3. Improved the progress bar function so that, when the shuttle is clicked and dragged, the timer is dynamically updated to reflect the current position.
Version 5.0.0.0 - April 20, 2023
I went back to WMPlayer.OCX embedded in IE. I compared 3 different options for playing digital media files which I could use for my media player. The first option was Windows Media Player(WMP) embedded in IE, which was used in versions 2 and 3 of zPlayer. The 2nd option was WMP object linked with ObjCreateInterface function to enable resizing of video without an IE. This option seemed attractive when there were fears of IE being dropped from Windows anytime soon. I adopted this option in version 4 of zPlayer. The 3rd option was winmm.dll, a Windows multimedia library for general programming purpose. I made a bare-bone media player with this method and uploaded it in AutoIt Example Scripts forum. All 3 options showed very similar funtionalities for playback of audio files, but they were significantly different from each other in playback of video files, especially as regards to resizing and fullscreen mode, and the first option, IE-embedded WMP, was by far the best option. Compared to the first option, the 2nd option showed unsatifactory performance in transition of video frames between pause and play. The 3rd option showed poor perforamnce in transition to fullscreen mode. And the fullscreen mode did not have a built-in video control and did not allow me to overlay my own video control on the screen. In the meantime I upgraded my OS to Windows 11 and, unlike my worries, I had no problem in running IE-embedded WMP object and it became clear that Windows will support IE untill the end of 2029. So I decided to go back to IE-embedded WMP. By the end of 2029, I hope a new method will be available which is comparable to, or better than, IE-embedded WMP.
Version 4.0.0.4 - December 5, 2022
1. Revised MyWindow() function, to address incorrect text in "Show/Hide Playlist Window" label when toggling between 'Show' and 'Hide' in a certain rare situation.
Version 4.0.0.3 - August 26, 2022
1. When an item in the playlist cannot be played back for any reason (ie, codec is not available or file does not exist), a dialog box appears to decide whether to play the next file or to quit. An error was found and corrected in the behavior when "play the next file" was selected.
Version 4.0.0.2 - March 26, 2022
1. When a video was paused while being played in maximized (not full screen) window, the image would shrink to a certain size smaller than the GUI for an unknown reason. _ResizeWMP() was added at the end of MyPause() function as an ad hoc measure. This brings the image back to normal size, but there is a short flicker while resizing the image. This problem remains to be solved in the future.
Version 4.0.0.1 - March 19, 2022
1. Implemented resizing of video in a Windows Media Player ActiveX control. This was made possible by using SetObjectRects method as demonstrated by @MattyD in his recent post (https://www.autoitscript.com/forum/topic/207744-media-player-embedding/?tab=comments#comment-1498631). Previously WMP was embedded in an Internet Explorer HTML document and I was worried of IE being not supported by Windows.
Version 3.0.2.6 - March 15, 2022
1. Deleted _IEAction ($myIE_Obj, "scrollintoview") from MyWMPlayer() function. It was found that _IEAction ($myIE_Obj, "refresh") was not necessary to start with.
Version 3.0.2.5 - March 14, 2022
1. Fixed code broken by newly released AutoIt stable version v3.3.16.0. An error occured at line #428 (While $oPlayer.playState <> $iPlaying) which meant that the WMP object was not duely created. It was solved by replacing _IEAction ($myIE_Obj, "refresh") with _IEAction ($myIE_Obj, "scrollintoview") in MyWMPlayer() function. Thanks go to @pixelsearch for his help in finding the cause.
2. Redundant re-creation of shell.application object in MyFileProperties() function was eliminated.
Version 3.0.2.4 - December 2, 2021
1. Added "File properties" to the playlist context menu. The user can copy any file property by doubleclicking an item in properties window and, therefore, previous context menus for copying file name and path were eliminated. File properties for the current file can also be invoked by clicking the media title in the main window.
Version 3.0.2.3 - November 5, 2021
1. In order to accommodate Unicode folder names, changed file format of zPlayer.ini file from default ANSI to Unicode UTF16 Little Endian.
Version 3.0.2.2 - October 29, 2021
1. Eliminated 'Video full screen on/off' menu from the main window because, according to my experience, it is better to handle it in the video window alone.
2. The function of 'Go to this folder' of the playlist context menu was expanded. In addition to going to the current folder, it now searches the relevant file in the folder. The error in finding a folder name with spaces was corrected.
Version 3.0.2.1 - September 8, 2021
1. The playing mode(sequential or shuffled) used to be saved in the zPlayer.ini when exiting the program. Now it is saved in the playlist in each folder so that the program, when it loads a playlist, picks up the playing mode which was in effect for that particular playlist.
2. Added a function to continue playback of a media from where it was left off. The initial default criteria for activation of this function are minimum media length of 600 seconds and minimum streamed length of 300 seconds. When you change the folder or exit the program and the current file meets these conditions, the current media position is saved in the playlist. When you reload that playlist, you will be asked if you want to continue or restart. By changing the preferences in Help window, you can adjust the minimum lengths, disenable this function or let the program automatically jump to the saved file position without asking a question.
3. Made substantial changes to wordings of the main window to increase readability and intuitiveness.
Version 3.0.2.0 - August 16 , 2021
1. Corrected malfunction in synchronization of zPlayer graphic controls when the user pauses or plays a file through video window context menu.
2. Improved readability of code by changing docking values for controls in playlist window from intigers to global constant variables defined in the GUIConstantsEx.au3.
Version 3.0.1.9 - July 19, 2021
1. Added menu buttons in playlist window to move an item up or dwon. Drop and drag was not impemented at this stage considering it's complexity for a small player like this.
2. Streamlined codes for drawing menu buttons in playlist window to improve readability and make it easier to add or delete a menu button.
Version 3.0.1.8 - July 3, 2021
1. Added 4 alternate hotkey sets to be used when the Windows uses Ctrl+Alt+Arrow shortcuts to change screen orientation. This happens when the computer has Intel CPU and Intel HD Graphics Control Panel installed. The alternate hotkeys use =, -, < and > keys instead of up, down, left and right arrows.
2. Changed some lines of code to comply with good coding practice.
Version 3.0.1.7 - April 17, 2021
1. Added Ctrl+Alt+0(Zero) hotkey to restore all windows to their default postions
2. Added Ctrl+Alt+c hotkey to show/hide media controls in video window
Version 3.0.1.6 - March 27, 2021
1. Drastically reduced the playlist load time by using _GUICtrlListView_AddArray() function instead of _GUICtrlListView_AddItem(). The load time was further reduced by use of _SendMessage(GUICtrlGetHandle($ctrlView), $LVM_DELETEALLITEMS) instead of _GUICtrlListView_DeleteAllItems() for deleting existing listview items when changing the folder. It used to take more than 5 seconds to load an 8,000-item playlist but, now, it takes less than 2 seconds.
2. Disabled hiding or showing main and/or playlist windows when video is playing in full screen or maximized mode.
3. Fixed incorrect functioning of Ctrl+Alt+m hotkey for changing playing mode.
Version 3.0.1.5 - March 24, 2021
1. Added codes to make the current item of the listview control remain focused all the time when the playlist window is visible.
2. Disabled hiding or showing main and/or playlist windows when video is playing in full screen mode.
3. Fixed incorrect functioning of Ctrl+Alt+m hotkey for changing playing mode.
Version 3.0.1.4 - March 17, 2021
1. Fixed the problem of main window being minimized when the Close box of playlist window is clicked.
2. Changed hotkeys for Play Next File, Play Previous File, Increase Volume and Decrease Volume from Ctrl+Arrows to Ctrl+Alt+Arrows. This will unify all the hotkey combinations of zPlayer and free up Ctrl+Arrows which are frequently used by other applications.
3. Fixed the problem of the title bar text of playlist window failing to accurately indicate the current playing mode.
4. Improved the way playlist window is scrolled to bring current file to the center of the window. Now it works dynamically while the window is resized.
I owe special thanks to @pixelsearch for his kind and active participation in this update.
Version 3.0.1.3 - March 14, 2021
1. Provided an input box in the Welcome window to allow the first time user to add file types to the default ones.
2. The main loop, which basically handled messages from all of the windows, was divided into 3 loops: one loop each for main window, playlist window and video window.
3. Eliminated minimize and maximize boxes from playlist window.
4. Eliminated horizontal scroll bar from listview control.
5. Added many comments to increase readability of source code.
Version 3.0.1.2 - March 11, 2021
1. Changed some constants to variables: they are heights of listview header and individual items in the playlist window, which are used for scrolling the current file to the center of window, and GUI border width, which is a factor affecting the default positions of windows. They are now obtained from an acutual temporary GUI created at the start of the program so that they accurately reflect the user's OS and default language which affect their values.
2. Streamliined the procedure to handle discrepancy between a playlist and actual files existing in the folder.
Version 3.0.1.1 - March 6, 2021
1. Fixed the problem of mute status being automatically unmuted when a new file is loaded.
2. Set $oPlayer.Settings.autoStart to true once at the start of the program instead of issuing $oPlayer.Controls.Play every time a file is loaded.
Version 3.0.1.0 - February 26, 2021
1. Streamlined procedures which synchronize media controls of zPlayer and Windows Media Player. New code is shorter and more readable.
2. Added a submenu item(Copy file name) in playlist context menu.
Version 3.0.0.8 - February 21, 2021
1. Changed design of main window so that the file name label control dynamically adjusts its position as the string size of the file name changes.
2. Added a menu and hot key in the main and video windows. Turn UI Full Screen On/Off (Ctrl+Alt+u) will toggle the full-screen mode of video window on and off.
3. zPlayer controls such as pause/play, repeat(loop) and volume level are now synchronized with WMP-intrinsic media controls in video window.
4. Changed the way repeat function works: Instead of loading the same file again after its play is complete, it now uses $oPlayer.Settings.setMode("loop", True). This makes the transition from end of file to beginning of file very smooth, especially noticeable in video files.
Version 3.0.0.6 - February 13, 2021
1. Changed media length and current position formats from MM:SS to HH:MM:SS. When this player was for audio only, HH was rarely needed.
2. Improved the way the media position indicators work in both main and video windows such that their numbers are changed real time as the slider shuttle is clicked and dragged.
3. The shape of mute control icon was changed for more intuitive look.
Version 3.0.0.5 - February 10, 2021
1. Media controls have been added to video window. By default it is a small rectangle in the bottom right corner of the video window which can be expanded to a collection of full controls when necessary.
2. mkv was added to default file types. It is recommended that existing zPlayer.ini file be deleted before applying this update.
Version 3.0.0.4 - December 7, 2020
1. A major error was found in "Rescan" function and corrected.
Version 3.0.0.3 - October 7, 2020
1. The file extension was the basis for zPlayer to recognize a video file, but now the existence of video image in the file itself is the basis for recognition of a video file. As a result, there is no need to have two separate keys for audio and video file types to be defined in zPlayer.ini file. Now all audio and video file types are defined under one key named File Types.
Version 3.0.0.2 - August 10, 2020
1. Added context menu in the playlist window with following submenus: Play this file, Delete from playlist, Copy file path, Go to this folder, Search internet
2. Added Reshuffle button to the playlist window. It reshuffles the current shuffled playlist. The button is disabled when the play mode is Sequential.
3. Used _GUICtrlListView_AddItem() instead of GUICtrlCreateListViewItem() to add playlist items, thus avoiding frequent re-creation of playlist window.
Version 3.0.0.1 - August 4, 2020
1. Added a video player
2. Depending on the file types specified by the user in zPlayer.ini file this player can be either audio only, video only or both.
Edited by CYCho
What's New in Version 5.0.0.1
Released
1. Divided MyAdlib function into AdlibProgressBar and AdlibTimer functions. MyAdlib function, called every 250 milliseconds, handled both progress bar and timer functions and, as a result, the timer in mm:ss format flickered frequently. Now AdlibTimer function, called once a second, updates only the timer. It still flickers but far less frequently.
2. Changed the way GUISetState(@SW_SHOW, $vcGUI) is triggered. Previously, it was triggered when the mouse entered the zone where the client area of the video window was located, regardless of the z-order. Now it is triggered only when the video window is visible, whether active or not.
3. Improved the progress bar function so that, when the shuttle is clicked and dragged, the timer is dynamically updated to reflect the current position.
Hash value for compiled file of the latest version:
SHA256: 8D3C584A4A73A156444823EBE300E496407701DEF70462DB42127B080DBEDA2A
As of it's release date, zPlayer.exe file is not flagged by Windows 10/11 Defender with latest Security Intelligence Update.