Esempio n. 1
0
        /// <summary>
        /// Gets video properties for a given storage file.
        /// </summary>
        /// <param name="libVLC">LibVLC Instance.</param>
        /// <param name="mP">Item to be parsed.</param>
        /// <param name="type">Item type.</param>
        /// <returns>Music MediaProperties.</returns>
        public static async Task <VideoItem> GetVideoPropertiesAsync(LibVLC libVLC, VideoItem mP, FromType type)
        {
            var media       = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type);
            var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false);

            if (parseStatus == MediaParsedStatus.Failed)
            {
                throw new ParseMediaException($"Could not parse {mP.Path}");
            }

            mP.Title = media.Meta(MetadataType.Title);

            var showName = media.Meta(MetadataType.ShowName);

            if (string.IsNullOrEmpty(showName))
            {
                showName = media.Meta(MetadataType.Artist);
            }

            if (!string.IsNullOrEmpty(showName))
            {
                mP.ShowTitle = showName;
            }

            var episodeString = media.Meta(MetadataType.Episode);

            if (string.IsNullOrEmpty(episodeString))
            {
                episodeString = media.Meta(MetadataType.TrackNumber);
            }

            var episode = 0;

            if (!string.IsNullOrEmpty(episodeString) && int.TryParse(episodeString, out episode))
            {
                mP.Episode = episode;
            }

            var episodesTotal       = 0;
            var episodesTotalString = media.Meta(MetadataType.TrackTotal);

            if (!string.IsNullOrEmpty(episodesTotalString) && int.TryParse(episodesTotalString, out episodesTotal))
            {
                mP.Episodes = episodesTotal;
            }

            var videoTrack = media.Tracks.FirstOrDefault(x => x.TrackType == TrackType.Video);

            mP.Width  = videoTrack.Data.Video.Width;
            mP.Height = videoTrack.Data.Video.Height;

            var durationLong = media.Duration;
            var duration     = TimeSpan.FromMilliseconds(durationLong);

            mP.Duration = duration;

            return(mP);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets music properties for a given storage file.
        /// </summary>
        /// <param name="libVLC">LibVLC Instance.</param>
        /// <param name="mP">Item to be parsed.</param>
        /// <param name="type">Item type.</param>
        /// <returns>Music MediaProperties.</returns>
        public static async Task <TrackItem> GetMusicPropertiesAsync(LibVLC libVLC, TrackItem mP, FromType type)
        {
            var media       = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type);
            var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false);

            if (parseStatus == MediaParsedStatus.Failed)
            {
                throw new ParseMediaException($"Could not parse {mP.Path}");
            }

            mP.AlbumArtist = media.Meta(MetadataType.AlbumArtist);
            mP.Artist      = media.Meta(MetadataType.Artist);
            mP.Album       = media.Meta(MetadataType.Album);
            mP.Title       = media.Meta(MetadataType.Title);
            mP.AlbumArt    = media.Meta(MetadataType.ArtworkURL);
            var yearString = media.Meta(MetadataType.Date);
            var year       = 0;

            if (int.TryParse(yearString, out year))
            {
                mP.Year = year;
            }

            var      durationLong = media.Duration;
            TimeSpan duration     = TimeSpan.FromMilliseconds(durationLong);

            mP.Duration = duration;

            var  trackNbString = media.Meta(MetadataType.TrackNumber);
            uint trackNbInt    = 0;

            uint.TryParse(trackNbString, out trackNbInt);
            mP.Tracknumber = trackNbInt;

            var discNb = media.Meta(MetadataType.DiscNumber);

            if (discNb != null && discNb.Contains("/"))
            {
                // if discNb = "1/2"
                var discNumDen = discNb.Split('/');
                if (discNumDen.Any())
                {
                    discNb = discNumDen[0];
                }
            }

            int.TryParse(discNb, out int discNbInt);
            mP.DiscNumber = discNbInt;

            var genre = media.Meta(MetadataType.Genre);

            mP.Genre = genre;
            return(mP);
        }
Esempio n. 3
0
        private void DisplayVideo(string uRL)
        {
            LibVLCSharp.Shared.Core.Initialize();
            lib = new LibVLC();

            var media = new LibVLCSharp.Shared.Media(lib, uRL, FromType.FromLocation);

            mymedia.MediaPlayer = new MediaPlayer(media)
            {
                EnableHardwareDecoding = true
            };
            mymedia.MediaPlayer.Play();
        }
