Exemplo n.º 1
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 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.
            }
        }