Repository navigation
Support for MediaPlayerElement/MediaPlayer - SKIA - #12198
Conversation
9368963 to
9dc51d4
Compare
There was a problem hiding this comment.
@rafael-rosa-knowcode I was discussing
with @nickrandolphBorder isn't supposed to have IsEnabled and it's being removed as part of the breaking changes. We think this line should set IsEnabled for ProgressSlider rather than the border.
I'm making the change in the breaking changes branch to unblock merging master to it: 1f8dffa, but consider doing it for master as well.
161cb44 to
12a0399
Compare
be5038d to
0b50d0c
Compare
| { | ||
| if (_videoView != null && | ||
| _mediaPlayer != null && | ||
| _mediaPlayer.Media != null && | ||
| _mediaPlayer.Media.Mrl != null && | ||
| _videoContainer is not null) | ||
| { | ||
| if (this.ActualHeight <= 0 || this.ActualWidth <= 0) | ||
| { | ||
| CheckUpdatedRequested(); | ||
| return; | ||
| } | ||
|
|
||
| var playerHeight = (double)this.ActualHeight - _transportControlsBounds.Height; | ||
| var playerWidth = (double)this.ActualWidth; | ||
|
|
||
| _mediaPlayer.Media.Parse(MediaParseOptions.ParseNetwork); | ||
|
|
||
| _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | ||
| { | ||
| if (_mediaPlayer != null && _mediaPlayer.Media != null) | ||
| { | ||
| var videoTrack = _mediaPlayer.Media.Tracks.FirstOrDefault(track => track.TrackType == TrackType.Video); | ||
| if (_mediaPlayer.Media.Tracks.Any(track => track.TrackType == TrackType.Video)) | ||
| { | ||
| var videoSettings = videoTrack.Data.Video; | ||
| var videoWidth = videoSettings.Width; | ||
| var videoHeight = videoSettings.Height; | ||
|
|
||
| // From: https://github.com/videolan/libvlcsharp/blob/bca0a53fe921e6f1f745e4e3ac83a7bd3b2e4a9d/src/LibVLCSharp/Shared/MediaPlayerElement/AspectRatioManager.cs#L188 | ||
| videoWidth = videoWidth * videoSettings.SarNum / videoSettings.SarDen; | ||
|
|
||
| UpdateVideoSizeAllocate(playerHeight, playerWidth, videoHeight, videoWidth); | ||
| } | ||
| else | ||
| { | ||
| CheckUpdatedRequested(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| CheckUpdatedRequested(); | ||
| } | ||
| }); | ||
| } | ||
| else | ||
| { | ||
| CheckUpdatedRequested(); | ||
| } |
There was a problem hiding this comment.
| { | |
| if (_videoView != null && | |
| _mediaPlayer != null && | |
| _mediaPlayer.Media != null && | |
| _mediaPlayer.Media.Mrl != null && | |
| _videoContainer is not null) | |
| { | |
| if (this.ActualHeight <= 0 || this.ActualWidth <= 0) | |
| { | |
| CheckUpdatedRequested(); | |
| return; | |
| } | |
| var playerHeight = (double)this.ActualHeight - _transportControlsBounds.Height; | |
| var playerWidth = (double)this.ActualWidth; | |
| _mediaPlayer.Media.Parse(MediaParseOptions.ParseNetwork); | |
| _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
| { | |
| if (_mediaPlayer != null && _mediaPlayer.Media != null) | |
| { | |
| var videoTrack = _mediaPlayer.Media.Tracks.FirstOrDefault(track => track.TrackType == TrackType.Video); | |
| if (_mediaPlayer.Media.Tracks.Any(track => track.TrackType == TrackType.Video)) | |
| { | |
| var videoSettings = videoTrack.Data.Video; | |
| var videoWidth = videoSettings.Width; | |
| var videoHeight = videoSettings.Height; | |
| // From: https://github.com/videolan/libvlcsharp/blob/bca0a53fe921e6f1f745e4e3ac83a7bd3b2e4a9d/src/LibVLCSharp/Shared/MediaPlayerElement/AspectRatioManager.cs#L188 | |
| videoWidth = videoWidth * videoSettings.SarNum / videoSettings.SarDen; | |
| UpdateVideoSizeAllocate(playerHeight, playerWidth, videoHeight, videoWidth); | |
| } | |
| else | |
| { | |
| CheckUpdatedRequested(); | |
| } | |
| } | |
| else | |
| { | |
| CheckUpdatedRequested(); | |
| } | |
| }); | |
| } | |
| else | |
| { | |
| CheckUpdatedRequested(); | |
| } | |
| { | |
| if (_videoView is not null && | |
| _mediaPlayer?.Media is { Mrl: not null } media | |
| _videoContainer is not null) | |
| { | |
| if (this.ActualHeight <= 0 || this.ActualWidth <= 0) | |
| { | |
| CheckUpdatedRequested(); | |
| return; | |
| } | |
| var playerHeight = (double)this.ActualHeight - _transportControlsBounds.Height; | |
| var playerWidth = (double)this.ActualWidth; | |
| media.Parse(MediaParseOptions.ParseNetwork); | |
| _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
| { | |
| if (media != _mediaPlayer?.Media) | |
| { | |
| return; // The media has been modified, abort async operation | |
| } | |
| if (media.Tracks.FirstOrDefault(track => track.TrackType == TrackType.Video) is { } videoTrack) | |
| { | |
| var videoSettings = videoTrack.Data.Video; | |
| var videoWidth = videoSettings.Width; | |
| var videoHeight = videoSettings.Height; | |
| // From: https://github.com/videolan/libvlcsharp/blob/bca0a53fe921e6f1f745e4e3ac83a7bd3b2e4a9d/src/LibVLCSharp/Shared/MediaPlayerElement/AspectRatioManager.cs#L188 | |
| videoWidth = videoWidth * videoSettings.SarNum / videoSettings.SarDen; | |
| UpdateVideoSizeAllocate(playerHeight, playerWidth, videoHeight, videoWidth); | |
| } | |
| else | |
| { | |
| CheckUpdatedRequested(); | |
| } | |
| }); | |
| } | |
| else | |
| { | |
| CheckUpdatedRequested(); | |
| } |
- As you are running async, you should capture the
mediavariables to make sure that it's not altered while deferring - You are searching for the video track (
videoTrack) inmedia, and the enumerating a second time to validate the you found something instead of validating thatvideoTrack is not null
You should also keep a reference of your async taks (the _) and make sure to clear it.
There was a problem hiding this comment.
The change do not work.
The media != _mediaPlayer?.Media is always different.
There was a problem hiding this comment.
For me the media != _mediaPlayer?.Media is always false is a red flag. It could be either:
- We are scheduling an async task for a given media, but it changes before we are able to execute that task ... and we will probably re-schedule a new task soon for the new media
- More probably the
_mediaPlayer?.Mediais creating a new instance ofLibVLCSharp.[..].Mediaon each get and that class does not implement equality operators. Then we should definitely keep a reference on themedialike I did instead of getting it everytime, and change the check I did to protect our-self from the first case by either:- Comparing
media.Mrlinstead of instances (we need to check if its a fullMrlthat contains all infos about the media) - (Preferred) Using a
CancellationTokenfor all async operation related to the media and make sure to cancel it when the media changes.
- Comparing
b34245b to
ef9dea5
Compare
| var videoTrack = _mediaPlayer.Media.Tracks.FirstOrDefault(track => track.TrackType == TrackType.Video); | ||
|
|
||
| if (_mediaPlayer.Media.Tracks.Any(track => track.TrackType == TrackType.Video)) |
There was a problem hiding this comment.
My previous comment here has not been addressed yet. There is something that we need to understand and fix / workaround #12198 (comment)
GitHub Issue (If applicable): closes #
PR Type
What kind of change does this PR introduce?
Support for MediaPlayerElement/MediaPlayer on Skia GTK
What is the current behavior?
Skia GTK do not play MediaPlayerElement
What is the new behavior?
Play MediaPlayerElement/MediaPlayer and have all features.
PR Checklist Of Features
Not Work
OK - working
Show and Enable functionality Work
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information
Internal Issue (If applicable): #12240