Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor - customization for video tag #10151

Closed
KSemenenko opened this issue Sep 15, 2022 · 3 comments
Closed

Blazor - customization for video tag #10151

KSemenenko opened this issue Sep 15, 2022 · 3 comments
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView proposal/open s/duplicate 2️⃣ This issue or pull request already exists

Comments

@KSemenenko
Copy link
Contributor

Description

As we know iOS force to use native player. But sometimes we need to customize.
Maybe background video or so on.

<video class="video-background" autoplay loop muted playsinline>

so, can we add in blazor support for it?

Public API Changes

No

Intended Use-Case

Custom video player.
Play videos on background.
Make video-call app with some custom video view.

@KSemenenko
Copy link
Contributor Author

KSemenenko commented Sep 15, 2022

In xamarin we use code like it

[assembly: ExportRenderer(typeof(MyWebView), typeof(MyWebViewRenderer))]
namespace WebViewSample.iOS
{
    public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
    {
        WKWebView wkWebView;

        protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                WKWebViewConfiguration configuration = new WKWebViewConfiguration();
                configuration.AllowsInlineMediaPlayback = true;
                wkWebView = new WKWebView(CGRect.Empty, configuration);

                if (Element.Url != null)
                {
                    wkWebView.LoadRequest(new NSUrlRequest(new NSUrl((Element).Url)));
                }
                SetNativeControl(wkWebView);
            }
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals(nameof(Element.Url)))
            {
                wkWebView.LoadRequest(new NSUrlRequest(new NSUrl((Element).Url)));
            }
        }

        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            Control.Frame = rect;
        }
    }
} 

WKWebViewConfiguration configuration = new();
configuration.AllowsInlineMediaPlayback = true;

@KSemenenko
Copy link
Contributor Author

Related to #4807

@jsuarezruiz jsuarezruiz added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Sep 16, 2022
@mkArtakMSFT
Copy link
Member

Thanks for linking the right issue, @KSemenenko. Closing this as the one you linked already tracks the work needed.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2022
@mkArtakMSFT mkArtakMSFT added the s/duplicate 2️⃣ This issue or pull request already exists label Sep 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView proposal/open s/duplicate 2️⃣ This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants