Exemplo n.º 1
0
        //private async void MediaControls_ButtonPressed(SystemMediaTransportControls sender,
        //    SystemMediaTransportControlsButtonPressedEventArgs args)
        //{
        //    switch (args.Button)
        //    {
        //        case SystemMediaTransportControlsButton.FastForward:
        //            await Player.SeekAsync(TimeSpan.FromSeconds(10));
        //            break;
        //        case SystemMediaTransportControlsButton.Rewind:
        //            await Player.SeekAsync(TimeSpan.FromSeconds(-10));
        //            break;
        //        case SystemMediaTransportControlsButton.Next:
        //            // Set player to show next video
        //            break;
        //        case SystemMediaTransportControlsButton.Previous:
        //            // Set player to show previous video
        //            break;
        //    }
        //}

        private async void MyMediaElement_OnMediaOpened(object sender, RoutedEventArgs e)
        {
            var updater = MediaControls.DisplayUpdater;

            // This may not be auto-detected, and if not set, an error
            // will be raised if you attempt to set corresponding attributes
            // eg if setting video properties when Type not set to Video
            updater.Type = MediaPlaybackType.Video;

            updater.VideoProperties.Title = "Big Bunny";
            updater.VideoProperties.Subtitle = "Player sample";

            var storageFile = await Package.Current.InstalledLocation.GetFileAsync("assets\\artwork.png");

            updater.Thumbnail = RandomAccessStreamReference.CreateFromFile(storageFile);
            updater.Update();

            var me = sender as MediaElement;
            var timeline = new SystemMediaTransportControlsTimelineProperties
            {
                StartTime = TimeSpan.FromSeconds(0),
                MinSeekTime = TimeSpan.FromSeconds(0),
                Position = TimeSpan.FromSeconds(0),
                MaxSeekTime = me.NaturalDuration.TimeSpan,
                EndTime = me.NaturalDuration.TimeSpan
            };
            MediaControls.UpdateTimelineProperties(timeline);

        }
Exemplo n.º 2
0
        private static void _mediaPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            //switch (musicPlayMode)
            //{
            //    case MusicPlayMode.listLoop:
            //        _mediaPlaybackList.ShuffleEnabled = false;
            //        _mediaPlaybackList.AutoRepeatEnabled = true;
            //        break;
            //    case MusicPlayMode.songLoop:

            //        _mediaPlaybackList.MoveTo(_mediaPlaybackList.CurrentItemIndex);
            //        break;
            //    case MusicPlayMode.random:
            //        _mediaPlaybackList.ShuffleEnabled = true;
            //        break;
            //    case MusicPlayMode.sequence:
            //        _mediaPlaybackList.ShuffleEnabled = false;
            //        _mediaPlaybackList.AutoRepeatEnabled = false;
            //        break;
            //    default:
            //        break;
            //}
            if (_mediaPlaybackList.Items.Count == 0)
            {
                return;
            }
            if (MediaChanged != null)
            {
                MediaChanged(sender, playList[Convert.ToInt32(_mediaPlaybackList.CurrentItemIndex)]);
            }
            if (DisplayEvent != null)
            {
                DisplayEvent(null, Visibility.Visible);
            }


            var _systemMediaTransportControls = _mediaPlayer.SystemMediaTransportControls;

            var timelineProperties = new SystemMediaTransportControlsTimelineProperties();
            // _systemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView();
            // Fill in the data, using the media elements properties
            SystemMediaTransportControlsDisplayUpdater updater = _systemMediaTransportControls.DisplayUpdater;

            updater.Type = MediaPlaybackType.Music;
            updater.MusicProperties.Artist = playList[Convert.ToInt32(_mediaPlaybackList.CurrentItemIndex)].artist;
            updater.MusicProperties.Title  = playList[Convert.ToInt32(_mediaPlaybackList.CurrentItemIndex)].title;
            updater.Thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri(playList[Convert.ToInt32(_mediaPlaybackList.CurrentItemIndex)].pic));

            updater.Update();

            timelineProperties.StartTime   = TimeSpan.FromSeconds(0);
            timelineProperties.MinSeekTime = TimeSpan.FromSeconds(0);
            timelineProperties.Position    = _mediaPlayer.PlaybackSession.Position;
            timelineProperties.MaxSeekTime = _mediaPlayer.PlaybackSession.NaturalDuration;
            timelineProperties.EndTime     = _mediaPlayer.PlaybackSession.NaturalDuration;

            // Update the System Media transport Controls
            _systemMediaTransportControls.UpdateTimelineProperties(timelineProperties);
        }
