implement playlist and remove possible segfault

This commit is contained in:
TangoCash
2015-05-14 23:28:16 +02:00
committed by svenhoefer
parent 01d64f4735
commit bda8590e3a

View File

@@ -463,8 +463,8 @@ bool CMoviePlayerGui::prepareFile(CFile *file)
} }
if (file->getType() == CFile::FILE_ISO) if (file->getType() == CFile::FILE_ISO)
ret = mountIso(file); ret = mountIso(file);
else if (file->getType() == CFile::FILE_PLAYLIST) //else if (file->getType() == CFile::FILE_PLAYLIST)
parsePlaylist(file); //parsePlaylist(file);
if (ret) if (ret)
makeFilename(); makeFilename();
@@ -546,6 +546,8 @@ bool CMoviePlayerGui::SelectFile()
if (file) { if (file) {
is_file_player = true; is_file_player = true;
ret = prepareFile(file); ret = prepareFile(file);
if (file->getType() == CFile::FILE_PLAYLIST)
parsePlaylist(file);
} }
} }
menu_ret = filebrowser->getMenuRet(); menu_ret = filebrowser->getMenuRet();
@@ -898,21 +900,28 @@ void CMoviePlayerGui::PlayFileLoop(void)
callInfoViewer(); callInfoViewer();
} else if (!filelist.empty()) { } else if (!filelist.empty()) {
EnableClockAndMute(false); EnableClockAndMute(false);
CFileBrowser playlist; CFileBrowser *playlist = new CFileBrowser();
CFile *pfile = NULL; CFile *pfile = NULL;
pfile = &(*filelist_it); pfile = &(*filelist_it);
if (playlist.playlist_manager(filelist, std::distance( filelist.begin(), filelist_it ))) int selected = std::distance( filelist.begin(), filelist_it );
filelist_it = filelist.end();
if (playlist->playlist_manager(filelist, selected))
{ {
playstate = CMoviePlayerGui::STOPPED; playstate = CMoviePlayerGui::STOPPED;
CFile *sfile = NULL; CFile *sfile = NULL;
for (filelist_it = filelist.begin(); filelist_it != filelist.end(); ++filelist_it) for (filelist_it = filelist.begin(); filelist_it != filelist.end(); ++filelist_it)
{ {
pfile = &(*filelist_it); pfile = &(*filelist_it);
sfile = playlist.getSelectedFile(); sfile = playlist->getSelectedFile();
if ( (sfile->getFileName() == pfile->getFileName()) && (sfile->getPath() == pfile->getPath())) if ( (sfile->getFileName() == pfile->getFileName()) && (sfile->getPath() == pfile->getPath()))
break; break;
} }
} }
else {
if (!filelist.empty())
filelist_it = filelist.begin() + selected;
}
delete playlist;
EnableClockAndMute(true); EnableClockAndMute(true);
} }
} else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) {
@@ -1978,6 +1987,8 @@ void CMoviePlayerGui::parsePlaylist(CFile *file)
char cLine[1024]; char cLine[1024];
char name[1024] = { 0 }; char name[1024] = { 0 };
infile.open(file->Name.c_str(), std::ifstream::in); infile.open(file->Name.c_str(), std::ifstream::in);
filelist_it = filelist.erase(filelist_it);
CFile tmp_file;
while (infile.good()) while (infile.good())
{ {
infile.getline(cLine, sizeof(cLine)); infile.getline(cLine, sizeof(cLine));
@@ -1992,13 +2003,14 @@ void CMoviePlayerGui::parsePlaylist(CFile *file)
if ((url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) || (url = strstr(cLine, "mmsh://")) ) { if ((url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) || (url = strstr(cLine, "mmsh://")) ) {
if (url != NULL) { if (url != NULL) {
printf("name %s [%d] url: %s\n", name, dur, url); printf("name %s [%d] url: %s\n", name, dur, url);
file_name = url; tmp_file.Name = name;
if (strlen(name)) tmp_file.Url = url;
pretty_name = name; filelist.push_back(tmp_file);
} }
} }
} }
} }
filelist_it = filelist.begin();
} }
bool CMoviePlayerGui::mountIso(CFile *file) bool CMoviePlayerGui::mountIso(CFile *file)