xref: /MusicPlayer2/MusicPlayer2/Playlist.h (revision bc3df715d47f9230181725a5fb4da658ce12d1ed)
1877f5f92SZhongYang #pragma once
292deac10Szhongyang #include "SongInfo.h"
33cd2a7a0SZhong Yang class CPlaylistFile
492deac10Szhongyang {
592deac10Szhongyang public:
6877f5f92SZhongYang     enum Type           //播放列表格式
7ef4ab09dSZhong Yang     {
8877f5f92SZhongYang         PL_PLAYLIST,    //MusicPlayer2播放列表
9877f5f92SZhongYang         PL_M3U,         //m3u播放列表
10877f5f92SZhongYang         PL_M3U8         //m3u8播放列表
11ef4ab09dSZhong Yang     };
12ef4ab09dSZhong Yang 
133cd2a7a0SZhong Yang     CPlaylistFile();
143cd2a7a0SZhong Yang     ~CPlaylistFile();
1592deac10Szhongyang     void LoadFromFile(const wstring& file_path);
16ef4ab09dSZhong Yang     void SaveToFile(const wstring& file_path, Type type = PL_PLAYLIST) const;
17472d2320Szhongyang219     const vector<SongInfo>& GetPlaylist() const;
1864f63821Slrisora     int AddSongsToPlaylist(const vector<SongInfo>& songs, bool insert_begin = false);
19bf9f8a7fSlrisora     // 使用移动语义覆盖参数song_list,调用后此CPlaylistFile对象不再可用
20bf9f8a7fSlrisora     void MoveToSongList(vector<SongInfo>& song_list);
213a33a1bbSlrisora     bool IsSongInPlaylist(const SongInfo& song);
223a33a1bbSlrisora     int GetSongIndexInPlaylist(const SongInfo& song);
233a33a1bbSlrisora     void RemoveSong(const SongInfo& song);
2492deac10Szhongyang 
25997e6edaSZhong Yang     static bool IsPlaylistFile(const wstring& file_path);
26ada8a249SZhong Yang     static bool IsPlaylistExt(wstring ext);
27997e6edaSZhong Yang 
28*bc3df715Slrisora     static void SavePlaylistToFile(const vector<SongInfo>& song_list, const wstring& file_path, Type type = PL_PLAYLIST);
29997e6edaSZhong Yang public:
30877f5f92SZhongYang     const static vector<wstring> m_surpported_playlist;     //支持的播放列表文件的扩展名列表
31997e6edaSZhong Yang 
3292deac10Szhongyang private:
333cd2a7a0SZhong Yang     void DisposePlaylistFileLine(const string& str_current_line, bool utf8);
343cd2a7a0SZhong Yang 
353cd2a7a0SZhong Yang private:
36480ef52eSZhong Yang     vector<SongInfo> m_playlist;
37b648f771SZhong Yang     wstring m_path;
3892deac10Szhongyang };
3992deac10Szhongyang 
40