Exemplo n.º 3
0
        void UpdateTimelineProperties()
        {
            // <SnippetUpdateTimelineProperties>
            // Create our timeline properties object
            var timelineProperties = new SystemMediaTransportControlsTimelineProperties();

            // Fill in the data, using the media elements properties
            timelineProperties.StartTime   = TimeSpan.FromSeconds(0);
            timelineProperties.MinSeekTime = TimeSpan.FromSeconds(0);
            timelineProperties.Position    = mediaElement.Position;
            timelineProperties.MaxSeekTime = mediaElement.NaturalDuration.TimeSpan;
            timelineProperties.EndTime     = mediaElement.NaturalDuration.TimeSpan;

            // Update the System Media transport Controls
            _systemMediaTransportControls.UpdateTimelineProperties(timelineProperties);
            // </SnippetUpdateTimelineProperties>
        }
Exemplo n.º 4
0
        public void SetTimeline()
        {
            SystemMediaTransportControlsTimelineProperties timelineProperties = new SystemMediaTransportControlsTimelineProperties();
            int current = Winamp.GetCurrentTrackOutputTime(OutputTimeMode.CurrentPositionMilliseconds);
            int lenght  = Winamp.GetCurrentTrackOutputTime(OutputTimeMode.TrackLenghtMilliseconds);

            timelineProperties.StartTime   = TimeSpan.FromSeconds(0);
            timelineProperties.MinSeekTime = TimeSpan.FromSeconds(0);
            timelineProperties.Position    = TimeSpan.FromMilliseconds(current);
            timelineProperties.MaxSeekTime = TimeSpan.FromSeconds(lenght);
            timelineProperties.EndTime     = TimeSpan.FromMilliseconds(lenght);

            player.IsFastForwardEnabled = true;
            player.IsRewindEnabled      = true;

            player.UpdateTimelineProperties(timelineProperties);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Used to update all position/duration related information to the SystemMediaTransport controls.
        /// Can be used when some state changes (new track, position changed) or periodically (every 5 seconds or so)
        /// to keep the system in sync with this apps playback state.
        /// </summary>
        private void UpdateSmtcPosition()
        {
            var timelineProperties = new SystemMediaTransportControlsTimelineProperties();

            // This is a simple scenario that supports seeking, therefore start time and min seek are both 0 and
            // end time and max seek are both the duration. This allows the system to suggest seeking anywhere in the track.
            // Position is the current player position.

            // Note: More complex scenarios may alter more of these values, such as only allowing seeking in a section of the content,
            // by setting min and max seek differently to start and end. For other scenarios such as live playback, end time may be
            // updated frequently too.
            timelineProperties.StartTime   = TimeSpan.FromSeconds(0);
            timelineProperties.MinSeekTime = TimeSpan.FromSeconds(0);
            timelineProperties.Position    = mediaPlayer.PlaybackSession.Position;
            timelineProperties.MaxSeekTime = mediaPlayer.PlaybackSession.NaturalDuration;
            timelineProperties.EndTime     = mediaPlayer.PlaybackSession.NaturalDuration;

            systemMediaControls.UpdateTimelineProperties(timelineProperties);
        }
        /// <summary>
        /// Used to update all position/duration related information to the SystemMediaTransport controls.
        /// Can be used when some state changes (new track, position changed) or periodically (every 5 seconds or so) 
        /// to keep the system in sync with this apps playback state. 
        /// </summary>
        private void UpdateSmtcPosition()
        {
            var timelineProperties = new SystemMediaTransportControlsTimelineProperties();

            // This is a simple scenario that supports seeking, therefore start time and min seek are both 0 and 
            // end time and max seek are both the duration. This allows the system to suggest seeking anywhere in the track.
            // Position is the current player position.

            // Note: More complex scenarios may alter more of these values, such as only allowing seeking in a section of the content,
            // by setting min and max seek differently to start and end. For other scenarios such as live playback, end time may be 
            // updated frequently too. 
            timelineProperties.StartTime = TimeSpan.FromSeconds(0);
            timelineProperties.MinSeekTime = TimeSpan.FromSeconds(0);
            timelineProperties.Position = mediaPlayer.PlaybackSession.Position;
            timelineProperties.MaxSeekTime = mediaPlayer.PlaybackSession.NaturalDuration;
            timelineProperties.EndTime = mediaPlayer.PlaybackSession.NaturalDuration;

            systemMediaControls.UpdateTimelineProperties(timelineProperties);
        }