How to import CD tracks from a CD into a universal Windows 10 application?

I need to import tracks from a CD, but so far I can’t do this. I can successfully import .mp3 or many other audio formats from a CD. First, for import purposes, I scan the files and folder of the CD. Then I show the list of files for the user and copies the files that the user selects from the list.

Here is my code to scan a directory or CD:

List<StorageFile> allTrackFiles = null; private async Task GetFiles(StorageFolder folder) { if(!scanningRemovableTask) { return; } try { if(allTrackFiles == null) { allTrackFiles = new List<StorageFile>(); } var items = await folder.GetItemsAsync(); foreach (var item in items) { if (item.GetType() == typeof(StorageFile)) { StorageFile storageFile = item as StorageFile; allTrackFiles.Add(storageFile); var basicProperties = await storageFile.GetBasicPropertiesAsync(); var musicProperties = await storageFile.OpenReadAsync(); } else await GetFiles(item as StorageFolder); } } catch(Exception e) { } } 

I pass the CD path to this function and it creates a list of files for me. This code works great when there is only .mp3 or any known audio format on the CD. But this creates problems when the CD has .CDA extension tracks. Since we know that .CDA files themselves cannot be played back, they are simply combined with the original media files.

Now I'm stuck here. How to read .CDA files or import .CDA files into our local directory in a universal Windows application.

+8
c # windows-store-apps uwp windows-10-universal
source share
1 answer

Short answer: this is not possible with CDA files.

Long answer: A CDA file is just a stub created by Windows for each audio track on a CD. These files do not contain actual audio data. All they contain is where each track starts and stops on the disc. If a file is “copied” from a CD to a computer, it cannot be used on its own, as it is only a shortcut to part of the disk. The audio CD is not formatted as a file system disk. They cannot be accessed as files. That is why windows create CDA files. It displays the CD as a file disc for tracks for easy viewing.

You will need to use a library that can load actual audio tracks from disk, not as files, but as audio tracks. The correct way to use CDA would be to use it as a reference to the actual soundtrack, copy it to a file, and then load the torn file.

You can use the native Windows Media interface to rip audio tracks. I also found a Code Project Tutorial that seems to use custom ripper. They should make you go in the right direction.

+6
source share

All Articles