Merge lp:~artem-anufrij/audience/Looping-functionality into lp:~audience-members/audience/trunk

Proposed by Artem Anufrij
Status: Merged
Approved by: Cody Garver
Approved revision: 451
Merged at revision: 450
Proposed branch: lp:~artem-anufrij/audience/Looping-functionality
Merge into: lp:~audience-members/audience/trunk
Diff against target: 47 lines (+14/-2)
1 file modified
src/Widgets/PreviewPopover.vala (+14/-2)
To merge this branch: bzr merge lp:~artem-anufrij/audience/Looping-functionality
Reviewer Review Type Date Requested Status
Audience Members Pending
Review via email: mp+240385@code.launchpad.net

Commit message

Improve preview looping

Description of the change

Preview looping functionality was improved.

To post a comment you must log in.
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Timer reset functionality was added

451. By artem-anufrij

Looping functionality was improved.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/PreviewPopover.vala'
2--- src/Widgets/PreviewPopover.vala 2014-11-02 21:19:27 +0000
3+++ src/Widgets/PreviewPopover.vala 2014-11-02 22:50:42 +0000
4@@ -23,6 +23,7 @@
5 dynamic Gst.Element preview_playbin;
6 Clutter.Texture video;
7 double ratio = 0;
8+ uint? timer_id = null;
9 public PreviewPopover () {
10 opacity = GLOBAL_OPACITY;
11 can_focus = false;
12@@ -57,7 +58,10 @@
13 stage.add_child (video);
14 add (clutter);
15 //show_all ();
16- closed.connect (() => {preview_playbin.set_state (Gst.State.PAUSED);});
17+ closed.connect (() => {
18+ preview_playbin.set_state (Gst.State.PAUSED);
19+ cancel_loop_timer ();
20+ });
21 }
22
23 public void set_preview_uri (string uri) {
24@@ -86,13 +90,21 @@
25 }
26
27 public void set_preview_progress (double progress) {
28+ cancel_loop_timer ();
29 int64 length;
30 preview_playbin.query_duration (Gst.Format.TIME, out length);
31 preview_playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, (int64)(double.max (progress, 0.0) * length));
32 preview_playbin.set_state (Gst.State.PLAYING);
33- Timeout.add_seconds (5, () => {
34+ timer_id = Timeout.add_seconds (5, () => {
35 set_preview_progress (progress);
36 return false;
37 });
38 }
39+
40+ private void cancel_loop_timer () {
41+ if (timer_id != null) {
42+ Source.remove (timer_id);
43+ timer_id = null;
44+ }
45+ }
46 }
47\ No newline at end of file

Subscribers

People subscribed via source and target branches