private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            _duration = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                timeLine.Minimum                   = 0;
                timeLine.Maximum                   = _duration.TotalSeconds;
                timeLine.StepFrequency             = 1;
                RangeSelectorControl.Minimum       = 0;
                RangeSelectorControl.Maximum       = Math.Round(_duration.TotalSeconds);
                RangeSelectorControl.RangeMax      = RangeSelectorControl.Maximum;
                RangeSelectorControl.StepFrequency = 1;

                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval        = TimeSpan.FromSeconds(1);
                timer.Tick           += Timer_Tick;
                timeLine.Value        = ((TimeSpan)_mediaTimelineController.Position).TotalSeconds;

                //textBlock.Text = GenTimeSpanFromSeconds(Math.Round(timeLine.Value));

                lowerTime.Text = GenTimeSpanFromSeconds(Math.Round(RangeSelectorControl.RangeMin));
                upperTime.Text = GenTimeSpanFromSeconds(Math.Round(RangeSelectorControl.RangeMax));
                totalTime.Text = GenTimeSpanFromSeconds(Math.Round(RangeSelectorControl.RangeMax) - Math.Round(RangeSelectorControl.RangeMin));
            });
        }
Beispiel #2
0
 private void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     Duration = sender.Duration.GetValueOrDefault();
     Log.WriteLine("[Player]载入成功! 音乐时长: " + Duration.ToString(), Level.Info);
     LoadComplete = true;
     playerTimelineController.Start();
 }
Beispiel #3
0
        private void Source_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            // Get the MediaPlaybackItem that corresponds to the MediaSource.
            MediaPlaybackItem item = MediaPlaybackItem.FindFromMediaSource(sender);

            if (item != null && item.AudioTracks.Count > 0)
            {
                // The MediaPlaybackItem contains additional information about the underlying media.
                string audioCodec = item.AudioTracks[item.AudioTracks.SelectedIndex].GetEncodingProperties().Subtype;

                // We can read values from the MediaSource.CustomProperties.
                object customValue = null;
                sender.CustomProperties.TryGetValue("uri", out customValue);
                string uri = (string)customValue;
                customValue = null;
                sender.CustomProperties.TryGetValue("contentId", out customValue);
                string contentId = (string)customValue;
                logView.Log($"Opened Media Source with Uri: {uri}, ContentId: {contentId}, Codec: {audioCodec}", LogViewLoggingLevel.Information);

                // This extension method in MediaPlaybackItemStringExtensions dumps all the properties from all the tracks.
                var allProperties = item.ToFormattedString();
                logView.Log($"MediaPlaybackItem nested properties: {allProperties}", LogViewLoggingLevel.Verbose);
                // The AdaptiveMediaSource can manage multiple video tracks internally,
                // but only a single video track is exposed in the MediaPlaybackItem, not a collection.
            }
        }
 private void MediaSourceOnOpenOperationCompleted(MediaSource sender,
                                                  MediaSourceOpenOperationCompletedEventArgs args)
 {
     if (args.Error != null)
     {
         MediaFailed?.Invoke(this, new MediaFailedEventArgs(args.Error.ToString(), args.Error.ExtendedError));
     }
 }
        private void Source_OpenOperationCompleted(MediaSource source, MediaSourceOpenOperationCompletedEventArgs args)
        {
            // Here we create our own metadata track.
            // Our goal is to track progress through the asset and report it back to a server.
            var contentId          = (Guid)source.CustomProperties["contentId"];
            var reportingUriFormat = "http://myserver/reporting/{0}?id={1}";

            //From \Shared\TrackingEventCue.cs :
            TrackingEventCue.CreateTrackingEventsTrack(source, contentId.ToString(), reportingUriFormat);
        }
Beispiel #6
0
 private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     duration = sender.Duration.GetValueOrDefault();
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         Display_ProcessBar.Minimum       = 0;
         Display_ProcessBar.Maximum       = duration.TotalSeconds;
         Display_ProcessBar.StepFrequency = 1;
     });
 }
Beispiel #7
0
 private async void _mediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     _duration = sender.Duration.GetValueOrDefault();
     //_mediaTimelineController.Duration = _duration;
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         Slider_play.Maximum       = _duration.TotalSeconds;
         Slider_play.StepFrequency = 1;
     });
 }
