Merge lp:~vikoadi/audience/fix-playlist into lp:~audience-members/audience/trunk

Proposed by Viko Adi Rahmawan
Status: Merged
Approved by: Raphael Isemann
Approved revision: 357
Merged at revision: 355
Proposed branch: lp:~vikoadi/audience/fix-playlist
Merge into: lp:~audience-members/audience/trunk
Diff against target: 132 lines (+46/-15)
4 files modified
data/org.pantheon.audience.gschema.xml (+5/-0)
src/Audience.vala (+14/-14)
src/Settings.vala (+1/-0)
src/Widgets/Playlist.vala (+26/-1)
To merge this branch: bzr merge lp:~vikoadi/audience/fix-playlist
Reviewer Review Type Date Requested Status
Cody Garver Needs Fixing
Raphael Isemann (community) code and code-style Approve
Audience Members code Pending
Review via email: mp+229352@code.launchpad.net

Commit message

Fix restoring the playlist from dconf. Now it will only add to the playlist when you have multiple arguments in the starting call and every future call with only one argument will create a new playlist.

Description of the change

-dont restore from dconf if open file from pantheon-files
-safe current video so can restore playlist and play previous video.

To post a comment you must log in.
Revision history for this message
Raphael Isemann (teemperor) wrote :

Works as intended in all aspects.

Give me some time to check the code itself.

review: Approve (functionality)
Revision history for this message
Raphael Isemann (teemperor) wrote :

There is a small codestyle error here:
> playlist.add_item (File.new_for_path(filename));
should be
> playlist.add_item (File.new_for_path (filename));

with a space before the bracket. Could you add that?

Otherwise good job.

review: Needs Fixing (code and code-style)
lp:~vikoadi/audience/fix-playlist updated
357. By Viko Adi Rahmawan

fix codestyle

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

Done

Revision history for this message
Raphael Isemann (teemperor) wrote :

Ok, i'll approve. If someone finds an obvious error in his code, blame me for now knowing the audience codebase well enough, but it looks fine for me ;)

review: Approve (code and code-style)
Revision history for this message
Raphael Isemann (teemperor) wrote :

I hope tarmac-bot can merge this evne though there is still a pending review i can't cancel for some reason.

Revision history for this message
Raphael Isemann (teemperor) wrote :

Oh, forgot: Thanks and good work!

Revision history for this message
Cody Garver (codygarver) wrote :

* It automatically starts playing the last played video, it's supposed to offer to resume in the welcome screen
* Does not restore playback position in resumed videos

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/org.pantheon.audience.gschema.xml'
2--- data/org.pantheon.audience.gschema.xml 2014-05-02 22:16:10 +0000
3+++ data/org.pantheon.audience.gschema.xml 2014-08-05 13:38:15 +0000
4@@ -20,6 +20,11 @@
5 <summary>List of last played videos</summary>
6 <description>A list of the last played</description>
7 </key>
8+ <key name="current-video" type="s">
9+ <default>""</default>
10+ <summary>last played video</summary>
11+ <description></description>
12+ </key>
13 <key name="last-stopped" type="d">
14 <default>0</default>
15 <summary>Last stopped time of last played video</summary>
16
17=== modified file 'src/Audience.vala'
18--- src/Audience.vala 2014-07-24 10:21:16 +0000
19+++ src/Audience.vala 2014-08-05 13:38:15 +0000
20@@ -303,18 +303,6 @@
21 });
22
23 stage.notify["allocation"].connect (() => {allocate_bottombar ();});
24-
25- if (settings.resume_videos == true && settings.last_played_videos.length > 0) {
26- welcome.hide ();
27- clutter.show_all ();
28- foreach (var filename in settings.last_played_videos) {
29- open_file (filename);
30- }
31-
32- video_player.playing = false;
33- video_player.progress = settings.last_stopped;
34- video_player.playing = true;
35- }
36 }
37
38 private void allocate_bottombar () {
39@@ -690,13 +678,25 @@
40 //the application started
41 public override void activate () {
42 build ();
43+ if (settings.resume_videos == true && settings.last_played_videos.length > 0) {
44+ welcome.hide ();
45+ clutter.show_all ();
46+ foreach (var filename in settings.last_played_videos) {
47+ playlist.add_item (File.new_for_path (filename));
48+ }
49+ open_file (settings.current_video);
50+
51+ video_player.playing = false;
52+ video_player.progress = settings.last_stopped;
53+ video_player.playing = true;
54+ }
55 }
56
57 //the application was requested to open some files
58 public override void open (File[] files, string hint) {
59 if (mainwindow == null)
60- activate ();
61-
62+ build ();
63+
64 welcome.hide ();
65 clutter.show_all ();
66 foreach (var file in files) {
67
68=== modified file 'src/Settings.vala'
69--- src/Settings.vala 2014-06-30 14:54:30 +0000
70+++ src/Settings.vala 2014-08-05 13:38:15 +0000
71@@ -23,6 +23,7 @@
72 public bool keep_aspect {get; set;}
73 public bool resume_videos {get; set;}
74 public string[] last_played_videos {get; set;}
75+ public string current_video {get; set;}
76 public double last_stopped {get; set;}
77 public string last_folder {get; set;}
78 public bool playback_wait {get; set;}
79
80=== modified file 'src/Widgets/Playlist.vala'
81--- src/Widgets/Playlist.vala 2014-07-06 11:16:48 +0000
82+++ src/Widgets/Playlist.vala 2014-08-05 13:38:15 +0000
83@@ -99,8 +99,23 @@
84 }
85
86 public void add_item (File path) {
87+ if (!path.query_exists ())
88+ return;
89+ var file_name = path.get_path ();
90+ bool exist = false;
91 Gtk.TreeIter iter;
92
93+ playlist.foreach ((model, path, iter) => {
94+ Value filename;
95+ playlist.get_value (iter, Columns.FILENAME, out filename);
96+ string name = filename.get_string ();
97+ if (name == file_name)
98+ exist = true;
99+ return false;
100+ });
101+ if (exist)
102+ return;
103+
104 Icon? playing = null;
105 Gtk.TreeIter dummy;
106 if (!playlist.get_iter_first (out dummy)){
107@@ -116,7 +131,16 @@
108 }
109
110 public void remove_item (File path) {
111- /*not needed up to now*/
112+ var file_name = path.get_path ();
113+
114+ playlist.foreach ((model, path, iter) => {
115+ Value filename;
116+ playlist.get_value (iter, Columns.FILENAME, out filename);
117+ string name = filename.get_string ();
118+ if (name == file_name)
119+ playlist.remove (iter);
120+ return false;
121+ });
122 }
123
124 public File? get_first_item () {
125@@ -159,6 +183,7 @@
126 }
127
128 settings.last_played_videos = videos;
129+ settings.current_video = videos[current];
130 }
131
132 }

Subscribers

People subscribed via source and target branches