xref: /MusicPlayer2/MusicPlayer2/Playlist.h (revision ec0490a72e915b8aa451edfc87be3aa2eecbe491)
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 AddFiles(const vector<wstring>& files, bool ignore_exist = false);
19     bool AddFiles(const vector<SongInfo>& files, bool ignore_exist = false);
20     void FromSongList(const vector<SongInfo>& song_list);
21     void ToSongList(vector<SongInfo>& song_list);
22     bool IsFileInPlaylist(const SongInfo& file);
23     int GetFileIndexInPlaylist(const SongInfo& file);
24     void RemoveFile(const SongInfo& file);
25 
26 	static bool IsPlaylistFile(const wstring& file_path);
27     static bool IsPlaylistExt(wstring ext);
28 
29 public:
30     const static vector<wstring> m_surpported_playlist;		//支持的播放列表文件的扩展名列表
31 
32 private:
33 	void DisposePlaylistFileLine(const string& str_current_line, bool utf8);
34 
35 private:
36     vector<SongInfo> m_playlist;
37     wstring m_path;
38 };
39 
40