Exemplo n.º 1
0
        /// <summary>
        /// Event handler for media status changes
        /// </summary>
        /// <param name="Tags">Array of tags</param>
        /// <param name="Properties">Array of property values</param>
        public void MediaStatusChange(MEDIASTATUSPROPERTYTAG[] tags, object[] properties)
        {
            //  Check to see if the socket server is valid
            if (MediaSink.SocketServer == null)
            {
                return;
            }

            try
            {
                for (int i = 0; i < tags.Length; i++)
                {
                    MEDIASTATUSPROPERTYTAG tag = tags[i];
                    object property            = properties[i];
                    //  Remove duplicate notifications
                    if ((tag == m_prevTag) && (property.ToString() == m_prevProp.ToString()))
                    {
                        return;
                    }
                    else
                    {
                        m_prevTag  = tag;
                        m_prevProp = property;
                    }

                    Trace.TraceInformation("{0}={1}", tag, property);

                    //  Announce the status change to all listeners
                    MediaSink.SocketServer.SendMessage(string.Format(CultureInfo.InvariantCulture, "{0}={1}\r\n", tag, property));

                    //  Update the media state information
                    MediaState.UpdateState(tag, property);

                    //  Check for MediaName status changes and get additional EPG data
                    //if (tag == MEDIASTATUSPROPERTYTAG.MediaName && MediaState.MediaMode == MEDIASTATUSPROPERTYTAG.TVTuner)
                    //{
                    //  Look up epg info in a background worker thread
                    //    ThreadPool.QueueUserWorkItem(new WaitCallback(LookupEpgInfo), property);
                    //}
                    //else if (tag == MEDIASTATUSPROPERTYTAG.MediaName && MediaState.MediaMode == MEDIASTATUSPROPERTYTAG.PVR)
                    //{
                    //    //  Get pvr media info in a background worker thread
                    //    ThreadPool.QueueUserWorkItem(new WaitCallback(RetrieveDvrmsInfo));
                    //}
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception: {0}", ex.ToString());
            }
        }
Exemplo n.º 2
0
        public void MediaStatusChange(MediaState.MEDIASTATUSPROPERTYTAG[] Tags, object[] Properties)
        {
            Trace.TraceInformation("Session.MediaStatusChange called");

            //Check to see if the socket server is valid
            if (Sink.SocketServer == null) {
              Trace.TraceError("SocketServer is null");
              return;
            }

            try {
                for (int i = 0; i < Tags.Length; i++) {
                    var tag = (MediaState.MEDIASTATUSPROPERTYTAG)Tags.GetValue(i);
                    var value = Properties.GetValue(i);

                    //  Remove duplicate notifications
                    if ((tag == prevCheckTag) && (value.ToString() == prevCheckProp.ToString())) {
                        return;
                    }

                    prevCheckTag = tag;
                    prevCheckProp = value;

                    Trace.TraceInformation("Tag  {0}={1}", tag, value);

                    Sink.SocketServer.SendMessage(
                        string.Format(CultureInfo.InvariantCulture, "{0}={1}\r\n", tag, value)
                        );

                    MediaState.UpdateState(tag, value);
                }
            }
            catch (Exception ex) {
                Trace.TraceError("Exception: {0}", ex.ToString());
            }
        }