[android]代码库
package com.example.day_15_surfaceview;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
public class MainActivity extends Activity {
private SurfaceView surfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
surfaceView = (SurfaceView) findViewById(R.id.surfaceview);
}
public void play(View v){
new Thread(){
private MediaPlayer player;
public void run(){
player =MediaPlayer.create(MainActivity.this, Uri.parse("mnt/sdcard/minion_08.mp4"));
SurfaceHolder handler =surfaceView.getHolder();
player.setDisplay(handler);
player.start();
}
}.start();
}
}
by: 发表于:2017-10-18 09:19:14 顶(0) | 踩(0) 回复
??
回复评论