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
=== modified file 'src/Widgets/PreviewPopover.vala'
--- src/Widgets/PreviewPopover.vala 2014-11-02 21:19:27 +0000
+++ src/Widgets/PreviewPopover.vala 2014-11-02 22:50:42 +0000
@@ -23,6 +23,7 @@
23 dynamic Gst.Element preview_playbin;23 dynamic Gst.Element preview_playbin;
24 Clutter.Texture video;24 Clutter.Texture video;
25 double ratio = 0;25 double ratio = 0;
26 uint? timer_id = null;
26 public PreviewPopover () {27 public PreviewPopover () {
27 opacity = GLOBAL_OPACITY;28 opacity = GLOBAL_OPACITY;
28 can_focus = false;29 can_focus = false;
@@ -57,7 +58,10 @@
57 stage.add_child (video);58 stage.add_child (video);
58 add (clutter);59 add (clutter);
59 //show_all ();60 //show_all ();
60 closed.connect (() => {preview_playbin.set_state (Gst.State.PAUSED);});61 closed.connect (() => {
62 preview_playbin.set_state (Gst.State.PAUSED);
63 cancel_loop_timer ();
64 });
61 }65 }
6266
63 public void set_preview_uri (string uri) {67 public void set_preview_uri (string uri) {
@@ -86,13 +90,21 @@
86 }90 }
8791
88 public void set_preview_progress (double progress) {92 public void set_preview_progress (double progress) {
93 cancel_loop_timer ();
89 int64 length;94 int64 length;
90 preview_playbin.query_duration (Gst.Format.TIME, out length);95 preview_playbin.query_duration (Gst.Format.TIME, out length);
91 preview_playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, (int64)(double.max (progress, 0.0) * length));96 preview_playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, (int64)(double.max (progress, 0.0) * length));
92 preview_playbin.set_state (Gst.State.PLAYING);97 preview_playbin.set_state (Gst.State.PLAYING);
93 Timeout.add_seconds (5, () => {98 timer_id = Timeout.add_seconds (5, () => {
94 set_preview_progress (progress);99 set_preview_progress (progress);
95 return false;100 return false;
96 });101 });
97 }102 }
103
104 private void cancel_loop_timer () {
105 if (timer_id != null) {
106 Source.remove (timer_id);
107 timer_id = null;
108 }
109 }
98}110}
99\ No newline at end of file111\ No newline at end of file

Subscribers

People subscribed via source and target branches