TMH
TMH

Reputation: 6246

Showing youtube video in WebView

I have some rough HTML coming from a website what I'm displaying in a WebView. In the HTML there's an iframe with a youtube video, and from what I've read they don't work. So my idea was to replace the iframe tag with an img tag (http://www.img.youtube.com/videoid/0.jpg) and make that a link to open the youtube app.

What would be the best way of me doing this? I tried using a replaceAll but it doesn't seem to be working.

if (mBundle.getString("youtubeKey") != null) {

        String youtubeKey = mBundle.getString("youtubeKey");
        sourceCode = sourceCode.replaceAll("/<iframe.*?</iframe>/si", "<img src='http://img.youtube.com/vi/"+youtubeKey+"/0.jpg");

        Log.d("FUApp", "Replaced");
    }

Upvotes: 1

Views: 4483

Answers (1)

Related Questions