Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save A-B repeat to play list #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/basegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2517,8 +2517,8 @@ void BaseGui::createPlaylist() {
connect( playlist, SIGNAL(playlistEnded()),
mplayerwindow, SLOT(showLogo()) );

connect(playlist, SIGNAL(requestToPlayFile(const QString &, int)),
core, SLOT(open(const QString &, int)));
connect(playlist, SIGNAL(requestToPlayFile(const QString &, int, int)),
core, SLOT(open(const QString &, int, int)));

connect(playlist, SIGNAL(requestToPlayStream(const QString &, QStringList)),
core, SLOT(openStream(const QString &, QStringList)));
Expand Down Expand Up @@ -5417,7 +5417,7 @@ void BaseGui::playlistHasFinished() {
void BaseGui::addToPlaylistCurrentFile() {
qDebug("BaseGui::addToPlaylistCurrentFile");
if (!core->mdat.filename.isEmpty()) {
playlist->addItem(core->mdat.filename, "", 0);
playlist->addItem(core->mdat.filename, "", 0, core->mset.A_marker, core->mset.B_marker);
playlist->setModified(true);
playlist->getMediaInfo(core->mdat);
}
Expand Down
31 changes: 18 additions & 13 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void Core::displayTextOnOSD(QString text, int duration, int level, QString prefi
}

// Generic open, autodetect type
void Core::open(QString file, int seek) {
void Core::open(QString file, int seek, int end) {
qDebug("Core::open: '%s'", file.toUtf8().data());

if (file.startsWith("file:")) {
Expand All @@ -469,7 +469,7 @@ void Core::open(QString file, int seek) {
qDebug("Core::open: * identified as local file");
// Local file
file = QFileInfo(file).absoluteFilePath();
openFile(file, seek);
openFile(file, seek, end);
}
else
if ( (fi.exists()) && (fi.isDir()) ) {
Expand Down Expand Up @@ -553,12 +553,12 @@ void Core::open(QString file, int seek) {
}
}

void Core::openFile(QString filename, int seek) {
void Core::openFile(QString filename, int seek, int end) {
qDebug("Core::openFile: '%s'", filename.toUtf8().data());

QFileInfo fi(filename);
if (fi.exists()) {
playNewFile(fi.absoluteFilePath(), seek);
playNewFile(fi.absoluteFilePath(), seek, end);
} else {
//File doesn't exists
//TODO: error message
Expand Down Expand Up @@ -958,7 +958,7 @@ void Core::openStream(QString name, QStringList params) {
}


void Core::playNewFile(QString file, int seek) {
void Core::playNewFile(QString file, int seek, int end) {
qDebug("Core::playNewFile: '%s'", file.toUtf8().data());

if (proc->isRunning()) {
Expand Down Expand Up @@ -988,7 +988,7 @@ void Core::playNewFile(QString file, int seek) {
/* initializeMenus(); */

qDebug("Core::playNewFile: volume: %d, old_volume: %d", mset.volume, old_volume);
initPlaying(seek);
initPlaying(seek, end);
}


Expand All @@ -997,7 +997,7 @@ void Core::restartPlay() {
initPlaying();
}

void Core::initPlaying(int seek) {
void Core::initPlaying(int seek, int end) {
qDebug("Core::initPlaying");

/*
Expand All @@ -1015,6 +1015,7 @@ void Core::initPlaying(int seek) {

int start_sec = (int) mset.current_sec;
if (seek > -1) start_sec = seek;
int end_sec = end;

if (initial_second != 0) {
qDebug("Core::initPlaying: initial_second: %d", initial_second);
Expand All @@ -1033,7 +1034,7 @@ void Core::initPlaying(int seek) {
}
#endif

startMplayer( mdat.filename, start_sec );
startMplayer( mdat.filename, start_sec, end_sec );
}

// This is reached when a new video has just started playing
Expand Down Expand Up @@ -1519,9 +1520,8 @@ void Core::goToPos(int perc) {
}
#endif


void Core::startMplayer( QString file, double seek ) {
qDebug() << "Core::startMplayer: file:" << file << "seek:" << seek;
void Core::startMplayer( QString file, double seek, double end ) {
qDebug() << "Core::startMplayer: file:" << file << "seek:" << seek << "end:" << end;

if (file.isEmpty()) {
qWarning("Core:startMplayer: file is empty!");
Expand Down Expand Up @@ -2205,6 +2205,9 @@ void Core::startMplayer( QString file, double seek ) {
proc->setOption("ab-loop-b", QString::number(mset.B_marker));
}
proc->setOption("ss", QString::number(seek));
if (end > 0) {
proc->setOption("endpos", QString::number(end - seek));
}
} else
#endif
{
Expand All @@ -2213,9 +2216,11 @@ void Core::startMplayer( QString file, double seek ) {
}
}
else
// If seek < 5 it's better to allow the video to start from the beginning
if ((seek >= 5) && (!mset.loop)) {
if (!mset.loop) {
proc->setOption("ss", QString::number(seek));
if (end > 0) {
proc->setOption("endpos", QString::number(end - seek));
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Core : public QObject

public slots:
//! Generic open, with autodetection of type
void open(QString file, int seek=-1);
void openFile(QString filename, int seek=-1);
void open(QString file, int seek=-1, int end=-1);
void openFile(QString filename, int seek=-1, int end=-1);
void openStream(QString name, QStringList params = QStringList());
/*
void openDVD( bool from_folder, QString directory = "");
Expand Down Expand Up @@ -480,12 +480,12 @@ protected slots:
#endif

protected:
void playNewFile(QString file, int seek=-1);
void playNewFile(QString file, int seek=-1, int end=-1);
void restartPlay();
void initPlaying(int seek=-1);
void initPlaying(int seek=-1, int end=-1);
void newMediaPlaying();

void startMplayer(QString file, double seek = -1 );
void startMplayer(QString file, double seek = -1, double end = -1 );
void stopMplayer();

void saveMediaInfo();
Expand Down
4 changes: 4 additions & 0 deletions src/mediadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void MediaData::reset() {
dvd_id="";
type = TYPE_UNKNOWN;
duration=0;
markerA=-1;
markerB=-1;

extra_params.clear();

Expand Down Expand Up @@ -108,6 +110,8 @@ void MediaData::list() {

qDebug(" filename: '%s'", filename.toUtf8().data());
qDebug(" duration: %f", duration);
qDebug(" markerA: %f", markerA);
qDebug(" markerB: %f", markerB);

qDebug(" video_width: %d", video_width);
qDebug(" video_height: %d", video_height);
Expand Down
2 changes: 2 additions & 0 deletions src/mediadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class MediaData {

QString filename;
double duration;
double markerA;
double markerB;

QStringList extra_params; // For streams

Expand Down
Loading