Jump to content
CYCho

zPlayer - My own little audio player

Recommended Posts

zPlayer is the name I used when I introduced the early version of this palyer 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: 1. An error (Variable used before declaration) was reported and corrected - 02:00 hours GMT,  March 14, 2019

      2. An error in tray menu was corrected -10:00 hours GMT, March14, 2019

      3. AutoIt3Wrapper_Au3Check_Parameters definition was added at the top of the code and all ensuing errors were corrected. - 00:10 hours GMT, March 16 2019

      4. Some features were added. - 10:30 hours GMT, March 18, 2019
          a. Jumping to new play-back position in a file
          b. Support for a manually made playlist
          c. Ctrl+Alt+h hotkey to trigger a help message box

      5. The minimum resizing width of playlist window was set at 450. - 01:10 hours GMT, March 23, 2019

      6. Problems associated with actions taken while in 'paused' status was addressed. - 07:40 GMT, April 12, 2019

      7. An error was found and corrected in restoring previous play-back environment when the mode was 'Shuffled.' - 11:00 GMT, April 17, 2019

Main-Window.png

Playlist-Window.png

Please see Downloads section of this forum for source code files.

 

Edited by CYCho

Share this post


Link to post
Share on other sites

Hello @@CYCho,

Thank you for this example program.  I've made a few audio scripts and wanted to see another example.  When I run your script, I am asked to locate a folder with music.  I navigate to My Music folder select a folder that contains MP3s and receive a script crash.

