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

Play multiple files #399

Open
wants to merge 3 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
2 changes: 2 additions & 0 deletions KeyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ map<int, int> KeyConfig::buildDefaultKeymap()
keymap['v'] = ACTION_STEP;
keymap['w'] = ACTION_SHOW_SUBTITLES;
keymap['x'] = ACTION_HIDE_SUBTITLES;
keymap['b'] = ACTION_PREVIOUS_FILE;
keymap['a'] = ACTION_NEXT_FILE;

return keymap;
}
Expand Down
2 changes: 2 additions & 0 deletions KeyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class KeyConfig
ACTION_PLAY = 36,
ACTION_CHANGE_FILE = 37,
ACTION_SET_LAYER = 38,
ACTION_PREVIOUS_FILE = 39,
ACTION_NEXT_FILE = 40
};

#define KEY_LEFT 0x5b44
Expand Down
10 changes: 10 additions & 0 deletions OMXControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,16 @@ OMXControlResult OMXControl::handle_event(DBusMessage *m)
dbus_respond_ok(m);
return KeyConfig::ACTION_PREVIOUS_CHAPTER;
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "NextFile"))
{
dbus_respond_ok(m);
return KeyConfig::ACTION_NEXT_FILE;
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "PreviousFile"))
{
dbus_respond_ok(m);
return KeyConfig::ACTION_PREVIOUS_FILE;
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "Pause"))
{
dbus_respond_ok(m);
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Copy over `omxplayer-dist/*` to the Pi `/`.

## SYNOPSIS

Usage: omxplayer [OPTIONS] [FILE]
Usage: omxplayer [OPTIONS] [FILE] ...

-h --help Print this help
-v --version Print version info
Expand Down Expand Up @@ -136,7 +136,7 @@ Usage: omxplayer [OPTIONS] [FILE]

For example:

./omxplayer -p -o hdmi test.mkv
./omxplayer -p -o hdmi test.mkv test2.mpeg

## KEY BINDINGS

Expand All @@ -151,6 +151,8 @@ Key bindings to control omxplayer while playing:
k next audio stream
i previous chapter
o next chapter
b previous file
a next file
n previous subtitle stream
m next subtitle stream
s toggle subtitles
Expand Down Expand Up @@ -182,6 +184,8 @@ The list of valid [action]s roughly corresponds to the list of default key bindi
NEXT_AUDIO
PREVIOUS_CHAPTER
NEXT_CHAPTER
PREVIOUS_FILE
NEXT_FILE
PREVIOUS_SUBTITLE
NEXT_SUBTITLE
TOGGLE_SUBTITLE
Expand Down Expand Up @@ -363,6 +367,22 @@ paused it will stay in pause (no effect).
:-------------: | -------
Return | `null`

#### NextFile

Skip to the next file.

Params | Type
:-------------: | -------
Return | `null`

#### PreviousFile

Skip to the previous file.

Params | Type
:-------------: | -------
Return | `null`

##### PlayPause

Toggles the play state. If the video is playing, it will be paused, if it is
Expand Down
23 changes: 22 additions & 1 deletion omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ int main(int argc, char *argv[])
TV_DISPLAY_STATE_T tv_state;
double last_seek_pos = 0;
bool idle = false;
bool m_continue = true;
std::string m_cookie = "";
std::string m_user_agent = "";
std::string m_lavfdopts = "";
Expand Down Expand Up @@ -934,6 +935,9 @@ int main(int argc, char *argv[])
return 0;
}

int firstFileIndex = optind;
while(optind < argc) {
m_continue = false;
m_filename = argv[optind];

auto PrintFileNotFound = [](const std::string& path)
Expand Down Expand Up @@ -1422,6 +1426,16 @@ int main(int argc, char *argv[])
m_stop = true;
goto do_exit;
break;
case KeyConfig::ACTION_NEXT_FILE:
goto do_continue;
break;
case KeyConfig::ACTION_PREVIOUS_FILE:
if(optind > firstFileIndex){
// will be increased by one at the end of the loop
optind-=2;
}
goto do_continue;
break;
case KeyConfig::ACTION_SEEK_BACK_SMALL:
if(m_omx_reader.CanSeek()) m_incr = -30.0;
break;
Expand Down Expand Up @@ -1578,7 +1592,7 @@ int main(int argc, char *argv[])
sentStarted = false;

if (m_omx_reader.IsEof())
goto do_exit;
goto do_continue;

// Quick reset to reduce delay during loop & seek.
if (m_has_video && !m_player_video.Reset())
Expand Down Expand Up @@ -1828,6 +1842,8 @@ int main(int argc, char *argv[])
}
}

do_continue:
m_continue = true;
do_exit:
if (m_stats)
printf("\n");
Expand Down Expand Up @@ -1876,6 +1892,11 @@ int main(int argc, char *argv[])
g_OMX.Deinitialize();
g_RBP.Deinitialize();

if(!m_continue){
break;
}
optind++;
}
printf("have a nice day ;)\n");

// exit status success on playback end
Expand Down