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

Options for start and end paused #669

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Usage: omxplayer [OPTIONS] [FILE]
--user-agent 'ua' Send specified User-Agent as part of HTTP requests
--lavfdopts 'opts' Options passed to libavformat, e.g. 'probesize:250000,...'
--avdict 'opts' Options passed to demuxer, e.g., 'rtsp_transport:tcp,...'
--start-paused Immediately pause the video after loading, will wait for dbus or key command to play

For example:

Expand Down
24 changes: 22 additions & 2 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ bool m_has_audio = false;
bool m_has_subtitle = false;
bool m_gen_log = false;
bool m_loop = false;
bool m_start_paused = false;

enum{ERROR=-1,SUCCESS,ONEBYTE};

Expand Down Expand Up @@ -569,6 +570,7 @@ int main(int argc, char *argv[])
const int http_user_agent_opt = 0x301;
const int lavfdopts_opt = 0x400;
const int avdict_opt = 0x401;
const int start_paused = 0x214;

struct option longopts[] = {
{ "info", no_argument, NULL, 'i' },
Expand Down Expand Up @@ -618,6 +620,7 @@ int main(int argc, char *argv[])
{ "key-config", required_argument, NULL, key_config_opt },
{ "no-osd", no_argument, NULL, no_osd_opt },
{ "no-keys", no_argument, NULL, no_keys_opt },
{ "start-paused", no_argument, NULL, start_paused },
{ "orientation", required_argument, NULL, orientation_opt },
{ "fps", required_argument, NULL, fps_opt },
{ "live", no_argument, NULL, live_opt },
Expand Down Expand Up @@ -765,6 +768,9 @@ int main(int argc, char *argv[])
case no_keys_opt:
m_no_keys = true;
break;
case start_paused:
m_start_paused = true;
break;
case font_opt:
m_font_path = optarg;
m_asked_for_font = true;
Expand Down Expand Up @@ -1435,20 +1441,23 @@ int main(int argc, char *argv[])
break;
case KeyConfig::ACTION_PLAY:
m_Pause=false;
//m_start_paused=false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove commented out code

if(m_has_subtitle)
{
m_player_subtitles.Resume();
}
break;
case KeyConfig::ACTION_PAUSE:
m_Pause=true;
//m_start_paused=false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if(m_has_subtitle)
{
m_player_subtitles.Pause();
}
break;
case KeyConfig::ACTION_PLAYPAUSE:
m_Pause = !m_Pause;
//m_start_paused = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if (m_av_clock->OMXPlaySpeed() != DVD_PLAYSPEED_NORMAL && m_av_clock->OMXPlaySpeed() != DVD_PLAYSPEED_PAUSE)
{
printf("resume\n");
Expand Down Expand Up @@ -1722,8 +1731,19 @@ int main(int argc, char *argv[])
{
if (m_av_clock->OMXIsPaused())
{
CLog::Log(LOGDEBUG, "Resume %.2f,%.2f (%d,%d,%d,%d) EOF:%d PKT:%p\n", audio_fifo, video_fifo, audio_fifo_low, video_fifo_low, audio_fifo_high, video_fifo_high, m_omx_reader.IsEof(), m_omx_pkt);
m_av_clock->OMXResume();
if (!m_start_paused)
{
CLog::Log(LOGDEBUG, "Resume %.2f,%.2f (%d,%d,%d,%d) EOF:%d PKT:%p\n", audio_fifo, video_fifo, audio_fifo_low, video_fifo_low, audio_fifo_high, video_fifo_high, m_omx_reader.IsEof(), m_omx_pkt);
m_av_clock->OMXResume();
}
else
{
CLog::Log(LOGDEBUG, "start-paused(%d)\n", m_start_paused);
m_av_clock->OMXResume();
m_Pause=true;
m_start_paused=false;
m_av_clock->OMXPause();
Comment on lines +1759 to +1762
Copy link

@DazB DazB Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my own experiments, I've found that only m_Pause=true; is needed, and the player will see that variable has changed and pause once it loops around.

A previous edit of this comment that suggested m_av_clock->OMXResume(); and m_av_clock->OMXPause(); may cause unwanted effects seems to have been related to something else, so I have edited this comment.

However I still think that this suggestion is cleaner and less likely to cause issues.

Suggested change
m_av_clock->OMXResume();
m_Pause=true;
m_start_paused=false;
m_av_clock->OMXPause();
m_Pause=true;
m_start_paused=false;

Copy link

@zasnicoff zasnicoff Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DazB Could you update your prepare-native-raspbian.sh script? Having trouble here trying to compile... It appears that some packages should be replaced: libva1 -> libva2; git-core -> git; libssl1.0-dev -> libssl-dev

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zasnicoff. That's also an issue with omxplayer, and not to do with any changes I've made. I too had those issues when first compiling. I probably should update my own fork of prepare-native-raspbian.sh to remedy this, but since it only happens when first compiling I didn't get round to it. Appreciate the heads up.

}
}
}
else if (m_Pause || audio_fifo_low || video_fifo_low)
Expand Down