movieplayer: add playlist_manager

NOTE: This is a merge of several patches by TangoCash
 for neutrino-mp aligned to neutrino-hd.
 We use 'play' key to open playlist_manager.


Origin commit data
------------------
Branch: ni/coolstream
Commit: dfc7a1d304
Author: TangoCash <eric@loxat.de>
Date: 2014-11-26 (Wed, 26 Nov 2014)

Origin message was:
------------------
- movieplayer: add playlist_manager

NOTE: This is a merge of several patches by TangoCash
   for neutrino-mp aligned to neutrino-hd.
   We use 'play' key to open playlist_manager.


------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2014-11-26 09:57:17 +01:00
committed by vanhofen
parent e94a2c76ce
commit cabc52c764
7 changed files with 235 additions and 5 deletions

View File

@@ -532,6 +532,7 @@ favorites.copy Kopiere Bouquet zu Favoriten
favorites.finalhint \nVersehentlich hinzugefügte Kanäle können mit\nder Bouquetverwaltung korrigiert werden.\n
favorites.menueadd Kanal Favoriten hinzufügen
favorites.nobouquets Favoriten sind nur mit aktivierten Bouquets möglich.
filebrowser.add Hinzufügen
filebrowser.delete Löschen
filebrowser.denydirectoryleave Startverzeichnis absolut
filebrowser.dodelete1 Soll
@@ -541,6 +542,7 @@ filebrowser.filter.inactive Filter aus
filebrowser.head Dateibrowser
filebrowser.mark Markieren
filebrowser.nextpage Seite vor
filebrowser.pm Playlist Manager
filebrowser.prevpage Seite zurück
filebrowser.scan Durchsuche Verzeichnisse
filebrowser.select Auswählen

View File

@@ -532,6 +532,7 @@ favorites.copy Copy bouquet to Favorites
favorites.finalhint \nUse the bouqueteditor to modify your favorites.\n
favorites.menueadd add channel to favorites
favorites.nobouquets Favorites are available with activated Bouquets only.
filebrowser.add Add
filebrowser.delete Delete
filebrowser.denydirectoryleave Absolute start directory
filebrowser.dodelete1 Delete
@@ -541,6 +542,7 @@ filebrowser.filter.inactive Filter off
filebrowser.head Filebrowser
filebrowser.mark Mark
filebrowser.nextpage Next Page
filebrowser.pm Playlist Manager
filebrowser.prevpage Prev. Page
filebrowser.scan Scaning folder
filebrowser.select Select

View File

@@ -597,6 +597,7 @@ bool CFileBrowser::exec(const char * const dirname)
bool res = false;
menu_ret = menu_return::RETURN_REPAINT;
playlistmode = false;
#ifdef ENABLE_INTERNETRADIO
if (m_Mode == ModeSC) {
m_baseurl = base;
@@ -905,6 +906,187 @@ bool CFileBrowser::exec(const char * const dirname)
return res;
}
bool CFileBrowser::playlist_manager(CFileList &playlist, unsigned int playing)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
bool res = false;
menu_ret = menu_return::RETURN_REPAINT;
filelist = playlist;
playlistmode = true;
fontInit();
paintHead();
selected = playing;
unsigned int oldselected = selected;
paint();
paintFoot();
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_FILEBROWSER]);
bool loop=true;
while (loop)
{
frameBuffer->blit();
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;
if (msg <= CRCInput::RC_MaxRC)
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_FILEBROWSER]);
if(!CRCInput::isNumeric(msg))
{
m_SMSKeyInput.resetOldKey();
paintSMSKey();
}
if (msg == CRCInput::RC_home)
{
loop = false;
}
else if (msg == NeutrinoMessages::STANDBY_ON ||
msg == NeutrinoMessages::SHUTDOWN ||
msg == NeutrinoMessages::SLEEPTIMER)
{
menu_ret = menu_return::RETURN_EXIT_ALL;
loop = false;
g_RCInput->postMsg(msg, data);
}
else if (msg == CRCInput::RC_timeout)
{
selected = oldselected;
loop = false;
}
else if (msg > CRCInput::RC_MaxRC)
{
if (CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all) {
menu_ret = menu_return::RETURN_EXIT_ALL;
loop = false;
}
}
if ((filelist.empty()))
continue;
if (msg_repeatok == CRCInput::RC_up)
{
unsigned int prevselected=selected;
unsigned int prevliststart = liststart;
if (selected)
selected --;
else
selected = filelist.size() - 1;
liststart = (selected/listmaxshow)*listmaxshow;
if(prevliststart != liststart)
{
paint();
}
else
{
paintItem(prevselected - prevliststart);
paintItem(selected - liststart);
}
}
else if (msg_repeatok == CRCInput::RC_down)
{
unsigned int prevselected=selected;
unsigned int prevliststart = liststart;
selected = (selected + 1) % filelist.size();
liststart = (selected/listmaxshow)*listmaxshow;
if(prevliststart != liststart)
{
paint();
}
else
{
paintItem(prevselected - prevliststart);
paintItem(selected - liststart);
}
}
else if (msg == (neutrino_msg_t) g_settings.key_pagedown)
{
unsigned int last = filelist.size() - 1;
if (selected != last && selected + listmaxshow >= filelist.size()) {
selected = last;
} else {
selected = (selected == last) ? 0 : selected + listmaxshow;
liststart = (selected / listmaxshow) * listmaxshow;
}
paint();
}
else if (msg == (neutrino_msg_t) g_settings.key_pageup)
{
if (selected && selected < listmaxshow) {
selected = 0;
} else {
selected = selected ? selected - listmaxshow : filelist.size() - 1;
liststart = (selected/listmaxshow)*listmaxshow;
}
paint();
}
else if (msg == CRCInput::RC_red)
{
if (filelist.size() > 1)
{
filelist.erase(filelist.begin()+selected);
if (selected) selected --;
}
paint();
}
else if (msg == CRCInput::RC_green)
{
CFileBrowser *addfiles = new CFileBrowser;
addfiles->Hide_records = true;
addfiles->Multi_Select = true;
addfiles->Dirs_Selectable = true;
addfiles->exec(g_settings.network_nfs_moviedir.c_str());
CFileList tmplist = addfiles->getSelectedFiles();
filelist.insert( filelist.end(), tmplist.begin(), tmplist.end() );
tmplist.clear();
delete addfiles;
paintHead();
paint();
paintFoot();
}
else if (msg == CRCInput::RC_yellow )
{
if (++g_settings.filebrowser_sortmethod >= FILEBROWSER_NUMBER_OF_SORT_VARIANTS)
g_settings.filebrowser_sortmethod = 0;
sort(filelist.begin(), filelist.end(), sortBy[g_settings.filebrowser_sortmethod]);
paint();
paintFoot();
}
else if (msg == CRCInput::RC_blue )
{
std::random_shuffle ( filelist.begin(), filelist.end() );
selected = 0;
paint();
paintFoot();
}
else if (msg == CRCInput::RC_ok)
{
filelist[selected].Marked = true;
loop = false;
res = true;
}
else if (CRCInput::isNumeric(msg_repeatok))
{
SMSInput(msg_repeatok);
}
}
hide();
frameBuffer->blit();
playlist = filelist;
return res;
}
void CFileBrowser::addRecursiveDir(CFileList * re_filelist, std::string rpath, bool bRootCall, CProgressWindow * progress)
{
neutrino_msg_t msg;
@@ -1115,7 +1297,7 @@ void CFileBrowser::paintHead()
l = asprintf(&l_name, "%s %s", g_Locale->getText(LOCALE_AUDIOPLAYER_ADD_SC), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
else
#endif
l = asprintf(&l_name, "%s %s", g_Locale->getText(LOCALE_FILEBROWSER_HEAD), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
l = asprintf(&l_name, "%s %s", g_Locale->getText(playlistmode ? LOCALE_FILEBROWSER_PM : LOCALE_FILEBROWSER_HEAD), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
if (l < 1) /* at least 1 for the " " space */
{
@@ -1176,6 +1358,8 @@ const struct button_label FileBrowserFilterButton[2] =
int CFileBrowser::paintFoot(bool show)
{
int cnt,res;
std::string sort_text = g_Locale->getText(LOCALE_MOVIEBROWSER_FOOT_SORT);
sort_text += g_Locale->getText(sortByNames[g_settings.filebrowser_sortmethod]);
@@ -1190,6 +1374,15 @@ int CFileBrowser::paintFoot(bool show)
if (Filter != NULL && use_filter)
f_loc = LOCALE_FILEBROWSER_FILTER_ACTIVE;
button_label_ext footerButtons_pm[] = {
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_FILEBROWSER_DELETE, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_FILEBROWSER_ADD, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_YELLOW, NONEXISTANT_LOCALE, sort_text.c_str(), sort_text_len, false },
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_AUDIOPLAYER_SHUFFLE, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_FILEBROWSER_SELECT, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_PLAY, LOCALE_FILEBROWSER_MARK, NULL, 0, false },
};
button_label_ext footerButtons[] = {
{ NEUTRINO_ICON_BUTTON_RED, NONEXISTANT_LOCALE, sort_text.c_str(), sort_text_len, false },
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_FILEBROWSER_SELECT, NULL, 0, false },
@@ -1197,17 +1390,28 @@ int CFileBrowser::paintFoot(bool show)
{ NEUTRINO_ICON_BUTTON_PLAY, LOCALE_FILEBROWSER_MARK, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_BLUE, f_loc, NULL, 0, false },
};
int cnt = sizeof(footerButtons) / sizeof(button_label_ext);
int fowidth = width - skwidth;
if (playlistmode) {
cnt = sizeof(footerButtons_pm) / sizeof(button_label_ext);
if (!show)
return paintButtons(footerButtons_pm, cnt, 0, 0, 0, 0, 0, false, NULL, NULL);
} else {
cnt = sizeof(footerButtons) / sizeof(button_label_ext);
if (!show)
return paintButtons(footerButtons, cnt, 0, 0, 0, 0, 0, false, NULL, NULL);
}
int fowidth = width - skwidth;
if (filelist.empty()) {
frameBuffer->paintBoxRel(x, y + height - foheight, width, foheight, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_MID, CORNER_BOTTOM);
return foheight;
}
int res = paintButtons(footerButtons, Filter ? cnt : cnt - 1, x, y + height - foheight, width, foheight, fowidth);
if (playlistmode)
res = paintButtons(footerButtons_pm, Filter ? cnt : cnt - 1, x, y + height - foheight, width, foheight, fowidth);
else
res = paintButtons(footerButtons, Filter ? cnt : cnt - 1, x, y + height - foheight, width, foheight, fowidth);
paintSMSKey();
return res;
}

View File

@@ -187,6 +187,7 @@ class CFileBrowser
int paintFoot(bool show = true);
void paintSMSKey();
void recursiveDelete(const char* file);
bool playlistmode;
protected:
void commonInit();
@@ -220,6 +221,7 @@ class CFileBrowser
~CFileBrowser();
bool exec(const char * const dirname);
bool playlist_manager(CFileList &playlist,unsigned int playing);
CFile *getSelectedFile();
inline const CFileList & getSelectedFiles(void) const

View File

@@ -885,6 +885,22 @@ void CMoviePlayerGui::PlayFileLoop(void)
updateLcd();
if (timeshift == TSHIFT_MODE_OFF)
callInfoViewer();
} else if (filelist.size() > 0) {
CFileBrowser playlist;
CFile *pfile = NULL;
pfile = &(*filelist_it);
if (playlist.playlist_manager(filelist, std::distance( filelist.begin(), filelist_it )))
{
playstate = CMoviePlayerGui::STOPPED;
CFile *sfile = NULL;
for (filelist_it = filelist.begin(); filelist_it != filelist.end(); ++filelist_it)
{
pfile = &(*filelist_it);
sfile = playlist.getSelectedFile();
if ( (sfile->getFileName() == pfile->getFileName()) && (sfile->getPath() == pfile->getPath()))
break;
}
}
}
} else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) {
if (playstate == CMoviePlayerGui::PAUSE) {

View File

@@ -559,6 +559,7 @@ typedef enum
LOCALE_FAVORITES_FINALHINT,
LOCALE_FAVORITES_MENUEADD,
LOCALE_FAVORITES_NOBOUQUETS,
LOCALE_FILEBROWSER_ADD,
LOCALE_FILEBROWSER_DELETE,
LOCALE_FILEBROWSER_DENYDIRECTORYLEAVE,
LOCALE_FILEBROWSER_DODELETE1,
@@ -568,6 +569,7 @@ typedef enum
LOCALE_FILEBROWSER_HEAD,
LOCALE_FILEBROWSER_MARK,
LOCALE_FILEBROWSER_NEXTPAGE,
LOCALE_FILEBROWSER_PM,
LOCALE_FILEBROWSER_PREVPAGE,
LOCALE_FILEBROWSER_SCAN,
LOCALE_FILEBROWSER_SELECT,

View File

@@ -559,6 +559,7 @@ const char * locale_real_names[] =
"favorites.finalhint",
"favorites.menueadd",
"favorites.nobouquets",
"filebrowser.add",
"filebrowser.delete",
"filebrowser.denydirectoryleave",
"filebrowser.dodelete1",
@@ -568,6 +569,7 @@ const char * locale_real_names[] =
"filebrowser.head",
"filebrowser.mark",
"filebrowser.nextpage",
"filebrowser.pm",
"filebrowser.prevpage",
"filebrowser.scan",
"filebrowser.select",