I'm using this piece of code to play an acc that is on the cloud with FFmpegMediaPlayer taken from here:
https://github.com/wseemann/FFmpegMediaPlayer
Code:
FFmpegMediaPlayer player = new FFmpegMediaPlayer();
try {
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(url);
player.prepareAsync();
} catch ( IOException | ExecutionException | InterruptedException e ){
e.printStackTrace();
}
When the URL format is like "http://something.com/audio.aac" that code works fine.
But, when the URL is like "https://something.com/audio.aac?something_else_here" that code doesn't work and it fires en Error(0,0).
Before FFmpegMediaPlayer I used the MediaPlayer with exact the same methods. Sometimes it had the same problems sometimes not, so I thought to switch to FFmpegMediaPlayer even because it is faster, but I'm not handling this error.
Does anyone now how to deal with this?
There might be several reasons why this error occurs but I'm going to show what did I do in my case. I thought that the problem was with the ending string of the link but it looks that it was OK.
I installed FFmpegMediaPlayer via gradle in my project:
dependencies {
compile 'com.github.wseemann:FFmpegMediaPlayer:1.0.4'
}
but it looks that when I was calling
player.setDataSource(url);
player.prepareAsync();
it had a problem with https
link.
So, what I did was to manually import the AAR package that supports the HTTPS
. I downloaded it in:
https://github.com/wseemann/FFmpegMediaPlayer/releases/download/v1.0.3/prebuilt-aars-with-https.zip
There are several AAR files compiled for different architectures, but there is also an AAR file that includes all architectures.
So this, was the solution of my problem.
The drawback is that importing this AAR the size of your application will increase by 4MB at least or even by 20MB if you choose to include the file that is compiled for all architectures.
At the end I went on another approach, but definitely Android should take some care on its MediaPlayer because it gives so much pain to the developers.