public bool PlayVideo(string[] urls)
        {
            if (String.IsNullOrEmpty(vlcPath))
            {
                MessageBox.Show("Video Continuous Play plugin: VLC path is not set");
                mbApiInterface.Player_PlayNextTrack();
                return(false);
            }
//            MessageBox.Show("playVideo:" + urls[0]);
            stopCurrentVlc();

            alreadyPlayedVideoCount++;

            String fileUrl = urls[0];

//            int currentDuration = mbApiInterface.NowPlaying_GetDuration();
//            MessageBox.Show(currentDuration+"");

            /*
             * string durationStr = mbApiInterface.Library_GetFileProperty(fileUrl, FilePropertyType.Duration);
             * string[] durationArray = durationStr.Split(':');
             * int durationInt = 0;
             * try
             * {
             *  foreach (String str in durationArray)
             *  {
             *      durationInt *= 60;
             *      durationInt += int.Parse(str);
             *  }
             *  duration = TimeSpan.FromSeconds(durationInt);
             * }
             * catch
             * {
             *  duration = TimeSpan.Zero;
             * }
             */

            string vlcCommand = "--rate=1.0 --play-and-exit ";

            if (isFullScreen)
            {
                vlcCommand += " --fullscreen ";
            }
            vlcCommand += " \"" + fileUrl + "\"";

            vlcProcess = new System.Diagnostics.Process();
            vlcProcess.StartInfo.FileName  = vlcPath;
            vlcProcess.StartInfo.Arguments = vlcCommand;
            //vlcProcess.SynchronizingObject = this;
            vlcProcess.Exited += new EventHandler(vlcProcess_Exited);
            vlcProcess.EnableRaisingEvents = true;
            start = DateTime.Now;
            vlcProcess.Start();
            return(true);
        }
Beispiel #2
0
 private void MediaControl_NextTrackButtonPress()
 {
     if (DateTime.Now.Subtract(lastNextTrackKeyPress).TotalMilliseconds > mediaKeysInvalidateBeforeMs)
     {
         mbApiInterface.Player_PlayNextTrack();
     }
 }
Beispiel #3
0
        private void systemMediaControls_ButtonPressed(SystemMediaTransportControls smtc,
                                                       SystemMediaTransportControlsButtonPressedEventArgs args)
        {
            lock (commandLock)
            {
                switch (args.Button)
                {
                case SystemMediaTransportControlsButton.Play:
                case SystemMediaTransportControlsButton.Pause:

                    if (systemMediaControls.PlaybackStatus != MediaPlaybackStatus.Changing)
                    {
                        mbApiInterface.Player_PlayPause();
                    }

                    break;

                case SystemMediaTransportControlsButton.Stop:
                    mbApiInterface.Player_Stop();
                    break;

                case SystemMediaTransportControlsButton.Next:
                    mbApiInterface.Player_PlayNextTrack();
                    break;

                case SystemMediaTransportControlsButton.Rewind:
                case SystemMediaTransportControlsButton.Previous:
                    if (systemMediaControls.PlaybackStatus != MediaPlaybackStatus.Changing)
                    {
                        // restart song
                        if (DateTime.Now.Subtract(lastPrevious).TotalMilliseconds > PreviousDelay)
                        {
                            mbApiInterface.Player_Stop();
                            mbApiInterface.Player_PlayPause();
                            lastPrevious = DateTime.Now;
                            break;
                        }

                        // play previous track
                        if (DateTime.Now.Subtract(lastPrevious).TotalMilliseconds < PreviousDelay)
                        {
                            mbApiInterface.Player_Stop();
                            mbApiInterface.Player_PlayPreviousTrack();
                            lastPrevious = DateTime.Now;
                        }
                    }

                    break;

                // TODO: fix
                case SystemMediaTransportControlsButton.ChannelUp:
                    mbApiInterface.Player_SetVolume(mbApiInterface.Player_GetVolume() + 0.05F);
                    break;

                case SystemMediaTransportControlsButton.ChannelDown:
                    mbApiInterface.Player_SetVolume(mbApiInterface.Player_GetVolume() - 0.05F);
                    break;
                }
            }
        }
        public void changePlayState(int state)
        {
            switch (state)
            {
            case 0:
                mbApiInterface_.Player_PlayPause();
                break;

            case 1:
                mbApiInterface_.Player_PlayNextTrack();
                break;

            case 2:
                mbApiInterface_.Player_PlayPreviousTrack();
                break;

            case 3:
                mbApiInterface_.Player_Stop();
                break;

            case 4:
                mbApiInterface_.Player_Stop();
                mbApiInterface_.Player_PlayPause();
                break;
            }
        }
        private void systemMediaControls_ButtonPressed(SystemMediaTransportControls smtc, SystemMediaTransportControlsButtonPressedEventArgs args)
        {
            switch (args.Button)
            {
            case SystemMediaTransportControlsButton.Stop:
                mbApiInterface.Player_Stop();
                break;

            case SystemMediaTransportControlsButton.Play:
                if (mbApiInterface.Player_GetPlayState() != PlayState.Playing)
                {
                    mbApiInterface.Player_PlayPause();
                }
                break;

            case SystemMediaTransportControlsButton.Pause:
                if (mbApiInterface.Player_GetPlayState() != PlayState.Paused)
                {
                    mbApiInterface.Player_PlayPause();
                }
                break;

            case SystemMediaTransportControlsButton.Next:
                mbApiInterface.Player_PlayNextTrack();
                break;

            case SystemMediaTransportControlsButton.Previous:
                mbApiInterface.Player_PlayPreviousTrack();
                break;

            case SystemMediaTransportControlsButton.Rewind:
                break;

            case SystemMediaTransportControlsButton.FastForward:
                break;

            case SystemMediaTransportControlsButton.ChannelUp:
                mbApiInterface.Player_SetVolume(mbApiInterface.Player_GetVolume() + 0.05F);
                break;

            case SystemMediaTransportControlsButton.ChannelDown:
                mbApiInterface.Player_SetVolume(mbApiInterface.Player_GetVolume() - 0.05F);
                break;
            }
        }
 private void CCNext(object sender, EventArgs e)
 {
     mbApiInterface.Player_PlayNextTrack();
 }
Beispiel #7
0
 /// <inheritdoc />
 public bool PlayNext()
 {
     return(_api.Player_PlayNextTrack());
 }
Beispiel #8
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;
            }
        }