|
5 | 5 | using LibVLCSharp.Shared; |
6 | 6 | using Screenbox.Core.Enums; |
7 | 7 | using Screenbox.Core.Factories; |
| 8 | +using Screenbox.Core.Helpers; |
8 | 9 | using Screenbox.Core.Messages; |
9 | 10 | using Screenbox.Core.Models; |
10 | 11 | using Screenbox.Core.Playback; |
@@ -91,32 +92,35 @@ public MediaViewModel(MediaViewModel source) |
91 | 92 | Source = source.Source; |
92 | 93 | } |
93 | 94 |
|
94 | | - private MediaViewModel(object source, LibVlcService libVlcService) |
| 95 | + private MediaViewModel(object source, MediaInfo mediaInfo, LibVlcService libVlcService) |
95 | 96 | { |
96 | 97 | _libVlcService = libVlcService; |
97 | 98 | Source = source; |
98 | 99 | Location = string.Empty; |
99 | 100 | _name = string.Empty; |
100 | | - _mediaInfo = new MediaInfo(); |
| 101 | + _mediaInfo = mediaInfo; |
101 | 102 | _artists = Array.Empty<ArtistViewModel>(); |
102 | 103 | _options = new List<string>(); |
103 | 104 | Options = new ReadOnlyCollection<string>(_options); |
104 | 105 | } |
105 | 106 |
|
106 | | - public MediaViewModel(LibVlcService libVlcService, StorageFile file) : this(file, libVlcService) |
| 107 | + public MediaViewModel(LibVlcService libVlcService, StorageFile file) |
| 108 | + : this(file, new MediaInfo(FilesHelpers.GetMediaTypeForFile(file)), libVlcService) |
107 | 109 | { |
108 | 110 | Location = file.Path; |
109 | 111 | _name = file.DisplayName; |
110 | 112 | _altCaption = file.Name; |
111 | 113 | } |
112 | 114 |
|
113 | | - public MediaViewModel(LibVlcService libVlcService, Uri uri) : this(uri, libVlcService) |
| 115 | + public MediaViewModel(LibVlcService libVlcService, Uri uri) |
| 116 | + : this(uri, new MediaInfo(MediaPlaybackType.Unknown), libVlcService) |
114 | 117 | { |
115 | 118 | Location = uri.OriginalString; |
116 | 119 | _name = uri.Segments.Length > 0 ? Uri.UnescapeDataString(uri.Segments.Last()) : string.Empty; |
117 | 120 | } |
118 | 121 |
|
119 | | - public MediaViewModel(LibVlcService libVlcService, Media media) : this(media, libVlcService) |
| 122 | + public MediaViewModel(LibVlcService libVlcService, Media media) |
| 123 | + : this(media, new MediaInfo(MediaPlaybackType.Unknown), libVlcService) |
120 | 124 | { |
121 | 125 | Location = media.Mrl; |
122 | 126 |
|
@@ -205,7 +209,7 @@ public async Task LoadDetailsAsync(IFilesService filesService) |
205 | 209 |
|
206 | 210 | switch (MediaType) |
207 | 211 | { |
208 | | - case MediaPlaybackType.Unknown when _item is { VideoTracks.Count: 0 }: |
| 212 | + case MediaPlaybackType.Unknown when _item is { VideoTracks.Count: 0, Media.IsParsed: true }: |
209 | 213 | // Update media type when it was previously set Unknown. Usually when source is a URI. |
210 | 214 | // We don't want to init PlaybackItem just for this. |
211 | 215 | MediaInfo.MediaType = MediaPlaybackType.Music; |
|
0 commit comments