Как играть в видео с SDcard в Micromax mobile?

70
7

У меня есть приложение, в котором есть задача для воспроизведения видео SD-карты. Но он показывает Null указатель Exception... Код ниже...

public class VideoPlayerActivity extends Activity {
VideoView video_player_view;
DisplayMetrics dm;
SurfaceView sur_View;
MediaController media_Controller;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getInit();
}

public void getInit() {
try {
video_player_view = (VideoView) findViewById(R.id.video_player_view);
media_Controller = new MediaController(getApplicationContext());
dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);
int height = dm.heightPixels;
int width = dm.widthPixels;
video_player_view.setMinimumWidth(width);
video_player_view.setMinimumHeight(height);
video_player_view.setMediaController(media_Controller);
video_player_view.setVideoPath("/storage/sdcard0/baby.3gp");
video_player_view.start();
} catch(Exception exp) {
Toast.makeText(getApplicationContext(), exp.getMessage(), 2).show();
}
}}

Я использую Micromax A210 для вывода вывода. Мой Logcat ниже

12-02 19:04:52.785: D/OpenGLRenderer(3950): Enabling debug mode 0
12-02 19:04:52.787: I/SurfaceView(3950): Changes: creating=true format=true size=true visible=true left=true top=true mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=true mVisible=false mRequestedVisible=true
12-02 19:04:52.788: I/SurfaceView(3950): Cur surface: Surface(name=null, identity=-1)
12-02 19:04:52.791: V/SurfaceView(3950): android.widget.VideoView{41688140 VFE..... .F....ID 0,0-1280,590 #7f06003d app:id/video_player_view} got resized: w=1280 h=590, cur w=-1 h=-1
12-02 19:04:52.793: I/SurfaceView(3950): New surface: Surface(name=null, identity=33), vis=true, frame=Rect(0, 130 - 1280, 720)
12-02 19:04:52.793: I/SurfaceView(3950): visibleChanged -- surfaceCreated
12-02 19:04:52.798: D/MediaPlayer(3950): mPlayerID = 2
12-02 19:04:52.799: D/MediaPlayer(3950): Don't notify duration to test.example.videoviewtesting!
12-02 19:04:52.799: I/SurfaceView(3950): finishedDrawing
12-02 19:04:52.799: E/MediaPlayer(3950): error (1, -2147483648)
12-02 19:04:52.802: D/AndroidRuntime(3950): Shutting down VM
12-02 19:04:52.802: W/dalvikvm(3950): threadid=1: thread exiting with uncaught exception (group=0x4139c9a8)
12-02 19:04:52.804: E/AndroidRuntime(3950): FATAL EXCEPTION: main
12-02 19:04:52.804: E/AndroidRuntime(3950): java.lang.NullPointerException
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.widget.VideoView.openVideo(VideoView.java:396)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.widget.VideoView$6.surfaceCreated(VideoView.java:730)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.SurfaceView.updateWindow(SurfaceView.java:606)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.SurfaceView.access$000(SurfaceView.java:88)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:183)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:692)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2123)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.Choreographer.doCallbacks(Choreographer.java:579)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.Choreographer.doFrame(Choreographer.java:548)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.os.Handler.handleCallback(Handler.java:725)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.os.Looper.loop(Looper.java:153)
12-02 19:04:52.804: E/AndroidRuntime(3950): at android.app.ActivityThread.main(ActivityThread.java:5297)
12-02 19:04:52.804: E/AndroidRuntime(3950): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 19:04:52.804: E/AndroidRuntime(3950): at java.lang.reflect.Method.invoke(Method.java:511)
12-02 19:04:52.804: E/AndroidRuntime(3950): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
12-02 19:04:52.804: E/AndroidRuntime(3950): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
12-02 19:04:52.804: E/AndroidRuntime(3950): at dalvik.system.NativeStart.main(Native Method)
12-02 19:04:52.814: D/dalvikvm(3950): threadid=11: interp stack at 0x5e220000

Я обновил файл main.xml. Не знаю, где я могу изменить размер представления...

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="video.sample.videosample.MainActivity"
android:orientation="vertical"
tools:ignore="MergeRootFrame" >

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

спросил(а) 2015-12-02T17:03:00+03:00 4 года, 2 месяца назад
0
Ваш ответ
Введите минимум 50 символов
Чтобы , пожалуйста,
Выберите тему жалобы:

Другая проблема