Beispiel #8
0
        private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)      //  媒体文件加载完后执行
        {
            duration = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                timeLine.Minimum       = 0;                     //  设置最小长度
                timeLine.Maximum       = duration.TotalSeconds; //  设置最大长度
                timeLine.StepFrequency = 0.5;                   //  设置更新频率
            });
        }
Beispiel #9
0
        private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            _duration = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                // change ui in page
                _mediaTimelineController.Start();
                PlayAndPause.Icon = new SymbolIcon(Symbol.Pause);
            });
        }
Beispiel #10
0
 private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     totalTime = sender.Duration.GetValueOrDefault();
     mediaTimelineController.Position = TimeSpan.FromSeconds(0);
     //timeSlider.Value = mediaTimelineController.Position.TotalSeconds;
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         timeSlider.Minimum       = 0;
         timeSlider.Maximum       = totalTime.TotalSeconds;
         timeSlider.StepFrequency = 1;
     });
 }
Beispiel #11
0
 private async void openOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     timeSpan = sender.Duration.GetValueOrDefault();
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         timeLine.Minimum = 0;
         timeLine.Maximum = timeSpan.TotalSeconds;
         str = "/" + Math.Floor(timeLine.Maximum / 3600).ToString("00") + ":" + (Math.Floor(timeLine.Maximum / 60) % 60).ToString("00") + ":" + (Math.Floor(timeLine.Maximum) % 60).ToString("00");
         displayTime.Text       = "00:00:00" + str;
         timeLine.StepFrequency = 1;
     });
 }
Beispiel #12
0
 private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
     _duration = sender.Duration.GetValueOrDefault();
     _total    = (int)Math.Floor(_duration.TotalSeconds);
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         slide.Maximum   = _duration.TotalSeconds;
         display.Text    = "0 / " + _total;
         slide.Value     = 0;
         slide.IsEnabled = true;
     });
 }
Beispiel #13
0
        private void Source_OpenOperationCompleted(MediaSource source, MediaSourceOpenOperationCompletedEventArgs args)
        {
            // Here we create our own metadata track.
            // Our goal is to track progress through the asset and report it back to a server.
            object customValue = null;

            source.CustomProperties.TryGetValue("contentId", out customValue);
            string contentId          = (string)customValue;
            var    reportingUriFormat = "http://myserver/reporting/{0}?id={1}";

            // From \Shared\TrackingEventCue.cs :
            TrackingEventCue.CreateTrackingEventsTrack(source, contentId, reportingUriFormat);
        }
Beispiel #14
0
        private async void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            duration = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                timeLine.Minimum       = 0;
                timeLine.Maximum       = duration.TotalSeconds;
                timeLine.StepFrequency = 1;
                nowTime.Text           = "00:00";
                totalTime.Text         = TimeFormat(duration);
            });
        }
Beispiel #15
0
        private async void setTimeLine(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            time = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                Debug.WriteLine(time.TotalSeconds);
                timeLine.Minimum       = 0;
                timeLine.Maximum       = time.TotalSeconds;
                timeLine.StepFrequency = 1;
                DateTime dt            = new DateTime(0).AddSeconds(time.TotalSeconds);
                totalTime.Text         = " " + dt.ToString().Substring(9, 7);
                nowTime.Text           = "00:00:00";
            });
        }
Beispiel #16
0
        //得到媒体的时长,决定slider的最大值
        private async void MediaSourceOpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            timeSpan = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                mediaSlider.Minimum       = 0;
                mediaSlider.Maximum       = timeSpan.TotalSeconds;
                mediaSlider.StepFrequency = 1;

                mediaSlider1.Minimum       = 0;
                mediaSlider1.Maximum       = timeSpan.TotalSeconds;
                mediaSlider1.StepFrequency = 1;
            });
        }
