private async void NewMediaOnParsedChanged(object sender, ObjectEventArgs <MediaParsedChangedArgs> e) { if (lastMedia == null) { throw new Exception("No media loaded"); } FileInfo mediaFile = new FileInfo(new Uri(lastMedia.Mrl).LocalPath); VidereMedia media = new VidereMedia(mediaFile) { Duration = lastMedia.Duration, Name = lastMedia.GetMeta(MetaDataType.Title) }; xZune.Vlc.MediaTrack vid = lastMedia.GetTracks( ).FirstOrDefault(O => O.Type == TrackType.Video); if (vid?.VideoTrack != null) { VideoTrack vidTrack = vid.VideoTrack.Value; media.Video = new VideoInfo { Width = vidTrack.Width, Height = vidTrack.Height }; } xZune.Vlc.MediaTrack aud = lastMedia.GetTracks( ).FirstOrDefault(O => O.Type == TrackType.Audio); if (aud?.AudioTrack != null) { AudioTrack audTrack = aud.AudioTrack.Value; media.Audio = new AudioInfo { Channels = audTrack.Channels, Rate = audTrack.Rate }; } await ViderePlayer.MainDispatcher.InvokeAsync(() => OnMediaLoaded( new OnMediaLoadedEventArgs(media))); }
/* * public void GetSubitems() * { * return GetSubitemsFunction.Delegate(InstancePointer); * } */ /// <summary> /// 获取媒体的基本流的描述,注意,在调用该方法之前你需要首先调用 <see cref="VlcMedia.Parse"/> 方法,或者至少播放一次. /// 否则,你将的得到一个空数组 /// </summary> public MediaTrack[] GetTracks() { var pointer = IntPtr.Zero; var count = _getTracksFunction.Delegate(InstancePointer, ref pointer); if (pointer == IntPtr.Zero) { var ex = VlcError.GetErrorMessage(); throw new Exception(ex); } var result = new MediaTrack[count]; var temp = pointer; for (var i = 0; i < count; i++) { var p = Marshal.ReadIntPtr(temp); result[i] = (MediaTrack)Marshal.PtrToStructure(p, typeof(MediaTrack)); temp = (IntPtr)((int)temp + Marshal.SizeOf(typeof(IntPtr))); } _releaseTracksFunction.Delegate(pointer, count); return(result); }