![]() Protected override void OnHandleCreated(EventArgs e) ID for the About item on the system menu private int SYSMENU_ABOUT_ID = 0x1 ( IntPtr hMenu, int uPosition, int uFlags, int uIDNewItem, string lpNewItem) Private static extern bool AppendMenu( IntPtr hMenu, int uFlags, int uIDNewItem, string lpNewItem) Private static extern IntPtr GetSystemMenu( IntPtr hWnd, bool bRevert) P/Invoke constants private const int WM_SYSCOMMAND = 0x112 Feature Highlighting Code Samples Iterating through the playlist items The WMPlayList class uses the WMPPlayListHeader and WMpPlayListBody classes to store the header and body of the playlist. Use the WMPRemoveDoubleType.BasedOnTrackTitle method instead. However, if the same music track appears on various "Best Of" albums, then this doesn't work because the track usually has different tracknumbers on different albums, and the tracknumber is usually include in the filename. This will remove doubles that have exactly the same filename but are in different locations. WMPRemoveDoubleType.BasedOnFilename: Here the filename excluding path and extension is used for comparing items.Use this to remove any media entries that have been accidentally inserted multiple times in the playlist. WMPRemoveDoubleType.BasedOnLocation: The whole file path is used to check for doubles.This process is slow, because all the media files have to be opened. This method will remove double tracks from different artists, for example Big Yellow Taxi has been covered by various artists, if you only want one in the playlist, use this remove method on the playlist. If the mediafile is not an MP3, then the filename is used. WMPRemoveDoubleType.BasedOnTrackTitle: This will open each MP3 and extract the tracktitle from the metadata.Remember that no physical files are removed, only the entries in the playlist! The WMPRemoveDoubleType is an enum with three values. MessageBox.Show(exp.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Playlist.RemoveDoubles(WMPRemoveDoubleType.BasedOnFilename) WMPPlayList playlist = new WMPPlayList(filename) Create an application with space (484x360 pixels) space for the control and add the following code: The control is within the WPLControlLib namespace. To use this user control, add a reference to the WMPControlLib assembly. It creates a J-Software\Tools folder in which the WMPPlayListFix application is copied, and creates a J-Software startmenu group with a shortcut to the application. The setup project: This is a setup program for the WMPPlayListFix program.The WMPPlayListFix application: This is just a wrapper user interface around the WMPPlayListCtrl user control.The WMPControlLib: This contains the WPL file control class WMPPlayList and the user control interface WMPPlayListCtrl.Writer.WriteProcessingInstruction( " wpl", " version=\"1.0\"") XmlWriter writer = XmlWriter.Create(filename, settings) Settings.DoNotEscapeUriAttributes = true Settings.ConformanceLevel = ConformanceLevel.Fragment XmlWriterSettings settings = new XmlWriterSettings() They differ from true XML files by the header. The playlist is stored between smil (Synchronized Multimedia Integration Language) tags. Microsoft uses an extended XML format to store Playlists, called WPL. And to top it off, make a shuffled playlist. Those last ones occur, of course, when after the creation of the playlist the media file is removed or moved. So I wanted something that removed the doubles in a playlist and removed non-existent files. (The solution for that with WMP is to temporarily save the shuffled list and then sync that list to the device). This is a problem if the playlist is larger than the portable device and you just want a shuffled selection on the device. When synchronizing a playlist to a portable device, Windows Media Player always uses an alphabetic write order, even when the list was shuffle using WMP.Windows Media Player does not check for non-existent file when a playlist is loaded, only when a non-existent file is encountered, the program shows an error and halts playback, which is a problem.So you can end up with playlist that contain a lot of doubles that can only be removed manually. ![]() Windows Media Player does not check for double entries in playlist.Therefore I needed a method to read and write the WPL files that hold playlists. I wanted to automatically clean-up Windows Media Player playlists. Download the projects with EXEs - 604.2 KB.Download WMPPlayListFix_setup - 365.8 KB. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |