public static void Run(string[] args) { // Initialize GStreamer Gst.Application.Init(ref args); // Create the elements _data.Playbin = ElementFactory.Make("playbin", "playbin"); if (_data.Playbin == null) { "Not all elements could be created".PrintErr(); return; } // Set the uri to play _data.Playbin["uri"] = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.ogv"; // Set the subtitle URI to play and some font description // if setting this, AnalyzeStreams doesn't show subtitle streams when called from state change message. // but Greek subtitles work _data.Playbin["suburi"] = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer_gr.srt"; _data.Playbin["subtitle-font-desc"] = "Sans, 18"; // Set flags to show Audio and Video and Subtitles GstPlayFlags flags = (GstPlayFlags)_data.Playbin["flags"]; flags |= GstPlayFlags.Audio | GstPlayFlags.Video | GstPlayFlags.Text; _data.Playbin["flags"] = (uint)flags; // Add a bus watch, so we get notified when a message arrives var bus = _data.Playbin.Bus; bus.AddSignalWatch(); bus.Message += HandleMessage; // Add a keyboard watch so we get notified of keystrokes GLib.Idle.Add(HandleKeyboard); // Start playing var ret = _data.Playbin.SetState(State.Playing); if (ret == StateChangeReturn.Failure) { "Unable to set the pipeline to the playing state".PrintErr(); _data.Playbin.Dispose(); return; } // Create a GLib Main Loop and set it to run _data.MainLoop = new GLib.MainLoop(); _data.MainLoop.Run(); // Free resources bus.Dispose(); _data.Playbin.SetState(State.Null); _data.Playbin.Dispose(); }
public static void Run(string[] args) { // Initialize GStreamer Gst.Application.Init(ref args); _bufferingLevel = 100; // Build the pipeline using (_pipeline = Parse.Launch("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm")) { var bus = _pipeline.Bus; // Set the download flag GstPlayFlags flags = (GstPlayFlags)_pipeline["flags"]; flags |= GstPlayFlags.Download; _pipeline["flags"] = (uint)flags; /* This doesn't work? flags = 0 ? * GstPlayFlags flags = (GstPlayFlags)_pipeline.Flags; * flags |= GstPlayFlags.Download; * _pipeline.Flags = (uint)flags; */ // Uncomment this line to limit the amount of downloaded data _pipeline["ring-buffer-max-size"] = 4000000L; // Start playing var ret = _pipeline.SetState(State.Playing); if (ret == StateChangeReturn.Failure) { "Unable to set the pipeline to the playing state.".PrintErr(); _pipeline.Dispose(); return; } else if (ret == StateChangeReturn.NoPreroll) { _isLive = true; } _loop = new GLib.MainLoop(); bus.AddSignalWatch(); bus.Message += CbMessage; _pipeline.Connect("deep-notify::temp-location", GotLocation); // Register a function that GLib will call every second GLib.Timeout.AddSeconds(1, RefreshUI); _loop.Run(); _pipeline.SetState(State.Null); bus.Dispose(); } }
public static void Run(string[] args) { // Initialize GStreamer Gst.Application.Init(ref args); // Create the elements _data.Playbin = ElementFactory.Make("playbin", "playbin"); if (_data.Playbin == null) { "Not all elements could be created".PrintErr(); return; } // Set the uri to play _data.Playbin["uri"] = "http://freedesktop.org/software/gstreamer-sdk/data/media/sintel_cropped_multilingual.webm"; //Data.Playbin["uri"] = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4"; //Data.Playbin["uri"] = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; // Set flags to show Audio and Video but ignore Subtitles GstPlayFlags flags = (GstPlayFlags)_data.Playbin["flags"]; flags |= (GstPlayFlags.Video | GstPlayFlags.Audio); flags &= (~GstPlayFlags.Text); _data.Playbin["flags"] = (uint)flags; // Set connection speed. This will affect some internal decisions of playbin2 _data.Playbin["connection-speed"] = 56; var bus = _data.Playbin.Bus; bus.AddSignalWatch(); bus.Message += HandleMessage; // Add a keyboard watch so we get notified of keystrokes GLib.Idle.Add(HandleKeyboard); // Start playing var ret = _data.Playbin.SetState(State.Playing); if (ret == StateChangeReturn.Failure) { "Unable to set the pipeline to the playing state".PrintErr(); _data.Playbin.Dispose(); return; } _data.MainLoop = new GLib.MainLoop(); _data.MainLoop.Run(); _data.Playbin.SetState(State.Null); }