intINk
intINk

Reputation: 129

play HTML5-videos in WebView?

I'm trying to play a video from my WebView, I've solved it... well sort of, but there is one problem. As for now, I've added an image with an onclick function named "playVideo"

public void playVideo(View V)
{
    String LINK = "*URL TO VIDEO*";
    setContentView(R.layout.video_activity);
    VideoView videoView = (VideoView) findViewById(R.id.video);
    MediaController mc = new MediaController(this);
    mc.setAnchorView(videoView);
    mc.setMediaPlayer(videoView);
    Uri video = Uri.parse(LINK);
    videoView.setMediaController(mc);
    videoView.setVideoURI(video);
    videoView.start();
}

When you press it, it opens up an activity with a "VideoView".

The problem:
I'm loading the video from a server and there will be new videos that will be uploaded and I would like to implement support for videos beeing played (run the "playVideo"-method) straight from the webpage that the webview shows.

Hope you understand what I mean.
Basicly; I want to click the < video >-tag (html5) open up video_activity and play video.

Upvotes: 1

Views: 1091

Answers (1)

aegsomweb
aegsomweb

Reputation: 83

I may have inadvertently posted this answer previously in the wrong place... I converted the video file to a base64 string and fed it directly into the source, vola! The webview is no longer confused by the asset location

<video width="400"  height="225" controls="controls" align="center" poster="data:image/poster.jpg" >
<source id="bigd" src="data:video/mp4;charset=utf-8;base64,AAAAHGZ0eXBtcDQyAAAAAG1...(etc.)">
</video>

Upvotes: 1

Related Questions