Skip to content

Webview on android doesn't load embed youtube url #6405

@lucasfeliciano

Description

@lucasfeliciano
import React, { View, WebView }  from 'react-native';

export const YoutubeScreen = React.createClass({
  render: function() {
    return (
      <View style={{flex: 1}}>
        <WebView
          style={{flex:1}}
          javaScriptEnabled={true}
          source={{uri: 'https://www.youtube.com/embed/ZZ5LpwO-An4?rel=0&autoplay=0&showinfo=0&controls=0'}}
        />
      </View>
    );
  }
});

If instead of using source={{uri: youtubeUrl}} use source={{html: iframeHtml}} it works.
But i don't want to use an iframe since I can't have access to the html inside of the iframe.

On iOS works fine. Is that a bug or a normal behaviour for android?

edit: Might be related to this:

  • set a WebChromeClient to your WebView

        web.setWebChromeClient(new WebChromeClient());
    
  • and turn on hardwareAccelerated value

    <application
    android:hardwareAccelerated="true"...
    

check out http://developer.android.com/reference/android/webkit/WebView.html and read HTML5 Video support part.

source: http://stackoverflow.com/questions/8122298/youtube-embed-videos-not-working-in-webview-whats-wrong-with-this-code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions