Streaming AAC audio with Android

后端 未结 5 920
遇见更好的自我
遇见更好的自我 2020-12-23 15:05

As I understand it, Android will only play AAC format audio if it\'s encoded as MPEG-4 or 3GPP.

I\'m able to play AAC audio encoded as M4A when it\'s local to the ap

5条回答
  •  渐次进展
    2020-12-23 15:25

    I tried it too but I could not find out the solution!

    At the last Google I/O I saw something that helped me a lot. It is Extending from MediaPlayer and improve a lot of things! Take a look.

    EXOPLAYER CAN HELP YOU A LOT

    Check this part of the example:

    private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
    private static final int BUFFER_SEGMENT_COUNT = 256;
    ...
    
    // String with the url of the radio you want to play
    String url = getRadioUrl();
    Uri radioUri = Uri.parse(url);
    // Settings for exoPlayer
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
    String userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
    DataSource dataSource = new DefaultUriDataSource(context, null, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(
    radioUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT);
    audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
    // Prepare ExoPlayer
    exoPlayer.prepare(audioRenderer);
    

    EXOPLAYER- I can play anything from streamings (video and audio)!

    LET ME KNOW IF YOU NEED HELP TO IMPLEMENT IT! :)

提交回复
热议问题