简体   繁体   English

Android VideoView在某些设备上无法播放* 3.gp文件

[英]Android VideoView doesn't play *3.gp file on some devices

Good evening, I have a following problem. 晚上好,我有以下问题。 I want to play a video format * .3gp in VideoView. 我想在VideoView中播放视频格式* .3gp。 I I've tried to use this code: 我尝试使用此代码:

  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mylay);
  VideoView videoHolder = new VideoView(this);
  videoHolder = (VideoView) findViewById(R.id.videoView1);
  Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.asd);
  videoHolder.setVideoURI(video);
  videoHolder.setOnPreparedListener(new OnPreparedListener() {
   public void onPrepared(MediaPlayer mp) {
        mp.start();
        mp.setLooping(true);
   }
  });
}

Everything is working fine on emulators and HTC Desire S. But there is a Chinese tablet Onda V972, which gives me an "error when playing video" every time: 在模拟器和HTC Desire S上一切正常。但是有一个中文平板电脑Onda V972,每次给我“播放视频时出错”:

06-19 18:34:18.890: W/AudioSystem(25145): AudioFlinger server died!
06-19 18:34:18.890: W/IMediaDeathNotifier(25145): media server died
06-19 18:34:18.890: E/MediaPlayer(25145): error (100, 0)
06-19 18:34:18.890: E/MediaPlayer(25145): Error (100,0)
06-19 18:34:18.890: D/VideoView(25145): Error: 100,0

Please tell me if this problem can be solved. 请告诉我这个问题是否可以解决。 Thank you so much. 非常感谢。 Maybe there's another way to load the video file into VideoView? 也许还有另一种方法可以将视频文件加载到VideoView中?

UPDATE 21.06: 更新21.06:

Just updated firmware of my tablet, now the video is playing but not looping. 刚刚更新了我平板电脑的固件,现在视频正在播放但没有循环播放。 I've tried the following code but the rusult is the same - HTC and emulators are doing well but tablet doesn't loop the video. 我尝试了以下代码,但鲁棒的是一样的-HTC和仿真器运行良好,但平板电脑无法播放视频。 I've tried *.mp4 also, all the same: 我也尝试过* .mp4,都一样:

VideoView videoHolder = new VideoView(this);
videoHolder = (VideoView) findViewById(R.id.videoView1);
// videoHolder.setMediaController(new MediaController(this));
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.asd);
videoHolder.setVideoURI(video);
// setContentView(videoHolder);

videoHolder.setOnPreparedListener(new OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.setLooping(true);
        mp.start();
    }
});

videoHolder
        .setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                mp.mp.seekTo(0);
                mp.start();
            }

        });

The question is - how can I make the video looping on all devices? 问题是-如何使视频在所有设备上循环播放?

try like that videoview set with media controller 尝试使用与媒体控制器一起设置的videoview

public class HelloInterruptVideoStream extends Activity
{
    private String path = "http://dl.dropbox.com/u/145894/t/rabbits.3gp";
    private VideoView videoview;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        videoview = (VideoView)findViewById(R.id.surface_view);

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        videoview.setVideoURI(Uri.parse(path));
        videoview.setMediaController(new MediaController(this));
        videoview.requestFocus();
        videoview.start();

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM