使用2个Android MediaPlayer类实例同时播放2个视频,如下所示
mediaplayer1.setDataSource( Path to Video1 );
mediaplayer1.prepare();
mediaplayer2.setDataSource( Path to Video2 );
mediaplayer2.prepare();
在调用mediaplayer2实例的准备工作时会遇到异常。
但如果我单独播放视频而不使用多个实例,那么它的工作正常。
我从logcat获取的日志信息如下: -
01-08 17:07:32.785: V/MediaPlayer(19201): setVideoSurfaceTexture
01-08 17:07:32.785: V/MediaPlayerService(12734): [176] setVideoSurfaceTexture(0x0)
01-08 17:07:32.785: V/MediaPlayer(19201): prepare
01-08 17:07:32.785: V/MediaPlayerService(12734): [176] setAudioStreamType(3)
01-08 17:07:32.785: V/MediaPlayerService(12734): [176] prepareAsync
01-08 17:07:32.785: V/AwesomePlayer(12734): prepareAsync
01-08 17:07:32.785: V/AwesomePlayer(12734): onPrepareAsyncEvent
01-08 17:07:32.785: I/SecMediaClock(12734): SecMediaClock constructor
01-08 17:07:32.785: I/SecMediaClock(12734): reset
01-08 17:07:32.785: V/AwesomePlayer(12734): initVideoDecoder flags=0x0
01-08 17:07:32.785: I/OMXCodec(12734): OMXCodec::Create mime (video/avc), flags (0), matchComponentName ((null)), createEncoder (0)
01-08 17:07:32.785: I/OMXCodec(12734): Attempting to allocate OMX node 'OMX.SEC.avc.dec'
01-08 17:07:32.785: D/OMX(12734): SendBroadCasting VIDEO_PLAYBACK_START
01-08 17:07:32.790: I/OMXCodec(12734): Successfully allocated OMX node 'OMX.SEC.avc.dec'
01-08 17:07:32.790: I/OMXCodec(12734): [OMX.SEC.avc.dec] AVC profile = 77 (Main), level = 40
01-08 17:07:32.790: I/OMXCodec(12734): [OMX.SEC.avc.dec] FrameRate (24)
01-08 17:07:32.790: I/OMX(12734): width (1914), height (848), fps (24)
01-08 17:07:32.790: E/OMX(12734): setParam sum(3246144) > max resolution(3010560)
01-08 17:07:32.790: D/OMX(12734): SendBroadCasting VIDEO_PLAYBACK_STOP
01-08 17:07:32.790: E/OMXCodec(12734): OmxCodec Create multi window instance fail appPid : 19201
01-08 17:07:32.795: D/WFDService(13028): intent recieved android.intent.action.VIDEO_PLAYBACK_STOP
01-08 17:07:32.795: E/WFDService(13028): FHD : android.intent.action.VIDEO_PLAYBACK_STOP
01-08 17:07:32.810: E/Bundle(13028): readBundle: bad magic number
01-08 17:07:32.810: E/Bundle(13028): readBundle: trace = java.lang.RuntimeException
01-08 17:07:32.810: E/Bundle(13028): at android.os.Bundle.readFromParcelInner(Bundle.java:1677)
01-08 17:07:32.810: E/Bundle(13028 at android.os.Bundle.<init>(Bundle.java:83)
01-08 17:07:32.810: E/Bundle(13028): at android.os.Parcel.readBundle(Parcel.java:1579)
01-08 17:07:32.810: E/Bundle(13028): at android.os.Parcel.readBundle(Parcel.java:1564)
01-08 17:07:32.810: E/Bundle(13028): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:371)
01-08 17:07:32.810: E/Bundle(13028): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2125)
01-08 17:07:32.810: E/Bundle(13028): at android.os.Binder.execTransact(Binder.java:388)
01-08 17:07:32.810: E/Bundle(13028): at dalvik.system.NativeStart.run(Native Method)
01-08 17:07:32.810: V/AwesomePlayer(12734): notifyListner_l() msg (100-MEDIA_ERROR), ext1 (1), ext2 (-2147483648)
01-08 17:07:32.810: V/MediaPlayerService(12734): [176] notify (0x40065290, 100, 1, -2147483648)
01-08 17:07:32.810: V/MediaPlayer(19201): message received msg=100, ext1=1, ext2=-2147483648
01-08 17:07:32.810: E/MediaPlayer(19201): error (1, -2147483648)
当我检查日志时,我发现setParam sum(3246144)&gt;最大分辨率(3010560)是问题的根本原因。我已经对此进行了大量搜索,但我没有得到任何与此相关的信息。任何人都可以帮我解决这个问题吗?
在Android 4.3上使用Galaxy S3。
提前致谢。