//Synchronize changes made directly to the chromecast (i.e by some other remote) to the musicbee player
        private void Synchronize_Reciever(object sender, EventArgs e)
        {
            if (mediaChannel == null)
            {
                return;
            }
            var obj = mediaChannel.Status;

            if (obj == null)
            {
                return;
            }

            var chromecastTime = obj.First().CurrentTime;
            var playerState    = obj.First().PlayerState;

            //Reflect changes made in the songs timeline to the musicbee player
            mbApiInterface.Player_SetPosition((int)(chromecastTime * 1000));

            var musicbeePlayerState = mbApiInterface.Player_GetPlayState();

            //Reflect the changes in the play state on the chromecast to the musicbee player
            if (playerState == "PAUSED" && musicbeePlayerState == PlayState.Playing)
            {
                mbApiInterface.Player_PlayPause();
            }
            if (playerState == "PLAYING" && musicbeePlayerState == PlayState.Paused)
            {
                mbApiInterface.Player_PlayPause();
            }
        }
        private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (_track.ChapterList.Count == 0)
            {
                return;
            }
            int     playerPosition = mbApiInterface.Player_GetPosition();
            Chapter currentChapter = _track.ChapterList.GetCurrentChapterFromPosition(playerPosition);

            if (!currentChapter.Equals(_currentChapter))
            {
                _mainForm?.Invoke(_mainForm.SetCurrentChapterDelegate, currentChapter);
                _currentChapter = currentChapter;
            }
            // Repeat section
            if (RepeatSection.RepeatCheck(playerPosition))
            {
                mbApiInterface.Player_SetPosition(RepeatSection.A.Position);
            }
        }
 public void LoadSavedPosition()
 {
     try
     {
         var text = File.ReadAllText(GetPositionFilename());
         _mbApiInterface.Player_SetPosition(int.Parse(text));
     }
     catch (Exception)
     {
         // ignored
     }
 }
        // Panel Click Event (seekbar)
        private void PanelClick(object sender, EventArgs e)
        {

            MouseEventArgs me = (MouseEventArgs)e;
            if (me.Button == System.Windows.Forms.MouseButtons.Left)
            {

                mbApiInterface.Player_SetPosition((int)Math.Round(findPos()));

            }
            else if (me.Button == System.Windows.Forms.MouseButtons.Right)
            {

                mbApiInterface.Player_PlayPause();

            }
        }
 private void systemMediaControls_PlaybackPositionChangeRequested(SystemMediaTransportControls smtc, PlaybackPositionChangeRequestedEventArgs args)
 {
     mbApiInterface.Player_SetPosition(args.RequestedPlaybackPosition.Milliseconds);
 }
Beispiel #6
0
 /// <inheritdoc/>
 public bool SeekTo(int position)
 {
     return(_api.Player_SetPosition(position));
 }
Beispiel #7
0
        public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            switch (type) // Perform some action depending on the notification type.
            {
            case NotificationType.PlayerShuffleChanged:
                UpdateActiveFlag();
                break;

            case NotificationType.TrackChanged:

                // Only process track if the plugin is active.
                if (active == false)
                {
                    break;
                }

                // Get tag value, and do not skip when the tag is not set, or is a "negative" style value.
                //string skip_tag_value2 = mbApiInterface.NowPlaying_GetFileTag(skip_tag_key);
                string skip_tag_value = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Custom1);
                if (skip_tag_value == null)
                {
                    break;
                }
                switch (skip_tag_value.ToLower())
                {
                case "":
                    break;

                case "false":
                    break;

                case "0":
                    break;

                case "no":
                    break;

                default:

                    List <Tuple <TimeSpan, TimeSpan> > ParsedTimestamps;

                    // Try parse the tag to proper timestamp ranges. If the process isn't succesful, skip the entire track.
                    if (TryParseTag(skip_tag_value, out ParsedTimestamps) == false)
                    {
                        mbApiInterface.Player_PlayNextTrack();
                        break;
                    }

                    // TODO, proper methods for handling multiple timestamps needed. Currently only checks for a new start time.

                    // If the start of the range is the start of the file, begin playing the song from the second time.
                    if (ParsedTimestamps[0].Item1.TotalMilliseconds == 0)
                    {
                        mbApiInterface.Player_SetPosition(Convert.ToInt32(ParsedTimestamps[0].Item2.TotalMilliseconds));
                        break;
                    }
                    else
                    {
                        mbApiInterface.Player_PlayNextTrack();
                        break;
                    }
                }
                break;
            }
        }