videoview不会播放视频

时间:2017-10-23 14:54:43

标签: android

你好按下按钮时试图播放视频,但是当我启动应用程序时,我收到视频无法播放的消息。

    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();

            }
        });

0 个答案:

没有答案