To play the selected file in the listbox:Ĭlass = " " = false = Win32API.new( ' WinMM', ' mciSendString', ' ppii', ' i')Įnd def = " close " ", 0, = false end def = " open \"#", " ", 0, 0)Įnd end class = " " def self.Copyright © 2021 Washington Commanders. Or double-click on it to start it (I won't show that part here). Now you have all your files ready to be played, all that's needed is to select one and press play. Once that is done, loop through it to display its content. The btnOpen_click event will open an OpenFileDialog window, get the selected *.wpl file and send it to the readPlaylist class, which will in turn parse through it, return an Arraylist with all the file names and their paths. The above code is pretty straight forward. ayListPath = openPlaylistDialog.FileName įor ( int x = 0 x < nowPlaylist.Count x++) ReadPlaylist readList = new readPlaylist() Private void btnOpen_Click( object sender, EventArgs e) So here's the start, make sure you got all the references. Here's a part of the file with all the click events and so on. Name.Add(readList.GetAttribute( 0).ToString()) If (readList.NodeType = XmlNodeType.Element) XmlTextReader readList = new XmlTextReader(m_xmlFile) / /// Fills up an Arraylist with titles found in the / /// Return an Arraylist of file found in Windows Media Playlist file / /// The Windows Media Playlist Path xxx.wpl file Private ArrayList name = new ArrayList() Now for reading the *.wpl file to get MP3s to play. ( " setaudio MediaFile treble to ", value), null, 0, 0) ( " setaudio MediaFile bass to ", value), null, 0, 0) WPL files can be accessed and utilized by the Nullsoft Winamp. The fundamentals of WPL files are represented in XML format. It is an owned file format utilized in Microsoft Windows Media Player versions 9 to 12. ( " setaudio MediaFile volume to ", value), null, 0, 0) Windows Media Player Playlist (WPL) is a computer file format that keeps multimedia playlists for video and audio collections. ( " setaudio MediaFile right volume to ", value), null, 0, 0) ( " setaudio MediaFile left volume to ", value), null, 0, 0) Return 0 // Guess could be used to return Volume level: I don't need it MciSendString( " status MediaFile mode", stringBuilder, i, 0) / /// Returns the current status player: playing, paused, stopped, etc. / /// Pauses currently playing audio file / /// If True,audio file will repeat public void Play( bool loop) Pcommand = " open \"" + sFileName + " \" type mpegvideo alias MediaFile" / /// This is the audio file's path and filename public void Open( string sFileName) / /// Stops currently playing audio file StringBuilder strReturn, int iReturnLength, int bla) Private static extern long mciSendString( string strCommand, I tried putting as many relevant comments in the code as I code without going overboard like I'm doing writing this article. MainPlayer.cs: Basically the buttons and click events, etc.readPlaylist.cs: This opens up an open dialog window and helps you select a *.wpl file.Player.cs : More can be found here, which in my opinion is a pain to understand sometimes.I know that I'm not re-inventing the wheel here, just hoping this will help someone somewhere. Just please keep in mind, that I'm not a programmer by profession and this is my first contribution to The Code Project. Moreover, I had fun trying my hand at parsing XML, so the application gets audio file information from a Windows Media Playlist. It also controls the volume of the left/right channels (if there are more than 1). It uses the winmm.dll from Windows to play, stop, pause, etc. Of course, if I had wanted a full blown MP3 player, I probably would have downloaded one of the many free applications out there. I based mine on a commercial package that shall remain nameless Almost every example I found for playing audio file using the winmm.dll only had play/stop capabilities (and sometimes pause). That is fine, I just wanted a bit more, and still wanted to keep it simple. download album artwork/artist pictures/genre illustrations - Edit Tags. After looking for a simple, yet free MP3 player, I decided to make my own. Popular Alternatives to Neutron Music Player for Web, Android, iPhone, Windows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |