mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
gui/movieplayer.cpp: add support to play files from upnp browser,
add support to stop playback while open in progress, to interrupt i.e. ffmpeg analyze etc, based on code (c) martii <m4rtii@gmx.de>
This commit is contained in:
@@ -50,6 +50,8 @@
|
|||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <libtuxtxt/teletext.h>
|
#include <libtuxtxt/teletext.h>
|
||||||
#include <zapit/zapit.h>
|
#include <zapit/zapit.h>
|
||||||
|
#include <system/set_threadname.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -138,6 +140,7 @@ void CMoviePlayerGui::Init(void)
|
|||||||
speed = 1;
|
speed = 1;
|
||||||
timeshift = 0;
|
timeshift = 0;
|
||||||
numpida = 0;
|
numpida = 0;
|
||||||
|
showStartingHint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayerGui::cutNeutrino()
|
void CMoviePlayerGui::cutNeutrino()
|
||||||
@@ -146,13 +149,17 @@ void CMoviePlayerGui::cutNeutrino()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
playing = true;
|
playing = true;
|
||||||
|
/* set g_InfoViewer update timer to 1 sec, should be reset to default from restoreNeutrino->set neutrino mode */
|
||||||
|
g_InfoViewer->setUpdateTimer(1000 * 1000);
|
||||||
|
|
||||||
|
if (isUPNP)
|
||||||
|
return;
|
||||||
|
|
||||||
g_Zapit->lockPlayBack();
|
g_Zapit->lockPlayBack();
|
||||||
g_Sectionsd->setPauseScanning(true);
|
g_Sectionsd->setPauseScanning(true);
|
||||||
|
|
||||||
CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoMessages::mode_ts);
|
CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoMessages::mode_ts);
|
||||||
m_LastMode = (CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);
|
m_LastMode = (CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);
|
||||||
/* set g_InfoViewer update timer to 1 sec, should be reset to default from restoreNeutrino->set neutrino mode */
|
|
||||||
g_InfoViewer->setUpdateTimer(1000 * 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayerGui::restoreNeutrino()
|
void CMoviePlayerGui::restoreNeutrino()
|
||||||
@@ -162,6 +169,9 @@ void CMoviePlayerGui::restoreNeutrino()
|
|||||||
|
|
||||||
playing = false;
|
playing = false;
|
||||||
|
|
||||||
|
if (isUPNP)
|
||||||
|
return;
|
||||||
|
|
||||||
g_Zapit->unlockPlayBack();
|
g_Zapit->unlockPlayBack();
|
||||||
g_Sectionsd->setPauseScanning(false);
|
g_Sectionsd->setPauseScanning(false);
|
||||||
|
|
||||||
@@ -175,18 +185,12 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey)
|
|||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
file_name = "";
|
|
||||||
full_name = "";
|
|
||||||
|
|
||||||
startposition = 0;
|
|
||||||
|
|
||||||
puts("[movieplayer.cpp] executing " MOVIEPLAYER_START_SCRIPT ".");
|
puts("[movieplayer.cpp] executing " MOVIEPLAYER_START_SCRIPT ".");
|
||||||
if (my_system(MOVIEPLAYER_START_SCRIPT) != 0)
|
if (my_system(MOVIEPLAYER_START_SCRIPT) != 0)
|
||||||
perror(MOVIEPLAYER_START_SCRIPT " failed");
|
perror(MOVIEPLAYER_START_SCRIPT " failed");
|
||||||
|
|
||||||
isMovieBrowser = false;
|
Cleanup();
|
||||||
isBookmark = false;
|
|
||||||
timeshift = 0;
|
|
||||||
if (actionKey == "tsmoviebrowser") {
|
if (actionKey == "tsmoviebrowser") {
|
||||||
isMovieBrowser = true;
|
isMovieBrowser = true;
|
||||||
moviebrowser->setMode(MB_SHOW_RECORDS);
|
moviebrowser->setMode(MB_SHOW_RECORDS);
|
||||||
@@ -212,11 +216,17 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey)
|
|||||||
isBookmark = true;
|
isBookmark = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if (actionKey == "upnp") {
|
||||||
|
isUPNP = true;
|
||||||
|
p_movie_info = NULL;
|
||||||
|
is_file_player = 1;
|
||||||
|
PlayFile();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(SelectFile()) {
|
while(!isHTTP && !isUPNP && SelectFile()) {
|
||||||
PlayFile();
|
PlayFile();
|
||||||
if(timeshift)
|
if(timeshift)
|
||||||
break;
|
break;
|
||||||
@@ -304,11 +314,8 @@ void CMoviePlayerGui::fillPids()
|
|||||||
vtype = p_movie_info->VideoType;
|
vtype = p_movie_info->VideoType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMoviePlayerGui::SelectFile()
|
void CMoviePlayerGui::Cleanup()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
menu_ret = menu_return::RETURN_REPAINT;
|
|
||||||
|
|
||||||
/*clear audiopids */
|
/*clear audiopids */
|
||||||
for (int i = 0; i < numpida; i++) {
|
for (int i = 0; i < numpida; i++) {
|
||||||
apids[i] = 0;
|
apids[i] = 0;
|
||||||
@@ -319,9 +326,23 @@ bool CMoviePlayerGui::SelectFile()
|
|||||||
currentspid = -1;
|
currentspid = -1;
|
||||||
numsubs = 0;
|
numsubs = 0;
|
||||||
|
|
||||||
|
startposition = 0;
|
||||||
|
isMovieBrowser = false;
|
||||||
|
isBookmark = false;
|
||||||
|
timeshift = 0;
|
||||||
|
isHTTP = false;
|
||||||
|
isUPNP = false;
|
||||||
is_file_player = false;
|
is_file_player = false;
|
||||||
p_movie_info = NULL;
|
p_movie_info = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMoviePlayerGui::SelectFile()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
menu_ret = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
file_name = "";
|
file_name = "";
|
||||||
|
full_name = "";
|
||||||
|
|
||||||
printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser);
|
printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser);
|
||||||
if (has_hdd)
|
if (has_hdd)
|
||||||
@@ -431,6 +452,27 @@ bool CMoviePlayerGui::SelectFile()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *CMoviePlayerGui::ShowStartHint(void *arg)
|
||||||
|
{
|
||||||
|
set_threadname(__func__);
|
||||||
|
CMoviePlayerGui *caller = (CMoviePlayerGui *)arg;
|
||||||
|
|
||||||
|
CHintBox hintbox(LOCALE_MOVIEPLAYER_STARTING, caller->file_name.c_str(), 450, NEUTRINO_ICON_MOVIEPLAYER);
|
||||||
|
hintbox.paint();
|
||||||
|
|
||||||
|
while (caller->showStartingHint) {
|
||||||
|
neutrino_msg_t msg;
|
||||||
|
neutrino_msg_data_t data;
|
||||||
|
g_RCInput->getMsg(&msg, &data, 1);
|
||||||
|
if (msg == CRCInput::RC_home || msg == CRCInput::RC_stop) {
|
||||||
|
if(caller->playback)
|
||||||
|
caller->playback->RequestAbort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hintbox.hide();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void CMoviePlayerGui::PlayFile(void)
|
void CMoviePlayerGui::PlayFile(void)
|
||||||
{
|
{
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
@@ -463,7 +505,18 @@ void CMoviePlayerGui::PlayFile(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file_prozent = 0;
|
file_prozent = 0;
|
||||||
if(!playback->Start((char *) full_name.c_str(), vpid, vtype, currentapid, currentac3, duration)) {
|
pthread_t thrStartHint;
|
||||||
|
if (is_file_player) {
|
||||||
|
showStartingHint = true;
|
||||||
|
pthread_create(&thrStartHint, NULL, CMoviePlayerGui::ShowStartHint, this);
|
||||||
|
}
|
||||||
|
bool res = playback->Start((char *) full_name.c_str(), vpid, vtype, currentapid, currentac3, duration);
|
||||||
|
if (thrStartHint) {
|
||||||
|
showStartingHint = false;
|
||||||
|
pthread_join(thrStartHint, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!res) {
|
||||||
playback->Close();
|
playback->Close();
|
||||||
} else {
|
} else {
|
||||||
playstate = CMoviePlayerGui::PLAY;
|
playstate = CMoviePlayerGui::PLAY;
|
||||||
|
@@ -98,6 +98,9 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
|
|
||||||
/* playback from MB */
|
/* playback from MB */
|
||||||
bool isMovieBrowser;
|
bool isMovieBrowser;
|
||||||
|
bool isHTTP;
|
||||||
|
bool isUPNP;
|
||||||
|
bool showStartingHint;
|
||||||
CMovieBrowser* moviebrowser;
|
CMovieBrowser* moviebrowser;
|
||||||
MI_MOVIE_INFO * p_movie_info;
|
MI_MOVIE_INFO * p_movie_info;
|
||||||
const static short MOVIE_HINT_BOX_TIMER = 5; // time to show bookmark hints in seconds
|
const static short MOVIE_HINT_BOX_TIMER = 5; // time to show bookmark hints in seconds
|
||||||
@@ -138,6 +141,9 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
void clearSubtitle();
|
void clearSubtitle();
|
||||||
void selectChapter();
|
void selectChapter();
|
||||||
|
|
||||||
|
void Cleanup();
|
||||||
|
static void *ShowStartHint(void *arg);
|
||||||
|
|
||||||
CMoviePlayerGui(const CMoviePlayerGui&) {};
|
CMoviePlayerGui(const CMoviePlayerGui&) {};
|
||||||
CMoviePlayerGui();
|
CMoviePlayerGui();
|
||||||
|
|
||||||
@@ -155,6 +161,7 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
void UpdatePosition();
|
void UpdatePosition();
|
||||||
int timeshift;
|
int timeshift;
|
||||||
int file_prozent;
|
int file_prozent;
|
||||||
|
void SetFile(std::string &name, std::string &file) { file_name = name; full_name = file; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user