Beispiel #17
0
        private async void MediaSource_OpenOperationCompleted1(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            _duration  = sender.Duration.GetValueOrDefault();
            _duration2 = sender.Duration.GetValueOrDefault();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                //<SnippetOffsetSliders>
                _timelineOffsetSlider1.Minimum       = -1 * _duration.TotalSeconds;
                _timelineOffsetSlider1.Maximum       = _duration.TotalSeconds;
                _timelineOffsetSlider1.StepFrequency = 1;

                _timelineOffsetSlider2.Minimum       = -1 * _duration2.TotalSeconds;
                _timelineOffsetSlider2.Maximum       = _duration2.TotalSeconds;
                _timelineOffsetSlider2.StepFrequency = 1;
                //</SnippetOffsetSliders>
            });
        }
        private void Source_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            // Get the MediaPlaybackItem that corresponds to the MediaSource.
            MediaPlaybackItem item = MediaPlaybackItem.FindFromMediaSource(sender);

            if (item != null && item.AudioTracks.Count > 0)
            {
                // The MediaPlaybackItem contains additional information about the underlying media.
                string audioCodec = item.AudioTracks[item.AudioTracks.SelectedIndex].GetEncodingProperties().Subtype;

                // We can read values from the MediaSource.CustomProperties.
                var uri       = (string)sender.CustomProperties["uri"];
                var contentId = (Guid)sender.CustomProperties["contentId"];
                Log($"Opened Media Source with Uri: {uri}, ContentId: {contentId}, Codec: {audioCodec}");

                // This extension method in MediaPlaybackItemStringExtensions dumps all the properties from all the tracks.
                var allProperties = item.ToFormattedString();
                Log(allProperties);
                // The AdaptiveMediaSource can manage multiple video tracks internally,
                // but only a single video track is exposed in the MediaPlaybackItem, not a collection.
            }
        }
        private void Source_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            // Get the MediaPlaybackItem that corresponds to the MediaSource.
            MediaPlaybackItem item = MediaPlaybackItem.FindFromMediaSource(sender);
            if (item != null && item.AudioTracks.Count > 0)
            {
                // The MediaPlaybackItem contains additional information about the underlying media.
                string audioCodec = item.AudioTracks[item.AudioTracks.SelectedIndex].GetEncodingProperties().Subtype;

                // We can read values from the MediaSource.CustomProperties.
                var uri = (string)sender.CustomProperties["uri"];
                var contentId = (Guid)sender.CustomProperties["contentId"];
                Log($"Opened Media Source with Uri: {uri}, ContentId: {contentId}, Codec: {audioCodec}");

                // This extension method in MediaPlaybackItemStringExtensions dumps all the properties from all the tracks.
                var allProperties = item.ToFormattedString();
                Log($"MediaPlaybackItem nested properties: {allProperties}");
                // The AdaptiveMediaSource can manage multiple video tracks internally,
                // but only a single video track is exposed in the MediaPlaybackItem, not a collection.
            }
        }
 private void MediaSourceOnOpenOperationCompleted(MediaSource sender,
     MediaSourceOpenOperationCompletedEventArgs args)
 {
     if (args.Error != null)
         MediaFailed?.Invoke(this, new MediaFailedEventArgs(args.Error.ToString(), args.Error.ExtendedError));
 }
        /*
         * private void MediaPlayer_MediaEnded(MediaPlayer sender, object args)
         * {
         *  lc.LogMessage("audio file finished playing....", LoggingLevel.Information);
         * }
         */

        /*
         * private void MediaPlayer_Play(MediaPlayer sender, object args)
         * {
         *  try
         *  {
         *      sender.Play();
         *  }
         *  catch (Exception)
         *  {
         *      lc.LogMessage("Could not play audio file....", LoggingLevel.Critical);
         *  }
         * }
         */

        private void MediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
        {
            TimeSpan duration = sender.Duration.GetValueOrDefault();

            lc.LogMessage("Finished loading the audio file, duration = " + duration.TotalSeconds + " seconds", LoggingLevel.Information);
        }
 private void Source_OpenOperationCompleted(MediaSource source, MediaSourceOpenOperationCompletedEventArgs args)
 {
     // Here we create our own metadata track.
     // Our goal is to track progress through the asset and report it back to a server.
     var contentId = (Guid)source.CustomProperties["contentId"];
     var reportingUriFormat = "http://myserver/reporting/{0}?id={1}";
     //From \Shared\TrackingEventCue.cs :
     TrackingEventCue.CreateTrackingEventsTrack(source, contentId.ToString(), reportingUriFormat);
 }
Beispiel #23
0
 private void _mediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
 {
 }