xajist / aacdecoder-android

GNU Lesser General Public License v3.0
0 stars 0 forks source link

Library doesnt work with android 4.4 kitkat #44

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. run the app in the eclipse simulator

im getting this: 

1-21 23:30:36.573: E/AACPlayer(1471): playAsync(): 11-21 23:30:36.573: 
E/AACPlayer(1471): java.lang.NullPointerException 11-21 23:30:36.573: 
E/AACPlayer(1471): at 
com.spoledge.aacdecoder.AACPlayer.dumpHeaders(AACPlayer.java:510) 11-21 
23:30:36.573: E/AACPlayer(1471): at 
com.spoledge.aacdecoder.AACPlayer.processHeaders(AACPlayer.java:497) 11-21 
23:30:36.573: E/AACPlayer(1471): at 
com.spoledge.aacdecoder.MultiPlayer.processHeaders(MultiPlayer.java:108) 11-21 
23:30:36.573: E/AACPlayer(1471): at 
com.spoledge.aacdecoder.AACPlayer.play(AACPlayer.java:280) 11-21 23:30:36.573: 
E/AACPlayer(1471): at 
com.spoledge.aacdecoder.AACPlayer$1.run(AACPlayer.java:248) 11-21 23:30:36.573: 
E/AACPlayer(1471): at java.lang.Thread.run(Thread.java:841) 

Original issue reported on code.google.com by alexis...@gmail.com on 26 Nov 2013 at 6:23

GoogleCodeExporter commented 8 years ago
I have the similar issue, i confirm this bug on Android 4.4 (kitkat). It's 
there any solution on this issue?

Original comment by florin.i...@gmail.com on 1 Dec 2013 at 11:45

GoogleCodeExporter commented 8 years ago
Same here 4.4.+

Original comment by m.mokrzy...@gmail.com on 11 Dec 2013 at 10:59

GoogleCodeExporter commented 8 years ago
Could you please retry using standalone emulator / device ?
I am trying standalone emulator, running 4.4.2 (ARM) and playing this stream 
without errors:
http://http.yourmuze.com:8000/play/paradise/l.aac

Original comment by vbarta...@gmail.com on 29 Dec 2013 at 9:47

GoogleCodeExporter commented 8 years ago
Issue 46 has been merged into this issue.

Original comment by vbarta...@gmail.com on 29 Dec 2013 at 9:48

GoogleCodeExporter commented 8 years ago

Original comment by vbarta...@gmail.com on 29 Dec 2013 at 9:48

GoogleCodeExporter commented 8 years ago
vbarta,

The issue it's also on normal device, tested on Nexus 7 (2013), Android 4.4.2, 
here you have a stream demo: http://159.253.145.178:8100

Thanks

Original comment by florin.i...@gmail.com on 30 Dec 2013 at 11:51

GoogleCodeExporter commented 8 years ago
with the update of kitkat, android removed something, i modified the lib with 
httpclientandroidlib and works but have glitchs streams cuts sometimes

Original comment by alexis...@gmail.com on 30 Dec 2013 at 2:31

GoogleCodeExporter commented 8 years ago
i modified the file aacplayer.java

import ch.boye.httpclientandroidlib.Header;
import ch.boye.httpclientandroidlib.HttpEntity;
import ch.boye.httpclientandroidlib.HttpResponse;
import ch.boye.httpclientandroidlib.client.methods.HttpGet;
import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;

