libvlcsharp
libvlcsharp copied to clipboard
Avalonia: Child content support for VideoView
Description of Change
Allow content to be placed to VideoView so that it renders it on top of the media player.
- Created bindable Content property for VideoView.
- When content is assigned or VideoView is attached to visual tree, tries to create a new transparent overlay window that is placed on top of the VideoView.
- Content is binded to windows content property.
- Uses VideoView Content and Bound property changed events to update overlay position.
Updated sample.
Solution is based on this PR: https://github.com/videolan/libvlcsharp/pull/294
Issues Resolved
- fixes #408
API Changes
Added:
- object VideoView.Content { get; set; } //Bindable Property
Platforms Affected
- Avalonia
Behavioral/Visual Changes
If user places control inside VideoView it will be shown top of the video.
Before/After Screenshots
Testing Procedure
- Tested with Windows 11
PR Checklist
- [x] Rebased on top of the target branch at time of PR
- [x] Changes adhere to coding standard
Thanks for implementing this 🎉
I'm not a fan of the Min/MaxContentOpacity properties, because it seems specific to your use case and, if I remember correctly, there is no such thing on the WPF airspace hack. (that being said, if @mfkl is OK with this, we might as well add the feature to the WPF implementation)
Otherwise, it's looking good (though I didn't test) and I'm looking forward having that fixed in the Avalonia implementation :)
I'm not a fan of the Min/MaxContentOpacity properties, because it seems specific to your use case and, if I remember correctly, there is no such thing on the WPF airspace hack. (that being said, if @mfkl is OK with this, we might as well add the feature to the WPF implementation)
You are right. At first I thought there would be an use case for it but I've been tinkering with this by building an media player element for Avalonia and realized that is something that should be implemented with content and not with VideoView. I will remove those properties and event handling related to the opacity change.
Converted this PR to draft. I was thinkin that it would be beneficial to get PointerEntered/PointerExited events from VideoView. Maybe other events aswell?
Tested, seems to work fine, thanks!
We'll likely have some fixes once it is used by a few people in production, this kind of thing is tricky to get right on the first go with all the edge cases (see the WPF history https://github.com/videolan/libvlcsharp/commits/3.x/src/LibVLCSharp.WPF), but that's alright.
Thanks for this! Will push to nuget tomorrow.