Esempio n. 4
0
        public VLCPage(string path)
        {
            InitializeComponent();
            download.IsVisible = false;
            LibVLCSharp.Shared.Core.Initialize();
            lib = new LibVLC();

            var media = new LibVLCSharp.Shared.Media(lib, path, FromType.FromLocation);

            mymedia.MediaPlayer = new MediaPlayer(media)
            {
                EnableHardwareDecoding = true
            };
            mymedia.MediaPlayer.Play();
        }
Esempio n. 5
0
        public VLCPage(ChurchMedia path)
        {
            InitializeComponent();
            medias = path;
            LibVLCSharp.Shared.Core.Initialize();
            lib = new LibVLC();

            var media = new LibVLCSharp.Shared.Media(lib, path.filePath, FromType.FromLocation);

            mymedia.MediaPlayer = new MediaPlayer(media)
            {
                EnableHardwareDecoding = true
            };
            mymedia.MediaPlayer.Play();

            desc.Text = path.description;
        }
        private CarouselModel CreateNewVideoItem(string modelType, string headline, string subline, string videoUrl)
        {
            var media = new LibVLCSharp.Shared.Media(LibVLC,
                                                     new Uri(videoUrl));
            var mediaPlayer = new MediaPlayer(media)
            {
                EnableHardwareDecoding = true
            };

            media.Dispose();
            mediaPlayer.Stop();

            return(new CarouselModel
            {
                ModelType = modelType,
                Headline = headline,
                Subline = subline,
                MediaPlayer = mediaPlayer,
                LibVLC = LibVLC
            });
        }
Esempio n. 7
0
 internal MediaFreedEventArgs(IntPtr mediaPtr)
 {
     Media = new Media(mediaPtr);
 }
Esempio n. 8
0
 internal MediaListWillDeleteItemEventArgs(Media media, int index) : base(media, index)
 {
 }
Esempio n. 9
0
 public MediaSubItemTreeAddedEventArgs(IntPtr subItemPtr)
 {
     SubItem = new Media(subItemPtr);
 }
Esempio n. 10
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="media">Current node</param>
 /// <param name="index">Current index</param>
 internal protected MediaListBaseEventArgs(Media media, int index)
 {
     Media = media;
     Index = index;
 }
Esempio n. 11
0
 internal MediaListItemDeletedEventArgs(Media media, int index) : base(media, index)
 {
 }
Esempio n. 12
0
 public MediaFreedEventArgs(IntPtr mediaPtr)
 {
     Media = new Media(mediaPtr);
 }
Esempio n. 13
0
 internal MediaPlayerMediaChangedEventArgs(IntPtr mediaPtr)
 {
     Media = new Media(mediaPtr);
 }
Esempio n. 14
0
 internal MediaSubItemAddedEventArgs(IntPtr mediaPtr)
 {
     SubItem = new Media(mediaPtr);
 }
Esempio n. 15
0
 public MediaPlayerMediaChangedEventArgs(IntPtr mediaPtr)
 {
     Media = new Media(mediaPtr);
 }
Esempio n. 16
0
 /// <summary>
 /// Get subitems of media descriptor object.
 /// </summary>
 /// <param name="media"></param>
 public MediaList(Media media)
     : base(() => Native.LibVLCMediaSubitems(media.NativeReference), Native.LibVLCMediaListRelease)
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Associate media instance with this media list instance. If another
 /// media instance was present it will be released. The
 /// MediaList lock should NOT be held upon entering this function.
 /// </summary>
 /// <param name="media">media instance to add</param>
 public void SetMedia(Media media)
 {
     Native.LibVLCMediaListSetMedia(NativeReference, media.NativeReference);
 }
Esempio n. 18
0
 public MediaListPlayerNextItemSetEventArgs(Media media)
 {
     Media = media;
 }
Esempio n. 19
0
 public MediaListWillAddItemEventArgs(Media media, int index) : base(media, index)
 {
 }
Esempio n. 20
0
 public MediaListItemAddedEventArgs(Media media, int index) : base(media, index)
 {
 }
Esempio n. 21
0
 internal MediaSubItemTreeAddedEventArgs(IntPtr subItemPtr)
 {
     SubItem = new Media(subItemPtr);
 }
Esempio n. 22
0
 public MediaSubItemAddedEventArgs(IntPtr mediaPtr)
 {
     SubItem = new Media(mediaPtr);
 }