From 10a29e093a4b6939b0462d93cba9b3f4251f3916 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 18 Jun 2012 15:05:16 +0400 Subject: [PATCH] gui/movieplayer.cpp: parse m3u files Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1caa062655fbdded439b31e2102e4ad07caf9788 Author: [CST] Focus Date: 2012-06-18 (Mon, 18 Jun 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 7b7af2963..d69ac76f2 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -47,6 +47,9 @@ #include #include "libtuxtxt/teletext.h" #include +#include +#include +#include //extern CPlugins *g_PluginList; #if HAVE_TRIPLEDRAGON @@ -113,6 +116,7 @@ void CMoviePlayerGui::Init(void) tsfilefilter.addFilter("m2ts"); tsfilefilter.addFilter("mp4"); tsfilefilter.addFilter("mov"); + tsfilefilter.addFilter("m3u"); if (strlen(g_settings.network_nfs_moviedir) != 0) Path_local = g_settings.network_nfs_moviedir; @@ -292,6 +296,7 @@ bool CMoviePlayerGui::SelectFile() is_file_player = false; p_movie_info = NULL; + file_name = ""; printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser); if (has_hdd) @@ -348,10 +353,34 @@ bool CMoviePlayerGui::SelectFile() is_file_player = true; full_name = file->Name.c_str(); ret = true; + if(file->getType() == CFile::FILE_PLAYLIST) { + std::ifstream infile; + char cLine[256]; + char name[255] = { 0 }; + infile.open(file->Name.c_str(), std::ifstream::in); + while (infile.good()) + { + infile.getline(cLine, 255); + if (cLine[strlen(cLine)-1]=='\r') + cLine[strlen(cLine)-1]=0; + + int duration; + sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &duration, name); + if (strlen(cLine) > 0 && cLine[0]!='#') + { + char *url = strstr(cLine, "http://"); + if (url != NULL) { + printf("name %s [%d] url: %s\n", name, duration, url); + full_name = url; + file_name = name; + } + } + } + } } } } - if(ret) { + if(ret && file_name.empty()) { std::string::size_type pos = full_name.find_last_of('/'); if(pos != std::string::npos) { file_name = full_name.substr(pos+1); @@ -394,6 +423,7 @@ void CMoviePlayerGui::PlayFile(void) duration = p_movie_info->length * 60 * 1000; file_prozent = 0; +//full_name = "http://172.16.1.1:49152/content/media/object_id/7/res_id/0/ext/file.avi"; if(!playback->Start((char *) full_name.c_str(), vpid, vtype, currentapid, currentac3, duration)) { playback->Close(); } else {