【问题标题】:how play more than a video in android如何在 android 中播放更多视频
【发布时间】:2015-10-05 18:38:25
【问题描述】:

我正在开发一个应用程序,该应用程序可以从用户那里获取输入语音,并且根据句子的不同,视频可以正常工作......但是视频每次只播放一个视频

public void onActivityResult(int request_code , int result_code , Intent i){
    super.onActivityResult(request_code, result_code, i);
    MediaController mediaController= new MediaController(this);
    mediaController.setAnchorView(resultvid);
    resultvid.setMediaController(mediaController);
    CharSequence h1 = "hello";
    CharSequence h2 = "i";
    CharSequence h3 = "want";
    CharSequence h4 = "water";
    CharSequence h5 = "thank you";

    switch (request_code){
        case 100: if(result_code == RESULT_OK && i != null ){
            ArrayList<String> result = i.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            resultTEXT.setText(result.get(0));


                if (String.valueOf(result).contains(h1)) {


                }  else if (String.valueOf(result).contains(h2)) {
                    resultvid.setVideoPath("file:///storage/sdcard0/srtosl/me.mp4");


                }  else if (String.valueOf(result).contains(h3)) {
                    resultvid.setVideoPath("file:///storage/sdcard0/srtosl/want.mp4");

                }  else if (String.valueOf(result).contains(h4)) {
                    resultvid.setVideoPath("file:///storage/sdcard0/srtosl/water.mp4");

                }  else if (String.valueOf(result).contains(h5)) {
                    resultvid.setVideoPath("file:///storage/sdcard0/srtosl/thankyou.mp4");

                }

                resultvid.start();



            break;

        }
    }

如果用户输入“我要水”,我需要所有视频一个一个播放。 谢谢

【问题讨论】:

    标签: android video android-videoview


    【解决方案1】:

    VideoView / MediaPlayer 有一个 setOnCompletionListener(MediaPlayer.OnCompletionListener l) 方法。视频播放完毕后,您可以进入下一个。

    也值得一读:What is the difference between MediaPlayer and VideoView in Android

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-28
      • 2013-12-26
      • 2011-12-31
      • 2012-10-02
      • 2011-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多