"E:\Programming\AutoIt\AutoIt_Forum\zPlayer\zPlayer\zPlayer.au3" (554) : ==> Variable used without being declared.:
If WinExists($winListView) Then
If WinExists(^ ERROR

 

Edited by Xandy

Share this post


Link to post
Share on other sites

Your code appears good.  I learned about FileInstal() because of how you use it to copy images.

I was curious if holding CTRL, ALT, or SHIFT would get the keys stuck, if used with Send("Volume UP").  The solution for that is SendEx(), which will force the modifiers keys to first be released.

But I didn't execute your script to a point where I could check this.

Edited by Xandy

Share this post


Link to post
Share on other sites

Ctrl+Alt did not create any problem for me so far and, as a matter of fact, I didn't know about SendEx(). Sure enough I wanted to learn something this way. Thanks.

Share this post


Link to post
Share on other sites

Thank you, script is working for me now.  Modifier keys are not becoming stuck.  Maybe this doesn't happen with HotKeySet(..) or Send("Volume Up/Down").  Either way nm.

The reason I stopped using the script (for now) is it was eating my CTRL+ARROWS.  I like to use these shortcuts to navigate words in a text.  There are several solutions to this problem, I could remap the hotkeys.  I could change the Song Next keys to respond to _IsPressed("11") And _IsPressed("25") and then your script would not eat the keys, yet still respond to them.  The song would change and my cursor would jump between words.  Not sure what I want to do yet.

Edited by Xandy

Share this post


Link to post
Share on other sites

Please let me know if you find a solution not to worry about stuck keys. It hasn't been a problem for me yet, but who knows? I just wanted to navigate around my music folders without a gui.

Share this post


Link to post
Share on other sites

If it hasn't been a problem for you.  It most likely not an issue and there is nothing to worry about.  If a key ever gets stuck wrap your Send() calls with a SendEx() call, just copy SendEx() from the Internet and use SendEx($string) instead of Send($string).  I wouldn't bother though, not if, keys aren't getting stuck.  I'm almost sorry I said anything.  There's no need to fix it if it isn't broken.

Share this post


Link to post
Share on other sites

According as @Bilgus suggested, "#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7" was added at the top of the code and all ensuing errors were corrected. Most of the errors were related with lack of keyword "Local" before assigning value to a local variable, and it seemed to be purely a matter of good coding practice. I'm glad I learned this though.

Edited by CYCho

Share this post


Link to post
Share on other sites

Some features were added.
1. Now you can click the slider in the graphical player to jump move the play-back position in a file.
2. The player now supports a manually made playlist with actual music files in other folders. This feature can be used for creating a playlist for a special occasion. For example, some carols can be included in the playlist and put in "Carols" folder: actual music files may reside anywhere in the computer.
3. A small help message box was added and can be triggered by Ctrl+Alt+h.

Edited by CYCho

Share this post


Link to post
Share on other sites

When resizing the playlist window, the minimum width was set at 450. Anything narrower would not be meaningful.

Share this post


Link to post
Share on other sites

For those non-AutoIt persons who visit this site as a result of Google or DuckDuckGo search, I attached a compiled executable file to the first post above. 

Edited by CYCho

Share this post


Link to post
Share on other sites

What should happen if the folder was changed or 'Play Next File' command was issued while the playback was in 'paused' status? This problem was addressed in today's revision.

Share this post


Link to post
Share on other sites

An error was found and corrected in restoring previous play-back environment when the mode of playback was 'Shuffled.' 

Share this post


Link to post
Share on other sites

I don't know when I will stop changing little things with this program. It happens that I make changes from time to time, maybe too soon, too often. If you have downloaded this program, please see if there was an update.

Share this post


Link to post
Share on other sites

I uploaded the source code in the Downloads section of this forum and deleted files attached to this topic.

Edited by CYCho

Share this post


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

  • Similar Content

    • By UEZ
      Hi,
      I created a FMOD UDF (x86 / x64 compatible) whereas the DLL calls are done from memory directly!
      Credits to trancexx for the Subrogation functions!
       
      Supported formats:
      - .MOD (protracker/fasttracker modules) - .S3M (screamtracker 3 modules) - .XM (fasttracker 2 modules) - .IT (impulse tracker modules) - .MID (MIDI files) - .RMI (MIDI files) - .SGT (DirectMusic segment files) - .FSB (FMOD Sample Bank files) - .MP3 - .OGG - .WAV - .MP2 - .RAW  
      Current added function list (sum = 70):
      FMUSICMEM_FreeSong FMUSICMEM_GetBPM FMUSICMEM_GetGlobalVolume FMUSICMEM_GetMasterVolume FMUSICMEM_GetName FMUSICMEM_GetNumChannels FMUSICMEM_GetNumInstruments FMUSICMEM_GetNumOrders FMUSICMEM_GetNumPatterns FMUSICMEM_GetNumSamples FMUSICMEM_GetOrder FMUSICMEM_GetPaused FMUSICMEM_GetRow FMUSICMEM_GetSpeed FMUSICMEM_GetTime FMUSICMEM_GetType FMUSICMEM_IsFinished FMUSICMEM_LoadSong FMUSICMEM_LoadSongEx FMUSICMEM_OptimizeChannels FMUSICMEM_PlaySong FMUSICMEM_SetMasterVolume FMUSICMEM_SetOrder FMUSICMEM_SetPaused FMUSICMEM_StopAllSongs FMUSICMEM_StopSong FSOUNDMEM_Close FSOUNDMEM_DSP_Create FSOUNDMEM_DSP_Free FSOUNDMEM_DSP_GetActive FSOUNDMEM_DSP_GetFFTUnit FSOUNDMEM_DSP_GetSpectrum FSOUNDMEM_DSP_SetActive FSOUNDMEM_DSP_SetPriority FSOUNDMEM_GetAmplitude FSOUNDMEM_GetChannelsPlaying FSOUNDMEM_GetCPUUsage FSOUNDMEM_GetCurrentLevels FSOUNDMEM_GetError FSOUNDMEM_GetFrequency FSOUNDMEM_GetGetSurround FSOUNDMEM_GetMaxChannels FSOUNDMEM_GetPan FSOUNDMEM_GetPaused FSOUNDMEM_GetVolume FSOUNDMEM_Init FSOUNDMEM_SetPaused FSOUNDMEM_SetSpeakerMode FSOUNDMEM_SetSurround FSOUNDMEM_SetVolume FSOUNDMEM_SetVolumeAbsolute FSOUNDMEM_Stream_Close FSOUNDMEM_Stream_FindTagField FSOUNDMEM_Stream_GetLength FSOUNDMEM_Stream_GetLengthMs FSOUNDMEM_Stream_GetNumTagFields FSOUNDMEM_Stream_GetOpenState FSOUNDMEM_Stream_GetPosition FSOUNDMEM_Stream_GetTagField FSOUNDMEM_Stream_GetTime FSOUNDMEM_Stream_Net_GetStatus FSOUNDMEM_Stream_Net_SetMetadataCallback FSOUNDMEM_Stream_Net_SetProxy FSOUNDMEM_Stream_Open FSOUNDMEM_Stream_Play FSOUNDMEM_Stream_PlayEx FSOUNDMEM_Stream_SetLoopCount FSOUNDMEM_Stream_SetPosition FSOUNDMEM_Stream_SetTime FSOUNDMEM_Stream_Stop  
      In the zip archive you can find 6 examples.
       
      Download:  FModMem UDF build 2019-11-24.zip
       
      If you have created additional examples, feel free to post it here.
    • By ripdad
      I ran across a topic while researching the BASS UDF...
      https://www.autoitscript.com/forum/topic/155845-carpenter-needs-help-performing-serious-surgery-on-audiometer2/ and then remembered another topic...
      https://www.autoitscript.com/forum/topic/121624-sound-level-sampling/ which got me to thinking as to how I could get the first topic to go LIVE without the need of loading an mp3.
      This will accept any LIVE AUDIO INPUT.
      Be sure to read this post if you have trouble with it...
      https://www.autoitscript.com/forum/topic/121624-sound-level-sampling/?do=findComment&comment=1400178 Also, read the comments I made in the script, so you will know how it will react to LIVE INPUT streams.

      Live FFT Visual Spectrum.zip
       

      LIVE Multiband FFT Visual Spectrum.au3
       
    • By CYCho
      This file includes all the source codes and a compiled .exe version of zPlayer, which is a stand-alone, simple, intuitive and easy-to-use, yet fully functional audio player.  I made this to suit my purpose and you can tweak it to your taste as the source code is only about 1000 lines which are very much readable.  This player has the following functions:
      - Play back all formats of audio files which can be palyed back by the Windows Media Player in your computer
      - Graphical player similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle funtions
      - Increase/decrease/mute sound volume
      - Change folders and create playlist for all audio 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
      - With one click, you can see DuckDuckGo search results for the file being played back
      - 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 window, and restore it to its default position
      - 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
×
×
  • Create New...