Beispiel #1
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;
                }
            }
        }
        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;
            }
        }
Beispiel #3
0
        private void systemMediaControls_ButtonPressed(SystemMediaTransportControls smtc, SystemMediaTransportControlsButtonPressedEventArgs args)
        {
            switch (args.Button)
            {
            case SystemMediaTransportControlsButton.Stop:
                MediaControl_StopButtonPress();
                break;

            case SystemMediaTransportControlsButton.Play:
            case SystemMediaTransportControlsButton.Pause:
                MediaControl_PlayPauseButtonPress();
                break;

            case SystemMediaTransportControlsButton.Next:
                MediaControl_NextTrackButtonPress();
                break;

            case SystemMediaTransportControlsButton.Previous:
                MediaControl_PreviousTrackButtonPress();
                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;
            }
        }
Beispiel #4
0
        /// <inheritdoc />
        public bool SetVolume(int volume)
        {
            var success = false;

            if (volume >= 0)
            {
                success = _api.Player_SetVolume((float)volume / 100);

                if (_api.Player_GetMute())
                {
                    _api.Player_SetMute(false);
                }
            }

            return(success);
        }
 public void changeVolume(float volume)
 {
     mbApiInterface_.Player_SetVolume(volume);
 }