Playing flash videos on android webview..

Was recently playing around with getting a youtube video to run on a webview in android. Was able to run it fine using the iframe but had issues getting some control over it. Same with ooyala videos.

Simple issues like video still playing once i leave the activity, on orientation change, etc..

It was rather simple in the end, coz webview exposes methods like onPause and onResume to provide control on the flash content being played in that webview.

Here are few things that you can do:

Handle your orientation. This would help keep the video running continuously even on orientation change. Modify your manifest like below.. and override onConfigurationChanged method to handle the orientation change.

<activity android:name:"MyActivity"




In your activity, handle onResume, onPause and onDestroy and control the webView instance from there. Create the webview as presented in the method showVideo. It basically loads the youtube video in an iframe. You can use the link of embeddable version of youtube video.



Hope it helps someone.. Let me know if there’s any better way.

5 thoughts on “Playing flash videos on android webview..

  1. Hi I had also implemented youtube video in the webview in the same way before but somehow it is not working in android 3.0 and 4.0+ devices. In android 4.0.3 it just loads a blank black screen with no audio or video. But it works fine in gingerbread.
    Did u try your implementation in any of the above devices? If yes then what were the resuls?

    1. Yeah.. its a mess on ICS. Apparently, they’ve updated the webkit code in ICS and made it buggy on video and streaming.. I’ll try to see if there’s a workaround for this.

  2. Hi satya, i have downloaded your code ,but i am getting error in this line,android:hardwareAccelerated=”true” ,i am using android2.3.3.

    1. This property is available from 3.0+ SDK level. In your IDE, setting the level to honeycomb should fix it. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s