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
=== modified file 'src/Audience.vala'
--- src/Audience.vala 2015-10-31 19:40:48 +0000
+++ src/Audience.vala 2015-11-03 17:36:48 +0000
@@ -254,7 +254,9 @@
254254
255 var video_filter = new Gtk.FileFilter ();255 var video_filter = new Gtk.FileFilter ();
256 video_filter.set_filter_name (_("Video files"));256 video_filter.set_filter_name (_("Video files"));
257 video_filter.add_mime_type ("video/*");257 foreach (var mime_type in video_mime_types) {
258 video_filter.add_mime_type (mime_type);
259 }
258260
259 file.add_filter (video_filter);261 file.add_filter (video_filter);
260 file.add_filter (all_files_filter);262 file.add_filter (all_files_filter);
@@ -336,19 +338,17 @@
336 var player_page = (mainwindow.get_child () as PlayerPage);338 var player_page = (mainwindow.get_child () as PlayerPage);
337 string[] videos = {};339 string[] videos = {};
338 foreach (var file in files) {340 foreach (var file in files) {
339341 if (is_video (file)) {
340 if (file.query_file_type (0) == FileType.DIRECTORY) {342 player_page.append_to_playlist (file);
343 videos += file.get_uri ();
344 } else if (file.query_file_type (0) == FileType.DIRECTORY) {
341 Audience.recurse_over_dir (file, (file_ret) => {345 Audience.recurse_over_dir (file, (file_ret) => {
342 player_page.append_to_playlist (file);346 player_page.append_to_playlist (file_ret);
343 videos += file_ret.get_uri ();347 videos += file_ret.get_uri ();
344 });348 });
345 } else if (player_page.video_player.playing &&349 } else if (player_page.video_player.playing &&
346 PlayerPage.is_subtitle (file.get_uri ())) {350 PlayerPage.is_subtitle (file.get_uri ())) {
347 message ("is subtitle");
348 player_page.video_player.set_subtitle_uri (file.get_uri ());351 player_page.video_player.set_subtitle_uri (file.get_uri ());
349 } else {
350 player_page.append_to_playlist (file);
351 videos += file.get_uri ();
352 }352 }
353 }353 }
354354
@@ -364,11 +364,8 @@
364 show_notification (_("%i videos added to playlist").printf (videos.length), "");364 show_notification (_("%i videos added to playlist").printf (videos.length), "");
365 }365 }
366366
367 play_file (videos [0]);367 player_page.play_first_in_playlist ();
368
369
370 }368 }
371
372 }369 }
373}370}
374371
375372
=== modified file 'src/Utils.vala'
--- src/Utils.vala 2015-06-06 14:08:15 +0000
+++ src/Utils.vala 2015-11-03 17:36:48 +0000
@@ -33,6 +33,86 @@
33}33}
3434
35namespace Audience {35namespace Audience {
36 // taken from totem-mime-types.h
37 static const string video_mime_types[] = {
38 "application/mxf",
39 "application/ogg",
40 "application/ram",
41 "application/sdp",
42 "application/vnd.apple.mpegurl",
43 "application/vnd.ms-wpl",
44 "application/vnd.rn-realmedia",
45 "application/x-extension-m4a",
46 "application/x-extension-mp4",
47 "application/x-flash-video",
48 "application/x-matroska",
49 "application/x-netshow-channel",
50 "application/x-ogg",
51 "application/x-quicktimeplayer",
52 "application/x-shorten",
53 "image/vnd.rn-realpix",
54 "image/x-pict",
55 "misc/ultravox",
56 "text/x-google-video-pointer",
57 "video/3gp",
58 "video/3gpp",
59 "video/dv",
60 "video/divx",
61 "video/fli",
62 "video/flv",
63 "video/mp2t",
64 "video/mp4",
65 "video/mp4v-es",
66 "video/mpeg",
67 "video/msvideo",
68 "video/ogg",
69 "video/quicktime",
70 "video/vivo",
71 "video/vnd.divx",
72 "video/vnd.mpegurl",
73 "video/vnd.rn-realvideo",
74 "video/vnd.vivo",
75 "video/webm",
76 "video/x-anim",
77 "video/x-avi",
78 "video/x-flc",
79 "video/x-fli",
80 "video/x-flic",
81 "video/x-flv",
82 "video/x-m4v",
83 "video/x-matroska",
84 "video/x-mpeg",
85 "video/x-mpeg2",
86 "video/x-ms-asf",
87 "video/x-ms-asx",
88 "video/x-msvideo",
89 "video/x-ms-wm",
90 "video/x-ms-wmv",
91 "video/x-ms-wmx",
92 "video/x-ms-wvx",
93 "video/x-nsv",
94 "video/x-ogm+ogg",
95 "video/x-theora+ogg",
96 "video/x-totem-stream",
97 "audio/x-pn-realaudio",
98 };
99
100 public static bool is_video (File filename) {
101 try {
102 string content_type = filename.query_info (
103 FileAttribute.STANDARD_CONTENT_TYPE,
104 FileQueryInfoFlags.NONE,
105 null).get_content_type ();
106 foreach (var video_mime_type in video_mime_types)
107 if (video_mime_type == content_type)
108 return true;
109 return false;
110 } catch (Error e) {
111 debug ("cant get ContentType " + e.message);
112 return false;
113 }
114 }
115
36 public delegate void FuncOverDir (File file_under_dir);116 public delegate void FuncOverDir (File file_under_dir);
37 public static void recurse_over_dir (File file_to_process, FuncOverDir func) {117 public static void recurse_over_dir (File file_to_process, FuncOverDir func) {
38 if (file_to_process.query_file_type (0) == FileType.DIRECTORY) {118 if (file_to_process.query_file_type (0) == FileType.DIRECTORY) {
39119
=== modified file 'src/Widgets/Playlist.vala'
--- src/Widgets/Playlist.vala 2015-06-08 05:53:03 +0000
+++ src/Widgets/Playlist.vala 2015-11-03 17:36:48 +0000
@@ -99,8 +99,9 @@
99 }99 }
100100
101 public void add_item (File path) {101 public void add_item (File path) {
102 if (!path.query_exists ())102 if (!path.query_exists () || !is_video (path))
103 return;103 return;
104
104 var file_name = path.get_uri ();105 var file_name = path.get_uri ();
105 bool exist = false;106 bool exist = false;
106 Gtk.TreeIter iter;107 Gtk.TreeIter iter;

Subscribers

People subscribed via source and target branches