Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix my "Unable to to create media player" error?

I'm using the playlist1 source code here: http://www.glowingpigs.com/index.php/extras

All I've done is changed the setDataSource from a local .mp3 to an audio webstream and added the following to the manifest since from my understanding 4.xx needs internet permission for webstreaming:

<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>

Media Player Code:

if (!mediaPlayer.isPlaying()) {
            try {
                mediaPlayer.setDataSource("http://stream.kpsu.org:8080/listen");

                // Send message to Activity to display progress dialogue
                sendBufferingBroadcast();
                // Prepare mediaplayer
                mediaPlayer.prepareAsync();

            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (IOException e) {
            }
        }

And getting the weird "Unable to to create media player" error. Weird, because it really has two to's and weird because it fails to build on the data source even though the data source is correct

like image 773
Kurt Wagner Avatar asked Dec 26 '22 23:12

Kurt Wagner


1 Answers

Issue was

<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>

was that instead of

<uses-permission android:name="android.permission.INTERNET"/> 

I had put the internet permission in the manifest, but somehow or another it got erased. And I ended up pasting absentmindedly something here I should have seen was not the INTERNET permission and recognized that the INTERNET permission was missing and was causing the issue.

like image 89
Kurt Wagner Avatar answered Jan 20 '23 20:01

Kurt Wagner