Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SongsDB;
- using System;
- using System.Diagnostics;
- using System.Drawing;
- using System.Windows.Forms;
- namespace MusicBeePlugin
- {
- public partial class Plugin
- {
- private MusicBeeApiInterface MbApiInterface;
- private PluginInfo about = new PluginInfo();
- public PluginInfo Initialise(IntPtr apiInterfacePtr)
- {
- MbApiInterface = new MusicBeeApiInterface();
- MbApiInterface.Initialise(apiInterfacePtr);
- about.PluginInfoVersion = PluginInfoVersion;
- about.Name = "MusicBee_MediaMonkey_Import_Plugin";
- about.Description = "Imports added date, play count and custom fields from MediaMonkey.";
- about.Author = "stax76";
- about.TargetApplication = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
- about.Type = PluginType.General;
- about.VersionMajor = 1; // your plugin version
- about.VersionMinor = 0;
- about.Revision = 1;
- about.MinInterfaceVersion = MinInterfaceVersion;
- about.MinApiRevision = MinApiRevision;
- about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);
- about.ConfigurationPanelHeight = 0; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function
- MbApiInterface.MB_AddMenuItem("mnuTools/MediaMonkey Import", "MediaMonkey Import", Import);
- return about;
- }
- private SDBApplication mm = new SDBApplication();
- public void Import(object sender, EventArgs e)
- {
- for (int i = 0; i < mm.AllVisibleSongList.Count; i++)
- {
- var track = mm.AllVisibleSongList.Item[i];
- MbApiInterface.Library_SetFileTag(track.Path, (MetaDataType)14, track.PlayCounter.ToString());
- MbApiInterface.Library_SetFileTag(track.Path, (MetaDataType)12, track.DateAdded.ToShortDateString());
- MbApiInterface.Library_SetFileTag(track.Path, MetaDataType.Custom1, track.Custom1);
- MbApiInterface.Library_CommitTagsToFile(track.Path);
- Debug.WriteLine(track.DateAdded.ToShortDateString() + ": " + track.Path);
- }
- MbApiInterface.MB_RefreshPanels();
- MessageBox.Show("done");
- }
- public bool Configure(IntPtr panelHandle)
- {
- // save any persistent settings in a sub-folder of this path
- string dataPath = MbApiInterface.Setting_GetPersistentStoragePath();
- // panelHandle will only be set if you set about.ConfigurationPanelHeight to a non-zero value
- // keep in mind the panel width is scaled according to the font the user has selected
- // if about.ConfigurationPanelHeight is set to 0, you can display your own popup window
- if (panelHandle != IntPtr.Zero)
- {
- Panel configPanel = (Panel)Panel.FromHandle(panelHandle);
- Label prompt = new Label();
- prompt.AutoSize = true;
- prompt.Location = new Point(0, 0);
- prompt.Text = "prompt:";
- TextBox textBox = new TextBox();
- textBox.Bounds = new Rectangle(60, 0, 100, textBox.Height);
- configPanel.Controls.AddRange(new Control[] { prompt, textBox });
- }
- return false;
- }
- // called by MusicBee when the user clicks Apply or Save in the MusicBee Preferences screen.
- // its up to you to figure out whether anything has changed and needs updating
- public void SaveSettings()
- {
- // save any persistent settings in a sub-folder of this path
- string dataPath = MbApiInterface.Setting_GetPersistentStoragePath();
- }
- // MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
- public void Close(PluginCloseReason reason)
- {
- }
- // uninstall this plugin - clean up any persisted files
- public void Uninstall()
- {
- }
- // receive event notifications from MusicBee
- // you need to set about.ReceiveNotificationFlags = PlayerEvents to receive all notifications, and not just the startup event
- public void ReceiveNotification(string sourceFileUrl, NotificationType type)
- {
- // perform some action depending on the notification type
- switch (type)
- {
- case NotificationType.PluginStartup:
- // perform startup initialisation
- switch (MbApiInterface.Player_GetPlayState())
- {
- case PlayState.Playing:
- case PlayState.Paused:
- // ...
- break;
- }
- break;
- case NotificationType.TrackChanged:
- string artist = MbApiInterface.NowPlaying_GetFileTag(MetaDataType.Artist);
- // ...
- break;
- }
- }
- // return an array of lyric or artwork provider names this plugin supports
- // the providers will be iterated through one by one and passed to the RetrieveLyrics/ RetrieveArtwork function in order set by the user in the MusicBee Tags(2) preferences screen until a match is found
- public string[] GetProviders()
- {
- return null;
- }
- // return lyrics for the requested artist/title from the requested provider
- // only required if PluginType = LyricsRetrieval
- // return null if no lyrics are found
- public string RetrieveLyrics(string sourceFileUrl, string artist, string trackTitle, string album, bool synchronisedPreferred, string provider)
- {
- return null;
- }
- // return Base64 string representation of the artwork binary data from the requested provider
- // only required if PluginType = ArtworkRetrieval
- // return null if no artwork is found
- public string RetrieveArtwork(string sourceFileUrl, string albumArtist, string album, string provider)
- {
- //Return Convert.ToBase64String(artworkBinaryData)
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement