its ages since i looked at this, but i think you need to tell MB via the API what formats are supported on the device - are you doing that already (properties.SupportedFormats = ...)?. Here is a code template i created:
[StructLayout(LayoutKind.Sequential)]
public struct DeviceProperties
{
private int version;
public string DeviceName;
// this should be a 64x64 bitmap
public Bitmap DeviceIcon64;
public string Manufacturer;
public string Model;
public string FirmwareVersion;
public int BatteryLevel;
public ulong FreeSpace;
public ulong TotalSpace;
// if yes, a Music node and if enabled Audiobook, Podcast, Video and playlist nodes are displayed in the Devices tree
public bool ShowCategoryNodes;
// device supports audio books as a category - if no, the files are synchronised to the music library
public bool AudiobooksSupported;
// device supports podcasts as a category - if no, the files are synchronised to the music library
public bool PodcastsSupported;
// device supports video as a category - if no, the files are synchronised to the music library
public bool VideoSupported;
// device supports a folder structure and allows the user to specify a naming template for the files
public bool OrganisedFoldersSupported;
// when enabled you need to query the MetaDataType.Artwork tag which will return null, "embeded" or the file location of the artwork. When not enabled, MusicBee forces the artwork to always be embeded (a temporary file is created if the file does not already have embeded artwork)
public bool SyncExternalArtwork;
// allows the user can choose whether files not on the sync list are to be removed from the device. If not enabled, its up to the plugin what to do
public bool SyncAllowFileRemoval;
// allows the user to tick 2-way rating sync in the device preferences
public bool SyncAllowRating2Way;
// allows the user to tick 2-way play count sync in the device preferences
public bool SyncAllowPlayCount2Way;
public SynchronisationSupportedFormats SupportedFormats;
// allows the user to tick 2-way playlist sync in the device preferences
public bool SyncAllowPlaylists2Way;
}
public bool GetDeviceProperties(IntPtr handle)
{
DeviceProperties properties = new DeviceProperties();
properties.DeviceName = about.TargetApplication;
properties.ShowCategoryNodes = true;
properties.AudiobooksSupported = true;
properties.PodcastsSupported = true;
properties.DeviceIcon64 = new Bitmap("C:\\Users\\Steven\\Pictures\\34M92.jpg");
properties.SupportedFormats = SynchronisationSupportedFormats.SyncMp3Supported | SynchronisationSupportedFormats.SyncAacSupported | SynchronisationSupportedFormats.SyncAlacSupported;
Marshal.StructureToPtr(properties, handle, false);
return true;
}
its ages since i looked at this, but i think you need to tell MB via the API what formats are supported on the device - are you doing that already
It appears so, below is in the code. But nothing specifically calls/references GetDeviceProperties() if that makes a difference.
public struct DeviceProperties
{
private int version;
public string DeviceName;
// this should be a 64x64 bitmap
public Bitmap DeviceIcon64;
public string Manufacturer;
public string Model;
public string FirmwareVersion;
public int BatteryLevel;
public ulong FreeSpace;
public ulong TotalSpace;
// if yes, a Music node and if enabled Audiobook, Podcast, Video and playlist nodes are displayed in the Devices tree
public bool ShowCategoryNodes;
// device supports audio books as a category - if no, the files are synchronised to the music library
public bool AudiobooksSupported;
// device supports podcasts as a category - if no, the files are synchronised to the music library
public bool PodcastsSupported;
// device supports video as a category - if no, the files are synchronised to the music library
public bool VideoSupported;
// device supports a folder structure and allows the user to specify a naming template for the files
public bool OrganisedFoldersSupported;
// when enabled you need to query the MetaDataType.Artwork tag which will return null, "embeded" or the file location of the artwork. When not enabled, MusicBee forces the artwork to always be embeded (a temporary file is created if the file does not already have embeded artwork)
public bool SyncExternalArtwork;
// allows the user can choose whether files not on the sync list are to be removed from the device. If not enabled, its up to the plugin what to do
public bool SyncAllowFileRemoval;
// allows the user to tick 2-way rating sync in the device preferences
public bool SyncAllowRating2Way;
// allows the user to tick 2-way play count sync in the device preferences
public bool SyncAllowPlayCount2Way;
public SynchronisationSupportedFormats SupportedFormats;
// allows the user to tick 2-way playlist sync in the device preferences
public bool SyncAllowPlaylists2Way;
}
public bool GetDeviceProperties(IntPtr handle)
{
DeviceProperties properties = new DeviceProperties();
if (!ITunes.IgnoreIPod)
{
properties.DeviceName = pluginName;
properties.FirmwareVersion = ITunes.IPodSource.SoftwareVersion;
properties.FreeSpace = (ulong)ITunes.IPodSource.FreeSpace;
properties.TotalSpace = (ulong)ITunes.IPodSource.Capacity;
}
else
{
properties.DeviceName = pluginName;
}
properties.ShowCategoryNodes = true;
properties.AudiobooksSupported = false;
properties.PodcastsSupported = false;
properties.VideoSupported = false;
properties.Manufacturer = "Apple Inc.";
properties.SyncExternalArtwork = false;
properties.SyncAllowFileRemoval = true;
properties.SyncAllowRating2Way = true;
properties.SyncAllowPlayCount2Way = true;
properties.SyncAllowPlaylists2Way = false;
System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("MusicBeePlugin.Images", System.Reflection.Assembly.GetExecutingAssembly());
properties.DeviceIcon64 = (Bitmap)resourceManager.GetObject("iTunes64");
properties.SupportedFormats = SynchronisationSupportedFormats.SyncMp3Supported | SynchronisationSupportedFormats.SyncAacSupported | SynchronisationSupportedFormats.SyncAlacSupported;
Marshal.StructureToPtr(properties, handle, false);
return true;
}
I have made the sync change but dont have iTunes installed to test it, so are you happy to try it on that understanding? I can send you a PM with a link
For the 2nd issue, do you have a function named "PrepareSynchronise" defined? It looks like i didnt document it, and its needed so you can tell musicbee how many files will be deleted and how many updated before the sync starts
PrepareSynchronise(
SynchronisationSettings settings, // indicates what type of synchronisation has been requested
KeyValuePair(Of Integer, String()) syncFiles[], // the files that will be sent for synchronisation
List(Of KeyValuePair(Of Integer, String[])) updates, // just add any values to this list - only the count in the list is used to determine the total files that will be sycned
List(Of String) deletes, // just add any values to this list - only the count in the list is used to determine the total files that will be deleted
List(Of String) playlists) // just add any values to this list - only the count in the list is used to determine the total playlists that will be synched
the SynchronisationSettings parameter will be set by MB and you could probably ignore it
[Flags()]
public enum SynchronisationSettings
{
None = 0,
SyncRemoveMissingFiles = 0x1,
SyncRating2Way = 0x2,
SyncPlayCount2Way = 0x4,
SyncConfirmRemoveFiles = 0x8,
SyncPlaylists2Way = 0x10
}
syncFiles will be set by MB and just telling you what the candidate files would be for the actual sync
the last 3 you need to add a list of filenames but in the current implementation, MB only uses the count from the list to work out the total file operations.
For the update parameter i dont recall why it wasnt just a list of string, so just use FilePropertyType.Url, and the filename
Forgot to mention. Before I changed anything with PrepareSynchronise the new version you gave me already changed the "No Files" problem to match the track number currently being synchronised.
eg) instead of -
1 of No files
2 of No files
3 of No files
It changed to -
1 of 1 files
2 of 2 files
3 of 3 files
Since adding PrepareSynchronise that behaviour hasn't changed so good chance I've got it wrong.
Here is the code I figured out after a bit of trial and error....
public bool PrepareSynchronise(SynchronisationSettings settings, KeyValuePair<int, string[]>[] syncFiles, List<KeyValuePair<int, string[]>> updates, List<string> deletes, List<string> playlists)
{
foreach (KeyValuePair<int, string[]> item in syncFiles)
{
Plugin.syncUpdates.Add(new KeyValuePair<int, string[]>(0,new string[]{item.Value[0]}));
}
settings = Plugin.SynchronisationSettings.None;
updates = Plugin.syncUpdates;
deletes = Plugin.syncDeletes;
playlists = Plugin.syncPlaylists;
MessageBox.Show(updates.Count.ToString());
return true;
}
I know the foreach loop is dodgy, I'm just using that for now to populate the updates . I couldn't get the FilePropertyType.Url to work as it kept telling me it couldn't convert it so I just put a zero in there for now.
When the messagebox pops up it does list the correct number of songs to be synced (well one extra because one is a playlist). So it must be working to some degree if syncFiles is populated.
syncDeletes and syncPlaylists are currently empty lists while I test it out.
Sorry for the hassle.