我正在制作一个项目,使用使用videoview的简单代码,我可以播放3gp amd mp4格式的视频文件
vv = (VideoView) findViewById(R.id.videoView);
vv.setVideoPath(filename);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
vv.start();
我想让它也播放mkv,flv,avi格式的文件.我确实在搜索此内容,并且获得了有关votamio的选项.我也尝试过我下载了vitamio的demoproject并导入了它的库,即InitActivity,在此demoproject中,我尝试播放简单的mp4文件,但这也没有播放.
那么,谁能建议我该怎么做才能播放所有视频格式?
使用Vitamio更新1:
import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class ViewVideo extends Activity {
private String filename;
VideoView vv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.gc();
if (!LibsChecker.checkVitamioLibs(this))
return;
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
// vv = new VideoView(getApplicationContext());
setContentView(R.layout.activity_view);
vv = (VideoView) findViewById(R.id.videoView);
vv.setVideoPath(filename);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
vv.start();
}
}
当我用
if (!LibsChecker.checkVitamioLibs(this))
return;
我得到的Logcat …
06-12 13:35:53.952: E/AndroidRuntime(8078): FATAL EXCEPTION: main
06-12 13:35:53.952: E/AndroidRuntime(8078): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.videoplayer/com.example.videoplayer.ViewVideo}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.videoplayer/io.vov.vitamio.activity.InitActivity}; have you declared this activity in your AndroidManifest.xml?
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.os.Looper.loop(Looper.java:130)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread.main(ActivityThread.java:3701)
06-12 13:35:53.952: E/AndroidRuntime(8078): at java.lang.reflect.Method.invokeNative(Native Method)
06-12 13:35:53.952: E/AndroidRuntime(8078): at java.lang.reflect.Method.invoke(Method.java:507)
06-12 13:35:53.952: E/AndroidRuntime(8078): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
06-12 13:35:53.952: E/AndroidRuntime(8078): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
06-12 13:35:53.952: E/AndroidRuntime(8078): at dalvik.system.NativeStart.main(Native Method)
06-12 13:35:53.952: E/AndroidRuntime(8078): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.videoplayer/io.vov.vitamio.activity.InitActivity}; have you declared this activity in your AndroidManifest.xml?
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.Activity.startActivity(Activity.java:2933)
06-12 13:35:53.952: E/AndroidRuntime(8078): at io.vov.vitamio.LibsChecker.checkVitamioLibs(LibsChecker.java:47)
06-12 13:35:53.952: E/AndroidRuntime(8078): at com.example.videoplayer.ViewVideo.onCreate(ViewVideo.java:19)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-12 13:35:53.952: E/AndroidRuntime(8078): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
06-12 13:35:53.952: E/AndroidRuntime(8078): ... 11 more