media player - Android 4.2 with 4 MediaPlayers = "Can't play this video" -
whenever i'm trying load @ least 4 mediaplayers, 1 of them corrupt video it's trying load , trigger android os message "can't play video"
other information:
for 3 mediaplayers works fine.
on other android versions, different 4.2, same code same 4 video works.
the 4 video can played independently on device. there no format problem.
after starting program , getting "can't play video" message, video can no longer played in other application unless reset device.
i tried both videoviews or independent mediaplayers displayed on surfaceviews.
i replicated error on more devices running android 4.2. on android 4.1.2 , other android 4 versions not recall code worked fine.
on android, idea related media codecs hidden developer has use consistent , unique api : mediaplayer
.
when play media, stream or located on external device, low level codecs/parsers instanciated every time application needing help.
however, occurs particular reasons related hardware decoding, codecs, cannot instantiated more once. matter of fact, every application must releasing resources (codecs instances instance) when not need them anymore calling mediaplayer.release()
in valid state.
in fact, i'm saying illustrated in documentation of release
on android developers website :
releases resources associated mediaplayer object. considered practice call method when you're done using mediaplayer. in particular, whenever activity of application paused (its onpause() method called), or stopped (its onstop() method called), method should invoked release mediaplayer object, unless application has special need keep object around. in addition unnecessary resources (such memory , instances of codecs) being held, failure call method if mediaplayer object no longer needed may lead continuous battery consumption mobile devices, , playback failure other applications if no multiple instances of same codec supported on device. if multiple instances of same codec supported, performance degradation may expected when unnecessary multiple instances used @ same time.
so, either not calling release
when done playing back, or app holding reference on kind of resources.
edit :
if need rendering several videos on same activity
, have 2 choices. said in response, wanted not possible because of low-level issues, neither on ios way.
what can try though :
if medias playing not real-time streamed content, wrap 4 videos single one, using 1 of available free video editors. render video in full screen in activity, have 4
views
.if real-time/non recorded content, keep first video is. assume every video encoded using same codec/container. might trying transcode 3 other videos use different codec , different format. make sure transcoding codec/container supported android. might potentially force android use different decoders in same time. think overkill compared result you're expecting.
lastly, use different backend decoding such
mediaplayer
+ffmpeg
orffmpeg
. again, if works be, think, huge overkill.
to sum up, have make compromises in order work.
Comments
Post a Comment