gui/movieplayer.cpp: add chapters support, at the moment on bookmarks (blue) key

This commit is contained in:
[CST] Focus
2013-05-10 16:34:12 +04:00
parent a6d7577235
commit 98829743b3
2 changed files with 50 additions and 18 deletions

View File

@@ -572,34 +572,35 @@ void CMoviePlayerGui::PlayFile(void)
callInfoViewer(/*duration, position*/); callInfoViewer(/*duration, position*/);
} else if (msg == (neutrino_msg_t) g_settings.mpkey_bookmark) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_bookmark) {
handleMovieBrowser((neutrino_msg_t) g_settings.mpkey_bookmark, position); if (is_file_player)
selectChapter();
else
handleMovieBrowser((neutrino_msg_t) g_settings.mpkey_bookmark, position);
} else if (msg == (neutrino_msg_t) g_settings.mpkey_audio) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_audio) {
selectAudioPid(is_file_player); selectAudioPid(is_file_player);
update_lcd = true; update_lcd = true;
clearSubtitle(); clearSubtitle();
} else if ( msg == (neutrino_msg_t) g_settings.mpkey_subtitle) { } else if ( msg == (neutrino_msg_t) g_settings.mpkey_subtitle) {
selectSubtitle(is_file_player); selectSubtitle();
clearSubtitle(); clearSubtitle();
update_lcd = true; update_lcd = true;
} else if (msg == (neutrino_msg_t) g_settings.mpkey_time) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_time) {
FileTime.switchMode(position, duration); FileTime.switchMode(position, duration);
} else if (!is_file_player && ((msg == (neutrino_msg_t) g_settings.mpkey_rewind) || } else if (/*!is_file_player &&*/ ((msg == (neutrino_msg_t) g_settings.mpkey_rewind) ||
(msg == (neutrino_msg_t) g_settings.mpkey_forward))) { (msg == (neutrino_msg_t) g_settings.mpkey_forward))) {
int newspeed; int newspeed;
if (msg == (neutrino_msg_t) g_settings.mpkey_rewind) { if (msg == (neutrino_msg_t) g_settings.mpkey_rewind) {
newspeed = (speed >= 0) ? -1 : speed - 1; newspeed = (speed >= 0) ? -1 : speed - 1;
if (playstate != CMoviePlayerGui::PAUSE)
playstate = CMoviePlayerGui::REW;
} else { } else {
newspeed = (speed <= 0) ? 2 : speed + 1; newspeed = (speed <= 0) ? 2 : speed + 1;
if (playstate != CMoviePlayerGui::PAUSE)
playstate = CMoviePlayerGui::FF;
} }
/* if paused, playback->SetSpeed() start slow motion */ /* if paused, playback->SetSpeed() start slow motion */
if (playback->SetSpeed(newspeed)) { if (playback->SetSpeed(newspeed)) {
printf("SetSpeed: update speed\n"); printf("SetSpeed: update speed\n");
speed = newspeed; speed = newspeed;
if (playstate != CMoviePlayerGui::PAUSE)
playstate = msg == (neutrino_msg_t) g_settings.mpkey_rewind ? CMoviePlayerGui::REW : CMoviePlayerGui::FF;
updateLcd(); updateLcd();
} }
//update_lcd = true; //update_lcd = true;
@@ -785,13 +786,13 @@ bool CMoviePlayerGui::getAudioName(int apid, std::string &apidtitle)
return false; return false;
} }
void CMoviePlayerGui::addAudioFormat(int count, std::string &apidtitle, bool file_player, bool& enabled) void CMoviePlayerGui::addAudioFormat(int count, std::string &apidtitle, bool& enabled)
{ {
enabled = true; enabled = true;
switch(ac3flags[count]) switch(ac3flags[count])
{ {
case 1: /*AC3,EAC3*/ case 1: /*AC3,EAC3*/
if (apidtitle.find("AC3") == std::string::npos || file_player) if (apidtitle.find("AC3") == std::string::npos)
apidtitle.append(" (AC3)"); apidtitle.append(" (AC3)");
break; break;
case 2: /*teletext*/ case 2: /*teletext*/
@@ -808,7 +809,8 @@ void CMoviePlayerGui::addAudioFormat(int count, std::string &apidtitle, bool fil
apidtitle.append(" (AAC)"); apidtitle.append(" (AAC)");
break; break;
case 6: /*DTS*/ case 6: /*DTS*/
apidtitle.append(" (DTS)"); if (apidtitle.find("DTS") == std::string::npos)
apidtitle.append(" (DTS)");
#ifndef BOXMODEL_APOLLO #ifndef BOXMODEL_APOLLO
enabled = false; enabled = false;
#endif #endif
@@ -834,9 +836,9 @@ void CMoviePlayerGui::getCurrentAudioName( bool file_player, std::string &audion
if(!file_player){ if(!file_player){
getAudioName(apids[count], audioname); getAudioName(apids[count], audioname);
return ; return ;
}else if (!language[count].empty()){ } else if (!language[count].empty()){
audioname = language[count]; audioname = language[count];
addAudioFormat(count, audioname, file_player, dumm); addAudioFormat(count, audioname, dumm);
if(!dumm && (count < numpida)){ if(!dumm && (count < numpida)){
currentapid = apids[count+1]; currentapid = apids[count+1];
continue; continue;
@@ -846,7 +848,7 @@ void CMoviePlayerGui::getCurrentAudioName( bool file_player, std::string &audion
char apidnumber[20]; char apidnumber[20];
sprintf(apidnumber, "Stream %d %X", count + 1, apids[count]); sprintf(apidnumber, "Stream %d %X", count + 1, apids[count]);
audioname = apidnumber; audioname = apidnumber;
addAudioFormat(count, audioname, file_player, dumm); addAudioFormat(count, audioname, dumm);
if(!dumm && (count < numpida)){ if(!dumm && (count < numpida)){
currentapid = apids[count+1]; currentapid = apids[count+1];
continue; continue;
@@ -887,7 +889,7 @@ void CMoviePlayerGui::selectAudioPid(bool file_player)
sprintf(apidnumber, "Stream %d %X", count + 1, apids[count]); sprintf(apidnumber, "Stream %d %X", count + 1, apids[count]);
apidtitle = apidnumber; apidtitle = apidnumber;
} }
addAudioFormat(count, apidtitle, file_player, enabled); addAudioFormat(count, apidtitle, enabled);
if(defpid && !enabled && (count < numpida)){ if(defpid && !enabled && (count < numpida)){
currentapid = apids[count+1]; currentapid = apids[count+1];
defpid = false; defpid = false;
@@ -1209,9 +1211,37 @@ void CMoviePlayerGui::showHelpTS()
helpbox.show(LOCALE_MESSAGEBOX_INFO); helpbox.show(LOCALE_MESSAGEBOX_INFO);
} }
void CMoviePlayerGui::selectSubtitle(bool file_player) void CMoviePlayerGui::selectChapter()
{ {
if (!file_player) if (!is_file_player)
return;
std::vector<int> positions; std::vector<std::string> titles;
playback->GetChapters(positions, titles);
if (positions.empty())
return;
CMenuWidget ChSelector(LOCALE_MOVIEBROWSER_MENU_MAIN_BOOKMARKS, NEUTRINO_ICON_AUDIO);
ChSelector.addIntroItems();
int select = -1;
CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
char cnt[5];
for (unsigned i = 0; i < positions.size(); i++) {
sprintf(cnt, "%d", i);
CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(titles[i].c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1));
ChSelector.addItem(item, position > positions[i]);
}
ChSelector.exec(NULL, "");
delete selector;
printf("CMoviePlayerGui::selectChapter: selected %d (%d)\n", select, (select >= 0) ? positions[select] : -1);
if(select >= 0)
playback->SetPosition(positions[select], true);
}
void CMoviePlayerGui::selectSubtitle()
{
if (!is_file_player)
return; return;
CMenuWidget APIDSelector(LOCALE_SUBTITLES_HEAD, NEUTRINO_ICON_AUDIO); CMenuWidget APIDSelector(LOCALE_SUBTITLES_HEAD, NEUTRINO_ICON_AUDIO);
@@ -1235,6 +1265,7 @@ void CMoviePlayerGui::selectSubtitle(bool file_player)
} }
sprintf(cnt, "%d", count); sprintf(cnt, "%d", count);
CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1));
item->setItemButton(NEUTRINO_ICON_BUTTON_STOP, false);
APIDSelector.addItem(item, defpid); APIDSelector.addItem(item, defpid);
} }
sprintf(cnt, "%d", count); sprintf(cnt, "%d", count);

View File

@@ -127,15 +127,16 @@ class CMoviePlayerGui : public CMenuTarget
bool getAudioName(int pid, std::string &apidtitle); bool getAudioName(int pid, std::string &apidtitle);
void selectAudioPid(bool file_player); void selectAudioPid(bool file_player);
void getCurrentAudioName( bool file_player, std::string &audioname); void getCurrentAudioName( bool file_player, std::string &audioname);
void addAudioFormat(int count, std::string &apidtitle, bool file_player, bool& enabled ); void addAudioFormat(int count, std::string &apidtitle, bool& enabled );
void handleMovieBrowser(neutrino_msg_t msg, int position = 0); void handleMovieBrowser(neutrino_msg_t msg, int position = 0);
bool SelectFile(); bool SelectFile();
void updateLcd(); void updateLcd();
void selectSubtitle(bool file_player); void selectSubtitle();
void showSubtitle(neutrino_msg_data_t data); void showSubtitle(neutrino_msg_data_t data);
void clearSubtitle(); void clearSubtitle();
void selectChapter();
CMoviePlayerGui(const CMoviePlayerGui&) {}; CMoviePlayerGui(const CMoviePlayerGui&) {};
CMoviePlayerGui(); CMoviePlayerGui();