added this lib and changed:

    public void play( String url, int expectedKBitSecRate ) throws Exception {

this method to:

    public void play( String url, int expectedKBitSecRate ) throws Exception {
        if (url.indexOf( ':' ) > 0) {
            /*   
            URLConnection cn = new URL( url ).openConnection();

            prepareConnection( cn );
            cn.connect();

            processHeaders( cn );

            // TODO: try to get the expectedKBitSecRate from headers
            play( getInputStream( cn ), expectedKBitSecRate);
             */
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet request = new HttpGet(url);
            request.setHeader("Icy-MetaData", "1");
            HttpResponse response = httpClient.execute(request);

            Header[] headers = response.getAllHeaders();
            for (Header header : headers) {
                Log.d(LOG, header.getName());
                playerCallback.playerMetadata(header.getName(), header.getValue());
            }
            HttpEntity entity = response.getEntity();
            InputStream inputStream = entity.getContent();
            play( inputStream, expectedKBitSecRate);
        }
        else play( new FileInputStream( url ), expectedKBitSecRate );
    }

stream will work then but have some cuts, dont know why if someone can help 
with this will be awesome.

Original comment by alexis...@gmail.com on 30 Dec 2013 at 2:36

GoogleCodeExporter commented 8 years ago
i attached the modified aacplayer and httpclientandroidlib

Original comment by alexis...@gmail.com on 30 Dec 2013 at 2:38

Attachments:

GoogleCodeExporter commented 8 years ago
Alexis can you attach the compiled lib????

Original comment by dang...@danguru.com on 7 Jan 2014 at 11:11

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have problem with android 4.4.+ (as I said before) nexus 4
If it helps my rom is: cyanogenmod 11-201407-NIGHTLY-mako

Original comment by m.mokrzy...@gmail.com on 8 Jan 2014 at 11:44

GoogleCodeExporter commented 8 years ago
It is related to this:
http://stackoverflow.com/questions/19738798/android-4-4-http-api-bugs

Original comment by vbarta...@gmail.com on 8 Jan 2014 at 1:25

GoogleCodeExporter commented 8 years ago
I've created own solution for this issue:
$ svn ci
Sending        decoder/src/com/spoledge/aacdecoder/AACPlayer.java
Adding         decoder/src/com/spoledge/aacdecoder/IcyURLConnection.java
Adding         decoder/src/com/spoledge/aacdecoder/IcyURLStreamHandler.java
Sending        player/src/com/spoledge/aacplay/AACPlayerActivity.java
Transmitting file data ....
Committed revision 37.

I've added a simple implementation of the HTTP/SHOUTCAST URLConnection called 
IcyURLConnection and IcyURLStreamHandler which is a java.net.URLStreamHandler. 
The library then detects whether the response is the standard HTTP or SHOUTCAST 
(or better "non-HTTP" - because the class is working for all responses like 
"xxx 200 OK"). If the response is standard, then continuing without any change. 
For non-HTTP responses, the old connection is closed and new one created - but 
for a differrent URL - starting with "icy" protocol.

To allow this solution working you need to register the IcyURLStreamHandler 
once in the JVM (I am doing this in the demo player - AACPlayerActiviy:)
----
        try {
            java.net.URL.setURLStreamHandlerFactory( new java.net.URLStreamHandlerFactory(){
                public java.net.URLStreamHandler createURLStreamHandler( String protocol ) {
                    Log.d( LOG, "Asking for stream handler for protocol: '" + protocol + "'" );
                    if ("icy".equals( protocol )) return new com.spoledge.aacdecoder.IcyURLStreamHandler();
                    return null;
                }
            });
        }
        catch (Throwable t) {
            Log.w( LOG, "Cannot set the ICY URLStreamHandler - maybe already set ? - " + t );
        }
----

For pre-Kitkat version this works like before - the old  HttpURLConnection is 
used, because it is able to parse the response. 
For Kitkat version you can speedup the process by supplying the "icy" protocol 
directly in the URL like: icy://159.253.145.178:8100

Attaching the library Jar file (the native *.so libraries are not affected).

Original comment by vbarta...@gmail.com on 8 Jan 2014 at 11:26

Attachments:

GoogleCodeExporter commented 8 years ago
Tnk you , is working well

Original comment by dang...@danguru.com on 10 Jan 2014 at 2:51

GoogleCodeExporter commented 8 years ago
revision 38 and revision 39

- IcyURLConnection can be used in plain Java (removed Android logging)

- unified the way how shoutcast connections are handled on pre-Kitkat and Kitkat
     --> since now always reconnecting shoutcast streams using IcyURLConnection (due to the check of the response code - without reconnection the check is not possible) 
     --> for backward compatibility use AACPlayer.setResponseCodeCheckEnabled( false )

Original comment by vbarta...@gmail.com on 10 Jan 2014 at 7:35

GoogleCodeExporter commented 8 years ago
included in version 0.8

Original comment by vbarta...@gmail.com on 12 Jan 2014 at 8:16