Merge lp:~vikoadi/audience/check-mimetype into lp:~audience-members/audience/trunk

Proposed by Viko Adi Rahmawan
Status: Rejected
Rejected by: Danielle Foré
Proposed branch: lp:~vikoadi/audience/check-mimetype
Merge into: lp:~audience-members/audience/trunk
Diff against target: 159 lines (+92/-14)
3 files modified
src/Audience.vala (+10/-13)
src/Utils.vala (+80/-0)
src/Widgets/Playlist.vala (+2/-1)
To merge this branch: bzr merge lp:~vikoadi/audience/check-mimetype
Reviewer Review Type Date Requested Status
kay van der Zander (community) code Needs Fixing
Review via email: mp+276575@code.launchpad.net

Description of the change

check file mimetype before added to playlist.
mimetipe list is taken from Totem code

To post a comment you must log in.
Revision history for this message
kay van der Zander (kay20) wrote :

-fix if code style one lined if with brackets. (When code has already new code style and old style, stick with the new.)

Also the 2 comment then it is all good

review: Needs Fixing (code)
Revision history for this message
Danielle Foré (danrabbit) wrote :

Rejecting since it seems to be abandoned

Unmerged revisions

553. By Viko Adi Rahmawan

rearrange if else

552. By Viko Adi Rahmawan

use video mimetype list for open file dialog

551. By Viko Adi Rahmawan

check if file is in video mimetest video before adding to playlist

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Audience.vala'
2--- src/Audience.vala 2015-10-31 19:40:48 +0000
3+++ src/Audience.vala 2015-11-03 17:36:48 +0000
4@@ -254,7 +254,9 @@
5
6 var video_filter = new Gtk.FileFilter ();
7 video_filter.set_filter_name (_("Video files"));
8- video_filter.add_mime_type ("video/*");
9+ foreach (var mime_type in video_mime_types) {
10+ video_filter.add_mime_type (mime_type);
11+ }
12
13 file.add_filter (video_filter);
14 file.add_filter (all_files_filter);
15@@ -336,19 +338,17 @@
16 var player_page = (mainwindow.get_child () as PlayerPage);
17 string[] videos = {};
18 foreach (var file in files) {
19-
20- if (file.query_file_type (0) == FileType.DIRECTORY) {
21+ if (is_video (file)) {
22+ player_page.append_to_playlist (file);
23+ videos += file.get_uri ();
24+ } else if (file.query_file_type (0) == FileType.DIRECTORY) {
25 Audience.recurse_over_dir (file, (file_ret) => {
26- player_page.append_to_playlist (file);
27- videos += file_ret.get_uri ();
28+ player_page.append_to_playlist (file_ret);
29+ videos += file_ret.get_uri ();
30 });
31 } else if (player_page.video_player.playing &&
32 PlayerPage.is_subtitle (file.get_uri ())) {
33- message ("is subtitle");
34 player_page.video_player.set_subtitle_uri (file.get_uri ());
35- } else {
36- player_page.append_to_playlist (file);
37- videos += file.get_uri ();
38 }
39 }
40
41@@ -364,11 +364,8 @@
42 show_notification (_("%i videos added to playlist").printf (videos.length), "");
43 }
44
45- play_file (videos [0]);
46-
47-
48+ player_page.play_first_in_playlist ();
49 }
50-
51 }
52 }
53
54
55=== modified file 'src/Utils.vala'
56--- src/Utils.vala 2015-06-06 14:08:15 +0000
57+++ src/Utils.vala 2015-11-03 17:36:48 +0000
58@@ -33,6 +33,86 @@
59 }
60
61 namespace Audience {
62+ // taken from totem-mime-types.h
63+ static const string video_mime_types[] = {
64+ "application/mxf",
65+ "application/ogg",
66+ "application/ram",
67+ "application/sdp",
68+ "application/vnd.apple.mpegurl",
69+ "application/vnd.ms-wpl",
70+ "application/vnd.rn-realmedia",
71+ "application/x-extension-m4a",
72+ "application/x-extension-mp4",
73+ "application/x-flash-video",
74+ "application/x-matroska",
75+ "application/x-netshow-channel",
76+ "application/x-ogg",
77+ "application/x-quicktimeplayer",
78+ "application/x-shorten",
79+ "image/vnd.rn-realpix",
80+ "image/x-pict",
81+ "misc/ultravox",
82+ "text/x-google-video-pointer",
83+ "video/3gp",
84+ "video/3gpp",
85+ "video/dv",
86+ "video/divx",
87+ "video/fli",
88+ "video/flv",
89+ "video/mp2t",
90+ "video/mp4",
91+ "video/mp4v-es",
92+ "video/mpeg",
93+ "video/msvideo",
94+ "video/ogg",
95+ "video/quicktime",
96+ "video/vivo",
97+ "video/vnd.divx",
98+ "video/vnd.mpegurl",
99+ "video/vnd.rn-realvideo",
100+ "video/vnd.vivo",
101+ "video/webm",
102+ "video/x-anim",
103+ "video/x-avi",
104+ "video/x-flc",
105+ "video/x-fli",
106+ "video/x-flic",
107+ "video/x-flv",
108+ "video/x-m4v",
109+ "video/x-matroska",
110+ "video/x-mpeg",
111+ "video/x-mpeg2",
112+ "video/x-ms-asf",
113+ "video/x-ms-asx",
114+ "video/x-msvideo",
115+ "video/x-ms-wm",
116+ "video/x-ms-wmv",
117+ "video/x-ms-wmx",
118+ "video/x-ms-wvx",
119+ "video/x-nsv",
120+ "video/x-ogm+ogg",
121+ "video/x-theora+ogg",
122+ "video/x-totem-stream",
123+ "audio/x-pn-realaudio",
124+ };
125+
126+ public static bool is_video (File filename) {
127+ try {
128+ string content_type = filename.query_info (
129+ FileAttribute.STANDARD_CONTENT_TYPE,
130+ FileQueryInfoFlags.NONE,
131+ null).get_content_type ();
132+ foreach (var video_mime_type in video_mime_types)
133+ if (video_mime_type == content_type)
134+ return true;
135+ return false;
136+ } catch (Error e) {
137+ debug ("cant get ContentType " + e.message);
138+ return false;
139+ }
140+ }
141+
142 public delegate void FuncOverDir (File file_under_dir);
143 public static void recurse_over_dir (File file_to_process, FuncOverDir func) {
144 if (file_to_process.query_file_type (0) == FileType.DIRECTORY) {
145
146=== modified file 'src/Widgets/Playlist.vala'
147--- src/Widgets/Playlist.vala 2015-06-08 05:53:03 +0000
148+++ src/Widgets/Playlist.vala 2015-11-03 17:36:48 +0000
149@@ -99,8 +99,9 @@
150 }
151
152 public void add_item (File path) {
153- if (!path.query_exists ())
154+ if (!path.query_exists () || !is_video (path))
155 return;
156+
157 var file_name = path.get_uri ();
158 bool exist = false;
159 Gtk.TreeIter iter;

Subscribers

People subscribed via source and target branches