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
This commit is contained in:
[CST] Focus
2014-04-21 14:05:53 +04:00
parent fd49c36a7b
commit ebf37fd192
2 changed files with 60 additions and 31 deletions

View File

@@ -349,6 +349,7 @@ void CMoviePlayerGui::Cleanup()
startposition = 0;
is_file_player = false;
p_movie_info = NULL;
autoshot_done = false;
}
void CMoviePlayerGui::makeFilename()
@@ -640,6 +641,8 @@ void CMoviePlayerGui::PlayFile(void)
g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ());
} else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) {
playstate = CMoviePlayerGui::STOPPED;
if ((duration - position) > 600000)
makeScreenShot(true);
} else if (msg == (neutrino_msg_t) g_settings.mpkey_play) {
if (time_forced) {
time_forced = false;
@@ -772,34 +775,7 @@ void CMoviePlayerGui::PlayFile(void)
} else if (msg == NeutrinoMessages::SHOW_EPG) {
handleMovieBrowser(NeutrinoMessages::SHOW_EPG, position);
} else if (msg == (neutrino_msg_t) g_settings.key_screenshot) {
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();
makeScreenShot();
} else if ( msg == NeutrinoMessages::EVT_SUBT_MESSAGE) {
showSubtitle(data);
} else if ( msg == NeutrinoMessages::ANNOUNCE_RECORD ||
@@ -815,9 +791,12 @@ void CMoviePlayerGui::PlayFile(void)
playstate = CMoviePlayerGui::STOPPED;
g_RCInput->postMsg(msg, data);
} else if (msg == CRCInput::RC_timeout) {
// nothing
} else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) {
} else if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) {
if (playstate == CMoviePlayerGui::PLAY && position >= 300000)
makeScreenShot(true);
} else if (msg == CRCInput::RC_favorites) {
makeScreenShot(false, true);
} else if (msg == CRCInput::RC_sat) {
//FIXME do nothing ?
} else {
if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) {
@@ -1730,3 +1709,51 @@ bool CMoviePlayerGui::mountIso(CFile *file)
}
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();
}