question

ChristianRobertoZaragoza-9276 avatar image
0 Votes"
ChristianRobertoZaragoza-9276 asked RobCaplan edited

WebView Xamarin Forms

Hola tengo una URL es de una radio, estoy tratando de ponerla dentro de un WebView para reproducirlo, en android funciona bien en IOS cuando le doy play no reproduce, el control play se detiene, alguna idea de lo que puede ser? muchas gracias.

Este es el codigo:

         <Grid>
             <WebView x:Name="WebviewTxt"/>
         </Grid>


WebviewTxt1.Source = "https://station.voscast.com/5bfd857684aca/";

dotnet-xamarin
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I test this web address, the radio shows in this iframe and use autoplay , would you mind not using autoplay in html? 133447-image.png



0 Votes 0 ·
image.png (8.2 KiB)

En unos instantes pruebo y te comento si funciono, muchas gracias por tu ayuda

0 Votes 0 ·

no se como usar el iframe, no me aparece en mi editor xaml de xamarin forms

0 Votes 0 ·
WenyanZhang-MSFT avatar image WenyanZhang-MSFT ChristianRobertoZaragoza-9276 ·

The webview source "https://station.voscast.com/5bfd857684aca/", this web page use allow = autoplay, you mean the redio doen't work in iOS, it caused by the limitation of WKWebview in iOS. You could have a try to change the html without allow = autoplay. You could also use customrenderer in Xamrin to set AllowsInlineMediaPlayback and MediaTypesRequiringUserActionForPlayback.

  public MyWKWebviewRenderer(WKWebViewConfiguration config) : base(config)
         {
             config.Preferences.JavaScriptCanOpenWindowsAutomatically = true;
             config.AllowsInlineMediaPlayback = true;
             config.MediaPlaybackRequiresUserAction = true;
             config.RequiresUserActionForMediaPlayback = true;
             config.MediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypes.Audio;
         }

0 Votes 0 ·

1 Answer

ChristianRobertoZaragoza-9276 avatar image
0 Votes"
ChristianRobertoZaragoza-9276 answered

Hola probé tu código y no funciono, finalmente lo resolví agregando permiso en el archivo info.plist, tuve que darle permiso al dominio de la url, eso resolvió el problemas. Muchas gracias por tu tiempo, saludos desde argentina.

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You are welcome, I'm so glad you solved this issue.

0 Votes 0 ·