-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
HTML5 video not working on MAUI WebView #4807
Comments
Thanks for the report @RaspeR87 ! It would greatly help us if you were able to provide a little sample project demonstrating this issue in the form of a GitHub repository. Thanks! |
@jfversluis of course, no problem. |
Thank you for that! Had a quick look and here is the weird thing... If I add the |
@jfversluis is maybe something related with mediaTypesRequiringUserActionForPlayback? |
Yeah I tried that as well. And it seems important to set that before you change these values before assigning the config to the WKWebView, so I tried this in my own handler: public class MyBlazorWebViewHandler : BlazorWebViewHandler
{
protected override WKWebView CreateNativeView()
{
var webview = base.CreateNativeView();
var config = webview.Configuration;
config.AllowsInlineMediaPlayback = true;
config.MediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypes.None;
config.MediaPlaybackRequiresUserAction = false;
return new WKWebView(RectangleF.Zero, config)
{
BackgroundColor = UIColor.Clear,
AutosizesSubviews = true
};
}
} But it all seemingly has no effect. One thing that stands out to me is that when I press the play button it loads for a relatively long time, so it seems the video is not even loaded yet. It doesn't even to attempt to load or autoplay. Not sure what that means, but it might be a hint for someone |
@jfversluis @RaspeR87 Would it be possible for you to try this with a plain MAUI WebView (not BlazorWebView) and see if the same issue occurs? |
Hi @RaspeR87. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@SteveSandersonMS @jfversluis no, it's not working on iOS platform with plain MAUI WebView too. It's working only on Android. Does anyone have any idea? |
Removed the Blazor label as it doesn't seem Blazor specific then. It's interesting though, if you go to this URL from a WebView: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_video_autoplay it doesn't work. But if you add the However, if you go to this page: https://googlechrome.github.io/samples/muted-autoplay/ which has the |
@jfversluis I already have muted attribute on my example on github: https://github.com/RaspeR87/MAUI/tree/main/Maui_Html5_Video I think in your example, when you add the |
Verifed reproes. repro project: [MauiApp1.zip](\mlangfs1\Public\dotnet maui\Repro Project) |
Hi, I am Glad you verified it. I too hit the same thing. Any idea on when a fix would publish? |
Thank you. When will next release be published? How frequently are new releases is published in general? I need to have some expectations in terms of when apps can use local resources (Play mp4 on WebView), in particular loading from local disk. |
@vhj1995 during the previews right now it has been once a month. After .NET MAUI goes GA, there will only be new versions once a year, every November together with the net .NET version. |
There is maybe one hint that adds some additional value here.
(Its probably another issue i have and im not using latest MAUI but an early project version of Blazor Hybrid from which MAUI was invented from. But its probably related.) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Any update on this? |
@MollsAndHersh @everybody : I've now switched to XAMARIN forms and am developing the app with the media element. |
Hi guys,
Well, interestingly enough, this works :\ Checking the requests in DevTools, the only difference between the fetch request and the normal request that the video element does when setting the video in src attribute is that the latter adds these three headers to the request:
Since I don't know if the video element has an attribute that prevents it's default chunking behavior, the only workaround for this issue that comes to my mind is as follows:
|
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
@cvalerio thanks for code snippet! |
For iOS, it looks like we need to set some properties on the configuration object here:
Unfortunately you need to set these before you pass the configuration object to the web view constructor. Setting them after this will not work. One idea is to create a builder configuration pattern to specify a delegate and have an opportunity to configure the Alternatively (or in addition to), we can set some defaults on the web view configuration out of the box:
There's more to investigate but that's the idea. |
In the meantime, if you're looking to make this work today, in .NET 7, you can customize the platform view factory or WebViewHandler like this:
|
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you! |
how could i use this in blazorwebview? In the meantime, if you're looking to make this work today, in .NET 7, you can customize the platform view factory or WebViewHandler like this: #if IOS || MACCATALYST
}; |
Description
If I want to add video in my MAUI Blazor App I have a problem with rendering this video on iOS. On Android works well.
I think the problem is in BlazorWebView component.
UPDATE This applies to all MAUI webviews, so is not Blazor-specific.
Steps to Reproduce
Create a new blank .NET MAUI Blazor App
Add some sample video mp4 file into the wwwroot/videos folder
Replace content of Index.razor page with content below:
Run app on Android. All good.
Run app on iPhone 12 (iOS 15.2) and nothing is shown where video could be.
Version with bug
Preview 13 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iPhone 12 iOS 15.2, Xcode 13.2.1, VS 17.2.0 Preview 1.0
Did you find any workaround?
No
Relevant log output
The text was updated successfully, but these errors were encountered: