Код в вопросе:
public class VideoPlayer extends Activity {
Bundle bundle;
VideoView vv;
String type;
Uri path;
Context mContext;
ImageView countImage;
@Override
public void onCreate(Bundle savedInstanceState) {
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.videoplayer);
mContext = getBaseContext();
vv = (VideoView) findViewById(R.id.videoView1);
countImage = (ImageView) findViewById(R.id.countdownNumber);
countImage.setVisibility(View.GONE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
// get details from the Bundle's extras.
bundle = getIntent().getExtras();
String playMode = bundle.getString("mode");
if (playMode.compareTo("single") == 0) { playSingle(); }
else if (playMode.compareTo("multi") == 0) { playMulti(); }
else { finish(); }
}
// --- PLAY SINGLE ---
public void playSingle() {
// retrieve name of video to play from the Bundle
String videoname = bundle.getString("videoname");
Uri path = Uri.parse("android.resource://com.sexinfo101.positions.guide/raw/video_" + videoname);
boolean result = false;
int test = mContext.getResources().getIdentifier("video_" + videoname, "raw", mContext.getPackageName());
if (test != 0) { result = true; }
if (!result) { finish(); }
vv.setMediaController(new MediaController(this));
vv.setVideoURI(path);
vv.requestFocus();
//vv.start();
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
vv.start();
}
});
vv.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (!mp.isPlaying()) {
mp.release();
finish(); // we're done here
}
}
});
}
}
Выход logcat:
08-06 15:22:30.770: ERROR/MediaPlayerService(116): Returning PV_PLAYER*************************
08-06 15:22:30.790: ERROR/PlayerDriver(116): Creating Non-Tunnel mode playback - uncompressed MIO
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): In OMX vdec Constuctor
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): Name of the device is Unknown
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Start of New Playback
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Open returned fd 30
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Reject Second instance of Decoder
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): In OMX vdec Destructor
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Msg Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Async Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Exit OMX vdec Destructor
08-06 15:22:31.310: ERROR/PlayerDriver(116): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
08-06 15:22:31.320: ERROR/MediaPlayer(1364): error (1, -17)
08-06 15:22:31.330: ERROR/MediaPlayer(1364): Error (1,-17)
Далее выводится logcat:
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): FATAL EXCEPTION: main
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): java.lang.IllegalStateException
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer._reset(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer.reset(MediaPlayer.java:1061)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.release(VideoView.java:510)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.access$2100(VideoView.java:50)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView$6.surfaceDestroyed(VideoView.java:500)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.reportSurfaceDestroyed(SurfaceView.java:568)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.updateWindow(SurfaceView.java:472)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:206)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.View.dispatchDetachedFromWindow(View.java:6029)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.doDie(ViewRoot.java:2720)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.die(ViewRoot.java:2690)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.access$2900(ActivityThread.java:125)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Looper.loop(Looper.java:123)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invoke(Method.java:521)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at dalvik.system.NativeStart.main(Native Method)
Я подозреваю, что строка logcat "08-06 17: 31: 29.960: ОШИБКА / OMX-VDEC-720P (116): отклонить второй экземпляр декодера" указывает на причину сбоя в подготовке, но у меня есть Понятия не имею, откуда взялся этот второй экземпляр. Это предшествует фактическому отключению декодера, поэтому, если не причина, то, по крайней мере, намекает на один.
Есть мысли? В отладчике я вижу, что был найден действительный ресурс, и этот код работал нормально, пока я не поменял местами таймеры для обработчика и запуска в многопользовательской функции, которую я вырезал из приведенного выше кода.