其他分享
首页 > 其他分享> > Android导入视频

Android导入视频

作者:互联网

package com.hui.weblab;


import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

public class androidmanifest4 extends Activity {
    private VideoView mVideoView;
    private Button playBtn, stopBtn;
    MediaController mMediaController;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.androidmanifest);
        mVideoView = new VideoView(this);
        mVideoView = (VideoView) findViewById(R.id.video);
        mMediaController = new MediaController(this);
        playBtn = (Button) findViewById(R.id.playbutton);
        stopBtn = (Button) findViewById(R.id.stopbutton);
        playBtn.setOnClickListener(new mClick());
        stopBtn.setOnClickListener(new mClick());
    }

    class mClick implements View.OnClickListener {
        @Override
        public void onClick(View v) {

            String uri = "android.resource://" + getPackageName() + "/" + R.raw.b_6;

            mVideoView.setVideoURI(Uri.parse(uri));
            mMediaController.setMediaPlayer(mVideoView);
            mVideoView.setMediaController(mMediaController);
            if (v == playBtn) {
                mVideoView.start();
            } else if (v == stopBtn) {
                mVideoView.stopPlayback();
            }
        }
    }
}

  

标签:视频,VideoView,playBtn,mMediaController,导入,import,Android,mVideoView,android
来源: https://www.cnblogs.com/chenjiachengshmily/p/16356630.html