8

I need to import tracks from a CD but so far I am unable in doing so. I can successfully import .mp3 or many other audio formats from a CD. For importing purpose first I scan files and folder of a CD. Then I show the list of files to user and copy files that user selects from list.

Here is my code for scanning a Directory or a 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 fine when CD has only .mp3 or any famous Audio format. But it creates trouble when CD has .CDA extension tracks. As we know that .CDA files are itself doesn't play, they are just shortcuts to the original media files.

Now, this is where I am stuck right now. How to read .CDA files or import .CDA files media to our local Directory in universal windows app.

2
  • Same question. Does .CDA support in UWP?
    – Mikewhat
    Commented Oct 13, 2016 at 7:39
  • Don't know the answer....I am looking for solution too!!! Commented Oct 13, 2016 at 11:02

1 Answer 1

6
+50

Short answer: This is not possible with CDA files.

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

You will have to use a library that can load the actual audio tracks from the disk, not as files but as audio tracks. The proper way to use the CDA would be to use it as a reference to the actual audio track, rip that to a file, then load the ripped file.

You can use the native Windows Media Interface for ripping audio tracks. I also found a Code Project Tutorial that seems to be using a custom ripper. They should get you going in the right direction.

3
  • Isn't the code project tutorial is for windows form app? I am trying to use it with UWP!!? Is it possible to use it with Universal Windows Platform?? Commented Oct 20, 2016 at 10:57
  • Actually I have not much experience in UWP or desktop apps....It would be really helpful if you give some more instruction to me for moving forward...BTW Thanks for the answer... Commented Oct 20, 2016 at 12:05
  • The code project tutorial uses a class named CDDrive. The first example shows how to use it. I peeked at the code and it does use native Windows api calls. Given the low level nature of reading audio CD's, there might not be a way around relying on the OS. I'm not sure how this translates to a universal Windows app. It may work just fine. Give it a try and let me know.
    – Jaguir
    Commented Oct 20, 2016 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.