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

PlaybackManager: Improve position querying #348

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Services/PlaybackManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,11 @@ public class Audience.PlaybackManager : Object {
notify["playing"].connect (() => {
var play_pause_action = default_application.lookup_action (Audience.App.ACTION_PLAY_PAUSE);
((SimpleAction) play_pause_action).set_state (playing);
update_position ();
});

Timeout.add (500, () => {
int64 _position;
if (playbin.query_position (Gst.Format.TIME, out _position)) {
position = _position;
} else {
position = 0;
}

update_position ();
return Source.CONTINUE;
});
}
Expand Down Expand Up @@ -160,6 +155,9 @@ public class Audience.PlaybackManager : Object {
case ASYNC_DONE:
if (is_seeking) {
is_seeking = false;

update_position ();

if (queued_seek >= 0) {
seek (queued_seek);
}
Expand Down Expand Up @@ -266,6 +264,15 @@ public class Audience.PlaybackManager : Object {
queued_seek = -1;
}

private void update_position () {
int64 _position;
if (playbin.query_position (Gst.Format.TIME, out _position)) {
position = _position;
} else {
position = 0;
}
}

private bool is_subtitle (string uri) {
if (uri.length < 4 || uri.get_char (uri.length - 4) != '.') {
return false;
Expand Down