Ronnie
Ronnie

Reputation: 11198

Auto start/play video in android

I am working on integrating some video into one of my Activities. It plays fine, but I have to click play for it to actually play. I searched the forums and the developer site and cannot find anything relating to autoplay or autostart. Any suggestions?

package com.dop.mobilevforum;

import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class Vforum extends Activity
{
    private String path = "http://somesite.com/video.mp4";

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.vforum);
        VideoView mVideoView = (VideoView) findViewById(R.id.videoView);
        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();
    }
}

Upvotes: 2

Views: 9792

Answers (1)

smg
smg

Reputation: 1223

Try calling mVideoView.start(); after requesting focus.

Upvotes: 3

Related Questions