wpfmediaplaylistm3u

Use an m3u playlist for my media player.


I am making a WPF application of a media player from scratch. I have added a listbox where I can switch from one song to the next. I want to save this list as an m3u playlist and I want to be able to read m3u file too. I am using mediaelement. How do I do this?


Solution

  • every line in a m3u list represents a mp3 file

    var mru = yourFileList.OfType<YourFileListType>().Select(f => f.TheFileName);
    // .Net 4.0
    File.WriteAllLines("YourM3uFile.m3u", mru);
    // .Net 3.5
    File.WriteAllLines("YourM3uFile.m3u", mru.ToArray());
    

    hope that helps