Background
The multimedia entertainment system in the Opel Ampera and Chevy Volt has some peculiarities when playing MP3 tracks from a USB stick and built-in hard drive for example it doesn't recognize Windows folder hierarchy. When a folder with different genres and albums of mp3 files is copied to the Ampera's hard drive; one flat list of mp3 and folder names is shown but no sign of the original genre and album hierarchy. For example, when I arrange music like in the next picture, it will be arranged as a flat list of folders and mp3 names in the Ampera's mp3 player.
When playing directly from the USB stick, the folder hierarchy is recognized but still some oddities are left. When playlist files are piggy bagged with the copy process, the player makes a mess of it. It doesn't know to choose between the folder hierarchy or the playlist files for displaying the mp3 files. When only using folder hierarchy without playlist files, again strange things happen, especially when the hierarchy is deep and the number of folders is greater then about 50. For example, it loses track of the mp3 locations and skipping a mp3 track can give surprising effects like suddenly jumping to another album or jumping back to the first mp3 track of the same or even another album.
After reading some forums, I found out that the best way to deal with the Ampera's mp3 player is to only use playlist files and copy all mp3 files with the playlists to the root of the USB stick. Because this is quite a repetitive process, I made a small program to do this in an more easy manner.
The Application
The application works as follows: Choose a folder where the mp3 files are arranged in folder hierarchy style, e.g., Rock\British\Rolling Stones. Choose a target folder, for example the drive mapped to the USB stick and you are ready to go. The application will create all playlist files and copies all mp3 tracks with the corresponding playlist files to the USB stick in such a manner that the Opel Ampera and Chevy Volt is able to (dis)play the mp3 tracks.
The application is using UltraID3Lib
to handle the mp3 tracks. A very easy and pleasant library for reading and writing ID3 metadata in MP3 file Check: UltraID3Lib.
The code of the Playlist creator is also quite straight forward, it reads in an iterative way through all folders and collects all mp3 data. The playlists are created and named depending on the folder where the mp3 data is located. After collecting all data, the mp3 tracks and corresponding playlists are copied to the target folder.
private string CreatePlayList(string folder)
{
UltraID3 ultraId = new UltraID3();
StringBuilder stringBuilder = new StringBuilder();
string[] files = Directory.GetFiles(folder, "*.mp3", SearchOption.TopDirectoryOnly);
if (files.Count() != 0)
{
ShowMessage(string.Format("Reading tracks from : {0} ", folder));
int entryNumber = 0;
stringBuilder.AppendLine("[playlist]");
foreach (string fileName in files)
{
ultraId.Read(@fileName);
int lenght = Convert.ToInt32(ultraId.Duration.TotalSeconds);
megaBytes = megaBytes + ultraId.Size / 1000000;
if (megaBytes > maxNumberOfMB && maxNumberOfMB > -1)
{
numberOfMBExceeded = true;
megaBytes = megaBytes - ultraId.Size / 1000000;
break;
}
numberOfTracks = numberOfTracks + 1;
if (numberOfTracks > maxNumberOfTracks && maxNumberOfTracks > -1)
{
numberOfTracksExceeded = true;
numberOfTracks = numberOfTracks - 1;
break;
}
entryNumber = entryNumber + 1;
string title = ultraId.Title;
stringBuilder.AppendLine(string.Format("File{0}={1}",
entryNumber, Path.GetFileName(fileName)));
stringBuilder.AppendLine(string.Format("Title{0}={1}", entryNumber, title));
stringBuilder.AppendLine(string.Format("Length{0}={1}", entryNumber, lenght));
}
stringBuilder.AppendLine(string.Format("NumberOfEntries={0}", entryNumber));
stringBuilder.AppendLine("Version=2");
}
return stringBuilder.ToString();
}
Still some Ampera/Volt mp3 player peculiarities have to be taken into account:
- Sometimes no more than 1000 tracks are displayed.
- No more than 200 tracks are displayed per playlist.
At this moment, the code works only with mp3 files but can be easily adapted to work with other music files. Best usage is to create relatively many playlists with a small number of mp3 tracks (less than 100) per playlist. Doing so makes the Ampera and Volt happy.