Ejemplo n.º 1
0
 /// <summary>
 /// Requeue message (eg when a command is allready being processed
 /// we cannot do other things until command is completly processed)
 /// </summary>
 private void RequeueMessage(MP_Message message)
 {
     lock (lockVAR)
     {
         if (messageQueue != null && message != null)
         {
             messageQueue.Insert(0, message);
         }
     } //lock
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove and MediaItem from the playlist
        /// </summary>
        public bool RemoveMediaItem(int index)
        {
            MediaItem removeItem = null;
            MediaItem currentItem = null;
            MediaItem preBufferedItem = null;
            lock (lockVAR)
            {
                removeItem = currentPlaylist[index];
                if (netStreams.Count > 0)
                {
                    currentItem = netStreams[0].Item;
                }
                if (netStreams.Count > 1)
                {
                    preBufferedItem = netStreams[1].Item;
                }
            } //lock

            if (currentItem != null && removeItem != null && currentItem.GUID.Equals(removeItem.GUID))
            {
                // stop playing!!
                Stop();
                Thread.Sleep(100);
            }

            bool result = currentPlaylist.RemoveMediaItem(index);

            if (preBufferedItem != null && preBufferedItem.GUID.Equals(removeItem.GUID))
            {
                MP_Message message = new MP_Message();
                message.MethodCall = MP_MethodCall.KillPreBufferedMediaItem;
                AddMessageToPump(message);
            }

            return result;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add new message to queue. Thread safe
 /// </summary>
 private void AddMessageToPump(MP_Message message)
 {
     lock (lockVAR)
     {
         if (messageQueue != null)
         {
             messageQueue.Add(message);
         }
     } //lock
 }
Ejemplo n.º 4
0
        /// Goto the previous track in the playlist
        public bool Previous()
        {
            // Allowed?
            if (previousButton == MPButtonState.Inactive)
            {
                return false;
            }

            DoEvent_MP_OnControleButtonStateChange_DisableTemporary(OnControleButtonStateChange, this);

            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Previous;
            AddMessageToPump(message);

            return true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Insert a MediaItem at the specified location.
        /// </summary>
        public bool InsertMediaItem(int atPosition, MediaItem item)
        {
            MediaItem preBufferedItem = null;
            lock (lockVAR)
            {
                if (netStreams.Count > 1)
                {
                    preBufferedItem = netStreams[1].Item;
                }
            } //lock

            bool result = currentPlaylist.InsertMediaItem(atPosition, item);

            MediaItem nextBufferedItem = currentPlaylist.NextMediaItem;

            if (preBufferedItem != null && nextBufferedItem != null && item.GUID.Equals(nextBufferedItem.GUID))
            {
                MP_Message message = new MP_Message();
                message.MethodCall = MP_MethodCall.KillPreBufferedMediaItem;
                AddMessageToPump(message);
            }

            return result;
        }
Ejemplo n.º 6
0
        public bool Seek(long seekTimeInMS)
        {
            // Allowed?
            if (!IsPlaying)
            {
                return false;
            }

            DoEvent_MP_OnControleButtonStateChange_DisableTemporary(OnControleButtonStateChange, this);

            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Seek;
            message.Params = new object[] { seekTimeInMS };
            AddMessageToPump(message);

            return true;
        }
Ejemplo n.º 7
0
        public bool Stop()
        {
            DoEvent_MP_OnControleButtonStateChange_DisableTemporary(OnControleButtonStateChange, this);

            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Stop;

            AddMessageToPump(message);

            return true;
        }
Ejemplo n.º 8
0
        public bool Pause()
        {
            if (netConnection == null || !netConnection.IsConnected)
            {
                return false;
            }

            DoEvent_MP_OnControleButtonStateChange_DisableTemporary(OnControleButtonStateChange, this);

            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Pause;

            AddMessageToPump(message);

            return true;
        }
Ejemplo n.º 9
0
        public bool Play(long startPositionInMS = -1)
        {
            if (netConnection == null || !netConnection.IsConnected)
            {
                return false;
            }

            DoEvent_MP_OnControleButtonStateChange_DisableTemporary(OnControleButtonStateChange, this);

            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Play;
            message.Params = new object[] { startPositionInMS };

            AddMessageToPump(message);

            return true;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Stops playing audio, disconnects any netStream connections and as
        /// last disconnects the NetConnection
        /// </summary>
        public void Disconnect()
        {
            MP_Message message = new MP_Message();
            message.MethodCall = MP_MethodCall.Disconnect;

            AddMessageToPump(message);
        }