android - Playing video in EXOPlayer -
i using below code play video using exoplayer doesn't plays.
video in mp4
format.where going wrong? showing error-
com.google.android.exoplayer.exoplaybackexception: java.io.ioexception: failed instantiate extractor.
code-
loadvideo("res:/" + r.raw.samplevider); private void loadvideo(string path) { player = exoplayer.factory.newinstance(2, 1000, 5000); uri uri = uri.parse(path); samplesource = new frameworksamplesource(getactivity().getapplicationcontext(), uri, null); // 1. instantiate player. // 2. construct renderers. videorenderer = new mediacodecvideotrackrenderer(getactivity().getapplicationcontext(),samplesource, mediacodecselector.default, mediacodec.video_scaling_mode_scale_to_fit_with_cropping); audiorenderer = new mediacodecaudiotrackrenderer(samplesource,mediacodecselector.default); // 3. inject renderers through prepare. player.prepare(videorenderer, audiorenderer); // 4. pass surface video renderer. player.sendmessage(videorenderer, mediacodecvideotrackrenderer.msg_set_surface, surfaceview.getholder().getsurface()); // 5. start playback. player.setplaywhenready(true); }
try : private static final int buffer_segment_size = 64 * 1024; private static final int buffer_segment_count = 256; private static final int renderer_count = 3; uri uri = uri.parse(getavideouri()); allocator allocator = new defaultallocator(buffer_segment_size); datasource datasource = new defaulturidatasource(this, null, getuseragent(this, "exoplayerexample")); extractorsamplesource samplesource = new extractorsamplesource( uri, datasource, allocator, buffer_segment_count * buffer_segment_size); mediacodecvideotrackrenderer videorenderer = new mediacodecvideotrackrenderer( this, samplesource, mediacodecselector.default, mediacodec.video_scaling_mode_scale_to_fit); mediacodecaudiotrackrenderer audiorenderer = new mediacodecaudiotrackrenderer( samplesource, mediacodecselector.default); player = exoplayer.factory.newinstance(renderer_count); player.prepare(videorenderer, audiorenderer, secondaudiorenderer); player.sendmessage(videorenderer, mediacodecvideotrackrenderer.msg_set_surface, surfaceview.getholder().getsurface()); player.setplaywhenready(true);
Comments
Post a Comment