你好按下按钮时试图播放视频,但是当我启动应用程序时,我收到视频无法播放的消息。
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;
public class lydbrett extends AppCompatActivity {
VideoView videolyd;
Uri uri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lydbrett);
videolyd = (VideoView) findViewById(R.id.videoView);
uri = Uri.parse("android.resource;//" + getPackageName()+ "/" + R.raw.nice);
videolyd.setVideoURI(uri);
Button playButton = (Button) findViewById(R.id.button);
playButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
videolyd.start();
}
});