xref: /MusicPlayer2/MusicPlayer2/Playlist.h (revision 3f01865b94c96f8705736816f9994bfd2bf2f36b)
1 #pragma once
2 #include "SongInfo.h"
3 class CPlaylistFile
4 {
5 public:
6     enum Type           //播放列表格式
7     {
8         PL_PLAYLIST,    //MusicPlayer2播放列表
9         PL_M3U,         //m3u播放列表
10         PL_M3U8         //m3u8播放列表
11     };
12 
13     CPlaylistFile();
14     ~CPlaylistFile();
15     void LoadFromFile(const wstring& file_path);
16     void SaveToFile(const wstring& file_path, Type type = PL_PLAYLIST) const;
17     const vector<SongInfo>& GetPlaylist() const;
18     bool AddSongsToPlaylist(const vector<SongInfo>& songs, bool ignore_exist = false);
19     void FromSongList(const vector<SongInfo>& song_list);
20     void ToSongList(vector<SongInfo>& song_list);
21     bool IsSongInPlaylist(const SongInfo& song);
22     int GetSongIndexInPlaylist(const SongInfo& song);
23     void RemoveSong(const SongInfo& song);
24 
25     static bool IsPlaylistFile(const wstring& file_path);
26     static bool IsPlaylistExt(wstring ext);
27 
28 public:
29     const static vector<wstring> m_surpported_playlist;     //支持的播放列表文件的扩展名列表
30 
31 private:
32     void DisposePlaylistFileLine(const string& str_current_line, bool utf8);
33 
34 private:
35     vector<SongInfo> m_playlist;
36     wstring m_path;
37 };
38 
39