mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
app: allow giving an uri instead of a directory as a startup arg
This way we can play streams.
This commit is contained in:
parent
a432c367e7
commit
540923db9c
2 changed files with 27 additions and 13 deletions
|
@ -25,12 +25,19 @@ public class MediaInfo.App : Window
|
|||
private FileChooserWidget chooser;
|
||||
private Info info;
|
||||
|
||||
public string directory { get; set; }
|
||||
|
||||
public App (string? directory)
|
||||
public App (string? directory_or_uri)
|
||||
{
|
||||
GLib.Object (type : WindowType.TOPLEVEL);
|
||||
this.directory = directory;
|
||||
|
||||
string directory = null;
|
||||
string uri = null;
|
||||
if (directory_or_uri != null) {
|
||||
if (FileUtils.test (directory_or_uri, FileTest.IS_DIR)) {
|
||||
directory = directory_or_uri;
|
||||
} else if (Uri.parse_scheme (directory_or_uri) != null) {
|
||||
uri = directory_or_uri;
|
||||
}
|
||||
}
|
||||
|
||||
// configure the window
|
||||
set_title (_("GStreamer Media Info"));
|
||||
|
@ -61,7 +68,16 @@ public class MediaInfo.App : Window
|
|||
chooser.set_current_folder (directory);
|
||||
}
|
||||
chooser.set_show_hidden (false);
|
||||
chooser.selection_changed.connect (on_update_preview);
|
||||
|
||||
if (uri != null) {
|
||||
chooser.set_sensitive (false);
|
||||
Idle.add ( () => {
|
||||
info.discover (uri);
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
chooser.selection_changed.connect (on_update_preview);
|
||||
}
|
||||
|
||||
info = new Info ();
|
||||
paned.pack2 (info, true, true);
|
||||
|
|
|
@ -26,15 +26,13 @@ const OptionEntry[] options = {
|
|||
{ null }
|
||||
};
|
||||
|
||||
int
|
||||
main(string[] args)
|
||||
{
|
||||
|
||||
int main(string[] args)
|
||||
{
|
||||
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
|
||||
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
|
||||
Intl.textdomain (Config.GETTEXT_PACKAGE);
|
||||
|
||||
OptionContext opt_context = new OptionContext (_("<directory>"));
|
||||
OptionContext opt_context = new OptionContext (_("<directory|uri>"));
|
||||
opt_context.set_help_enabled (true);
|
||||
opt_context.add_main_entries (options, null);
|
||||
opt_context.add_group (Gst.init_get_option_group ());
|
||||
|
@ -52,12 +50,12 @@ main(string[] args)
|
|||
}
|
||||
|
||||
// take remaining arg and use as default dir
|
||||
string directory = null;
|
||||
string directory_or_uri = null;
|
||||
if (args.length > 1) {
|
||||
directory=args[1];
|
||||
directory_or_uri = args[1];
|
||||
}
|
||||
|
||||
App app = new App (directory);
|
||||
App app = new App (directory_or_uri);
|
||||
app.show_all ();
|
||||
|
||||
Gtk.main ();
|
||||
|
|
Loading…
Reference in a new issue