ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Unable to play mp3 in assets folder using AssetDataSource

Open amanmj opened this issue 10 years ago • 7 comments

I am using exoplayer to play a song file - "song.mp3" present in "/src/main/assets" folder using AssetDataSource.

My code is as follows :

DataSource dataSource=new AssetDataSource(getApplicationContext());
ExtractorSampleSource extractorSampleSource=new       ExtractorSampleSource(Uri.parse("song.mp3"),dataSource,new DefaultAllocator(1000),5000);
ExoPlayer exo=ExoPlayer.Factory.newInstance(1);
TrackRenderer audio=new MediaCodecAudioTrackRenderer(extractorSampleSource,null,true);
exo.prepare(audio);
exo.setPlayWhenReady(true);
Log.i("Exoplayer duration","reached end "+exo.getDuration());

exo.duration() is returning "-1" and the song is not playing. Please help.

amanmj avatar Dec 30 '15 12:12 amanmj

Try asset:///song.mp3 as URI

se-bastiaan avatar Dec 30 '15 13:12 se-bastiaan

@se-bastiaan still the same problem. It won't play @ojw28 can you look into this please?

amanmj avatar Dec 31 '15 08:12 amanmj

What @se-bastiaan suggests should work. There's not a lot we can do to investigate further unless you provide complete information as listed here.

You should also ensure that the asset really is being included in your apk. Are you able to play it using MediaPlayer or any other media library?

ojw28 avatar Jan 03 '16 16:01 ojw28

@ojw28 , yes the mp3 file is included in the apk and I am able to play it using MediaPlayer but through AssetFileDescriptor whereas I need a URI in case of AssetDataSource so AssetFileDescriptor won't work in case of Exoplayer. Issue : audio File does not play when AssetDataSource. After I run the app on an android device , the file does not play and no exception is produced. The issue is on all android devices with API>=16. I am using the current latest version of Exoplayer. Here is a snippet of my logcat.

01-04 22:21:33.532 7319-7319/com.example.amanmj.exoplayer_temp I/art: Late-enabling -Xcheck:jni
01-04 22:21:33.578 7319-7333/com.example.amanmj.exoplayer_temp I/art: Debugger is no longer active
01-04 22:21:33.673 7319-7319/com.example.amanmj.exoplayer_temp I/ExoPlayerImpl: Init 1.5.3
01-04 22:21:33.681 7319-7319/com.example.amanmj.exoplayer_temp D/AppTracker: App Event: start
01-04 22:21:33.706 7319-7345/com.example.amanmj.exoplayer_temp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
01-04 22:21:33.707 7319-7319/com.example.amanmj.exoplayer_temp D/Atlas: Validating map...
01-04 22:21:33.736 7319-7345/com.example.amanmj.exoplayer_temp I/Adreno: QUALCOMM build                   : efd53e6, I3c94fdbbc3
                                                                         Build Date                       : 09/09/15
                                                                         OpenGL ES Shader Compiler Version: E031.25.03.09
                                                                         Local Branch                     : 
                                                                         Remote Branch                    : quic/LA.BF64.1.2.1.c1_rb1.21
                                                                         Remote Branch                    : NONE
                                                                         Reconstruct Branch               : NOTHING
01-04 22:21:33.746 7319-7345/com.example.amanmj.exoplayer_temp I/OpenGLRenderer: Initialized EGL, version 1.4
01-04 22:21:33.762 7319-7345/com.example.amanmj.exoplayer_temp D/OpenGLRenderer: Enabling debug mode 0
01-04 22:21:33.762 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/evrc
01-04 22:21:33.764 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/qcelp
01-04 22:21:33.769 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
01-04 22:21:33.777 7319-7319/com.example.amanmj.exoplayer_temp D/AbstractTracker: Event success
01-04 22:21:33.781 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/x-ms-wma
01-04 22:21:33.782 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/x-ms-wma-lossless
01-04 22:21:33.783 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/x-ms-wma-pro
01-04 22:21:33.784 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/amr-wb-plus
01-04 22:21:33.789 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/qcelp
01-04 22:21:33.790 7319-7342/com.example.amanmj.exoplayer_temp W/AudioCapabilities: Unsupported mime audio/evrc
01-04 22:21:33.797 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/mpeg2
01-04 22:21:33.799 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/mpeg2
01-04 22:21:33.803 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/x-ms-wmv
01-04 22:21:33.807 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/x-ms-wmv
01-04 22:21:33.815 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/divx
01-04 22:21:33.817 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/divx311
01-04 22:21:33.824 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/divx4
01-04 22:21:33.839 7319-7342/com.example.amanmj.exoplayer_temp W/VideoCapabilities: Unsupported mime video/mp4v-esdp
01-04 22:21:33.840 7319-7319/com.example.amanmj.exoplayer_temp I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@69816d6 time:13325390
01-04 22:21:33.861 7319-7342/com.example.amanmj.exoplayer_temp I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
01-04 22:21:33.879 7319-7352/com.example.amanmj.exoplayer_temp I/OMXClient: Using client-side OMX mux.
01-04 22:21:33.884 7319-7352/com.example.amanmj.exoplayer_temp D/ACodec: configureCodec
01-04 22:21:33.921 7319-7342/com.example.amanmj.exoplayer_temp D/AudioTrack: set(): streamType -1, sampleRate 44100, format 0x1, channelMask 0x3, frameCount 17640, flags #0, notificationFrames 0, sessionId 0, transferType 3, uid -1, pid -1
01-04 22:21:33.923 7319-7342/com.example.amanmj.exoplayer_temp D/AudioTrack: TrackOffload: AudioTrack Offload disabled by property, returning false
01-04 22:21:38.344 7319-7319/com.example.amanmj.exoplayer_temp D/AppTracker: App Event: stop
01-04 22:21:38.447 7319-7319/com.example.amanmj.exoplayer_temp D/AbstractTracker: Event success

Here is a link to my code https://github.com/amanmj/exoplayer_temp @ojw28 is any other information required?

amanmj avatar Jan 04 '16 16:01 amanmj

Please see list of complete information linked above, and provide it. Thanks.

ojw28 avatar Jan 04 '16 16:01 ojw28

@ojw28 there is not any example of AssetDataSource in the demo app. I have uploaded the bugReport. Please let me know if any other information is needed. bugreport.txt Here is a link to my code https://github.com/amanmj/exoplayer_temp

amanmj avatar Jan 06 '16 15:01 amanmj

Try using larger parameters for the default allocator and the ExtractorSampleSource in:

ExtractorSampleSource extractorSampleSource=new ExtractorSampleSource(Uri.parse("song.mp3"),dataSource,new DefaultAllocator(1000),5000);

Such as the ones used in the DemoPlayer.

In particular, the ExtractorSampleSource gets blocked after lacking allocated space. You can check the ExtractorSampleSource class. To sum up, try

ExtractorSampleSource extractorSampleSource=new ExtractorSampleSource(Uri.parse("song.mp3"),dataSource,new DefaultAllocator(64 * 1024), 64 * 1024 * 256);

Just like in the DemoPlayer.

Regards.

AquilesCanta avatar Jan 07 '16 15:01 AquilesCanta