Пример #1
0
 static void Handle(object e, MessageArgs args)
 {
     switch (args.Message.Type) {
     case MessageType.StateChanged:
         State oldstate, newstate, pendingstate;
         args.Message.ParseStateChanged (out oldstate, out newstate, out pendingstate);
         System.Console.WriteLine ("[StateChange] From " + oldstate + " to " + newstate + " pending at " + pendingstate);
         break;
     case MessageType.StreamStatus:
         Element owner;
         StreamStatusType type;
         args.Message.ParseStreamStatus (out type, out owner);
         System.Console.WriteLine ("[StreamStatus] Type" + type + " from " + owner);
         break;
     case MessageType.DurationChanged:
         long duration;
         element.QueryDuration (Format.Time, out duration);
         System.Console.WriteLine ("[DurationChanged] New duration is " + (duration / Constants.SECOND) + " seconds");
         break;
     case MessageType.ResetTime:
         ulong runningtime = args.Message.ParseResetTime ();
         System.Console.WriteLine ("[ResetTime] Running time is " + runningtime);
         break;
     case MessageType.AsyncDone:
         ulong desiredrunningtime = args.Message.ParseAsyncDone ();
         System.Console.WriteLine ("[AsyncDone] Running time is " + desiredrunningtime);
         break;
     case MessageType.NewClock:
         Clock clock = args.Message.ParseNewClock ();
         System.Console.WriteLine ("[NewClock] " + clock);
         break;
     case MessageType.Buffering:
         int percent = args.Message.ParseBuffering ();
         System.Console.WriteLine ("[Buffering] " + percent + " % done");
         break;
     case MessageType.Tag:
         TagList list = args.Message.ParseTag ();
         System.Console.WriteLine ("[Tag] Information in scope " + list.Scope + " is " + list.ToString());
         break;
     case MessageType.Error:
         GLib.GException gerror;
         string debug;
         args.Message.ParseError (out gerror, out debug);
         System.Console.WriteLine ("[Error] " + gerror.Message + " debug information " + debug + ". Exiting! ");
         Loop.Quit ();
         break;
     case MessageType.Eos:
         System.Console.WriteLine ("[Eos] Playback has ended. Exiting!");
         Loop.Quit ();
         break;
     default:
         System.Console.WriteLine ("[Recv] " + args.Message.Type);
         break;
     }
 }
Пример #2
0
        static void HandleMessage(object o, MessageArgs args)
        {
            var msg = args.Message;
            switch (msg.Type) {
            case MessageType.Error: {
                    GLib.GException err;
                    string debug;

                    msg.ParseError (out err, out debug);
                    Console.WriteLine ("Error: {0}", err.Message);

                    Pipeline.SetState (State.Ready);
                    MainLoop.Quit ();
                    break;
                }
            case MessageType.Eos:
                // end-of-stream
                Pipeline.SetState (State.Ready);
                MainLoop.Quit ();
                break;
            case MessageType.Buffering: {
                    int percent = 0;

                    // If the stream is live, we do not care about buffering.
                    if (IsLive) break;

                    percent = msg.ParseBuffering ();
                    Console.WriteLine ("Buffering ({0})", percent);
                    // Wait until buffering is complete before start/resume playing
                    if (percent < 100)
                        Pipeline.SetState (State.Paused);
                    else
                        Pipeline.SetState (State.Playing);
                    break;
                }
            case MessageType.ClockLost:
                // Get a new clock
                Pipeline.SetState (State.Paused);
                Pipeline.SetState (State.Playing);
                break;
            default:
                // Unhandled message
                break;
            }
        }
Пример #3
0
 static void MessageHandler (object sender, MessageArgs args) {
   Message message = args.Message;
   string text = String.Format ("Message from {0}:  \t{1}", message.Src.Name, message.Type);
   switch (message.Type) {
     case MessageType.Error:
       Enum err;
       string msg;
       message.ParseError (out err, out msg);
       text += String.Format ("\t({0})", msg);
       break;
     case MessageType.StateChanged:
       State oldstate, newstate, pending;
       message.ParseStateChanged (out oldstate, out newstate, out pending);
       text += String.Format ("\t\t{0} -> {1}   ({2})", oldstate, newstate, pending);
       break;
     case MessageType.Eos:
       loop.Quit();
       break;
   }
   Console.WriteLine (text);
 }
        private void MsgHandler(object o, MessageArgs args)
        {
            switch (args.Message.Type) {
                case MessageType.DurationChanged:
                if (pipeline.QueryDuration (Format.Time, out duration)) {
                    duration /= Gst.Constants.SECOND;
                    ReadID ();
                }
                break;
                case MessageType.Eos:
                // todo: finish
                break;
                case MessageType.Tag:
                TagList tags = args.Message.ParseTag();
                tags.GetString("chromaprint-fingerprint", out fingerprint);

                if (fingerprint != null) {
                    ReadID ();
                }
                break;
            }
        }
        static void HandleMessage(object o, MessageArgs args)
        {
            var msg = args.Message;
            switch (msg.Type) {
            case MessageType.Error:
                GLib.GException err;
                string debug;
                msg.ParseError (out err, out debug);
                Console.WriteLine ("Error received from element {0}: {1}", msg.Src, err.Message);
                Console.WriteLine ("Debugging information: {0}", debug != null ? debug : "none");
                MainLoop.Quit ();
                break;
            case MessageType.Eos:
                Console.WriteLine ("End-Of-Stream reached.");
                MainLoop.Quit ();
                break;
            case MessageType.StateChanged: {
                    State oldState, newState, pendingState;
                    msg.ParseStateChanged (out oldState, out newState, out pendingState);
                    if (msg.Src == Playbin) {
                        if (newState == State.Playing) {
                            // Once we are in the playing state, analyze the streams
                            AnalyzeStreams ();
                        }
                    }
                } break;
            default:
                break;
            }

            // We want to keep receiving messages
            args.RetVal = true;
        }