gui/movieplayer.cpp: auto-create movie thumbnail, if enabled,

at playback when position more than 5 min from start,
or on stop if position more than 10 minutes before end;
create movie thumbnail with RC_favorites key


Origin commit data
------------------
Branch: ni/coolstream
Commit: ebf37fd192
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-04-21 (Mon, 21 Apr 2014)



------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2014-04-21 14:05:53 +04:00
parent cf62382309
commit cbff8cc356
2 changed files with 60 additions and 31 deletions

View File

@@ -349,6 +349,7 @@ void CMoviePlayerGui::Cleanup()
startposition = 0; startposition = 0;
is_file_player = false; is_file_player = false;
p_movie_info = NULL; p_movie_info = NULL;
autoshot_done = false;
} }
void CMoviePlayerGui::makeFilename() void CMoviePlayerGui::makeFilename()
@@ -640,6 +641,8 @@ void CMoviePlayerGui::PlayFile(void)
g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ()); g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ());
} else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) {
playstate = CMoviePlayerGui::STOPPED; playstate = CMoviePlayerGui::STOPPED;
if ((duration - position) > 600000)
makeScreenShot(true);
} else if (msg == (neutrino_msg_t) g_settings.mpkey_play) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_play) {
if (time_forced) { if (time_forced) {
time_forced = false; time_forced = false;
@@ -772,34 +775,7 @@ void CMoviePlayerGui::PlayFile(void)
} else if (msg == NeutrinoMessages::SHOW_EPG) { } else if (msg == NeutrinoMessages::SHOW_EPG) {
handleMovieBrowser(NeutrinoMessages::SHOW_EPG, position); handleMovieBrowser(NeutrinoMessages::SHOW_EPG, position);
} else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { } else if (msg == (neutrino_msg_t) g_settings.key_screenshot) {
makeScreenShot();
char ending[(sizeof(int)*2) + 6] = ".jpg";
if(!g_settings.screenshot_cover)
snprintf(ending, sizeof(ending) - 1, "_%x.jpg", position);
std::string fname = full_name;
std::string::size_type pos = fname.find_last_of('.');
if(pos != std::string::npos) {
fname.replace(pos, fname.length(), ending);
} else
fname += ending;
if(!g_settings.screenshot_cover){
pos = fname.find_last_of('/');
if(pos != std::string::npos) {
fname.replace(0, pos, g_settings.screenshot_dir);
}
}
#if 0 // TODO disable overwrite ?
if(!access(fname.c_str(), F_OK)) {
}
#endif
CScreenShot * sc = new CScreenShot(fname);
if(g_settings.screenshot_cover && !g_settings.screenshot_video)
sc->EnableVideo(true);
sc->Start();
} else if ( msg == NeutrinoMessages::EVT_SUBT_MESSAGE) { } else if ( msg == NeutrinoMessages::EVT_SUBT_MESSAGE) {
showSubtitle(data); showSubtitle(data);
} else if ( msg == NeutrinoMessages::ANNOUNCE_RECORD || } else if ( msg == NeutrinoMessages::ANNOUNCE_RECORD ||
@@ -815,9 +791,12 @@ void CMoviePlayerGui::PlayFile(void)
playstate = CMoviePlayerGui::STOPPED; playstate = CMoviePlayerGui::STOPPED;
g_RCInput->postMsg(msg, data); g_RCInput->postMsg(msg, data);
} else if (msg == CRCInput::RC_timeout) { } else if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) {
// nothing if (playstate == CMoviePlayerGui::PLAY && position >= 300000)
} else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { makeScreenShot(true);
} else if (msg == CRCInput::RC_favorites) {
makeScreenShot(false, true);
} else if (msg == CRCInput::RC_sat) {
//FIXME do nothing ? //FIXME do nothing ?
} else { } else {
if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) {
@@ -1730,3 +1709,51 @@ bool CMoviePlayerGui::mountIso(CFile *file)
} }
return false; return false;
} }
void CMoviePlayerGui::makeScreenShot(bool autoshot, bool forcover)
{
if (autoshot) {
if (autoshot_done || !g_settings.auto_cover)
return;
autoshot_done = true;
}
bool cover = autoshot || g_settings.screenshot_cover || forcover;
char ending[(sizeof(int)*2) + 6] = ".jpg";
if (!cover)
snprintf(ending, sizeof(ending) - 1, "_%x.jpg", position);
std::string fname = full_name;
std::string::size_type pos = fname.find_last_of('.');
if (pos != std::string::npos) {
fname.replace(pos, fname.length(), ending);
} else
fname += ending;
if (autoshot && !access(fname.c_str(), F_OK)) {
printf("CMoviePlayerGui::makeScreenShot: cover [%s] already exist..\n", fname.c_str());
return;
}
if (!cover) {
pos = fname.find_last_of('/');
if(pos != std::string::npos)
fname.replace(0, pos, g_settings.screenshot_dir);
}
CScreenShot * sc = new CScreenShot(fname);
if (cover) {
sc->EnableVideo(true);
}
if (autoshot || forcover) {
int xres = 0, yres = 0, framerate;
videoDecoder->getPictureInfo(xres, yres, framerate);
if (xres && yres) {
int w = std::min(300, xres);
int h = (float) yres / ((float) xres / (float) w);
sc->SetSize(w, h);
}
}
sc->Start();
}

View File

@@ -113,6 +113,7 @@ class CMoviePlayerGui : public CMenuTarget
CFileFilter tsfilefilter; CFileFilter tsfilefilter;
std::string Path_local; std::string Path_local;
int menu_ret; int menu_ret;
bool autoshot_done;
/* playback from bookmark */ /* playback from bookmark */
CBookmarkManager * bookmarkmanager; CBookmarkManager * bookmarkmanager;
@@ -147,6 +148,7 @@ class CMoviePlayerGui : public CMenuTarget
void parsePlaylist(CFile *file); void parsePlaylist(CFile *file);
bool mountIso(CFile *file); bool mountIso(CFile *file);
void makeFilename(); void makeFilename();
void makeScreenShot(bool autoshot = false, bool forcover = false);
void Cleanup(); void Cleanup();
static void *ShowStartHint(void *arg); static void *ShowStartHint(void *arg);