1

I've been unable to get a particular stream to work in my MediaPlayer app. I know the app works, but when I decided to change my streaming service, the new URL won't work. Plugging this URL into a web browser DOES work. Here's my relevant code:

String url = "http://smoke.wavestreamer.com:7562/listen.asx?sid=1";
mediaPlayer.setOnPreparedListener(this); // ...and other listeners...
mediaPlayer.setDataSource(url);
mediaPlayer.prepareAsync();

And then, in onPrepared():

mediaPlayer.start();

This is my LogCat (from running it on my Samsung Galaxy Nexus with Android 4.3):

01-23 14:32:08.994    8726-8726/com.mycompany.myapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-23 14:32:08.994    8726-8726/com.mycompany.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 11370: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-23 14:32:08.994    8726-8726/com.mycompany.myapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
01-23 14:32:08.994    8726-8726/com.mycompany.myapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-23 14:32:08.994    8726-8726/com.mycompany.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 11376: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-23 14:32:08.994    8726-8726/com.mycompany.myapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
01-23 14:32:09.002    8726-8726/com.mycompany.myapp I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-23 14:32:09.002    8726-8726/com.mycompany.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 9064: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-23 14:32:09.002    8726-8726/com.mycompany.myapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
01-23 14:32:09.017    8726-8726/com.mycompany.myapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-23 14:32:09.017    8726-8726/com.mycompany.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 377: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-23 14:32:09.025    8726-8726/com.mycompany.myapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
01-23 14:32:09.025    8726-8726/com.mycompany.myapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-23 14:32:09.025    8726-8726/com.mycompany.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 399: Landroid/content/res/TypedArray;.getType (I)I
01-23 14:32:09.025    8726-8726/com.mycompany.myapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
01-23 14:32:09.244    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Binding to service
01-23 14:32:09.244    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ in startAndBindToService()
01-23 14:32:09.533    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ service.onStartCommand()
01-23 14:32:09.533    8726-8726/com.mycompany.myapp D/MediaPlayerService﹕ onStartCommand()
01-23 14:32:09.541    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ intent.getAction() is null (started from MainActivity); returning now
01-23 14:32:09.799    8726-8726/com.mycompany.myapp D/libEGL﹕ loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
01-23 14:32:09.892    8726-8726/com.mycompany.myapp D/libEGL﹕ loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
01-23 14:32:09.900    8726-8726/com.mycompany.myapp D/libEGL﹕ loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
01-23 14:32:10.088    8726-8726/com.mycompany.myapp D/OpenGLRenderer﹕ Enabling debug mode 0
01-23 14:32:10.088    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Bound to service
01-23 14:32:10.096    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:10.096    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:10.408    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Service set to run in foreground.
01-23 14:32:10.510    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ WifiLock acquired.
01-23 14:32:10.635    8726-8726/com.mycompany.myapp I/Choreographer﹕ Skipped 31 frames!  The application may be doing too much work on its main thread.
01-23 14:32:10.931    8726-8739/com.mycompany.myapp E/MediaPlayer﹕ error (1, -2147483648)
01-23 14:32:11.041    8726-8726/com.mycompany.myapp E/MediaPlayer﹕ Error (1,-2147483648)
01-23 14:32:11.041    8726-8726/com.mycompany.myapp E/MyMediaPlayer﹕ There has been an error of type MEDIA_ERROR_UNKNOWN, with no extras
01-23 14:32:11.041    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ There was an error initializing media player
01-23 14:32:11.056    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Restarting after error
01-23 14:32:11.056    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:11.056    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:11.221    8726-8726/com.mycompany.myapp D/dalvikvm﹕ GC_FOR_ALLOC freed 231K, 3% free 9144K/9412K, paused 136ms, total 137ms
01-23 14:32:11.517    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:11.627    8726-8856/com.mycompany.myapp E/MediaPlayer﹕ error (1, -2147483648)
01-23 14:32:11.838    8726-8726/com.mycompany.myapp E/MediaPlayer﹕ Error (1,-2147483648)
01-23 14:32:11.846    8726-8726/com.mycompany.myapp E/MyMediaPlayer﹕ There has been an error of type MEDIA_ERROR_UNKNOWN, with no extras
01-23 14:32:11.846    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ There was an error initializing media player
01-23 14:32:11.861    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Restarting after error
01-23 14:32:11.861    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:11.861    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:11.900    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Service set to run in foreground.
01-23 14:32:11.971    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:11.978    8726-8739/com.mycompany.myapp E/MediaPlayer﹕ error (1, -107)
01-23 14:32:12.064    8726-8726/com.mycompany.myapp E/MediaPlayer﹕ Error (1,-107)
01-23 14:32:12.064    8726-8726/com.mycompany.myapp E/MyMediaPlayer﹕ There has been an error of type MEDIA_ERROR_UNKNOWN, with no extras
01-23 14:32:12.064    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ There was an error initializing media player
01-23 14:32:12.080    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Restarting after error
01-23 14:32:12.080    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:12.080    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:12.166    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Service set to run in foreground.
01-23 14:32:12.306    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:12.471    8726-8740/com.mycompany.myapp E/MediaPlayer﹕ error (1, -2147483648)
01-23 14:32:12.525    8726-8726/com.mycompany.myapp E/MediaPlayer﹕ Error (1,-2147483648)
01-23 14:32:12.525    8726-8726/com.mycompany.myapp E/MyMediaPlayer﹕ There has been an error of type MEDIA_ERROR_UNKNOWN, with no extras
01-23 14:32:12.525    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ There was an error initializing media player
01-23 14:32:12.541    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Restarting after error
01-23 14:32:12.541    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:12.541    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:12.603    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Service set to run in foreground.
01-23 14:32:12.666    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:12.674    8726-8740/com.mycompany.myapp E/MediaPlayer﹕ error (1, -107)
01-23 14:32:12.721    8726-8726/com.mycompany.myapp E/MediaPlayer﹕ Error (1,-107)
01-23 14:32:12.728    8726-8726/com.mycompany.myapp E/MyMediaPlayer﹕ There has been an error of type MEDIA_ERROR_UNKNOWN, with no extras
01-23 14:32:12.728    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ There was an error initializing media player
01-23 14:32:12.744    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Restarting after error
01-23 14:32:12.744    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Initializing service.
01-23 14:32:12.744    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ setting up mediaPlayer
01-23 14:32:12.806    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ Service set to run in foreground.
01-23 14:32:12.869    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:13.158    8726-8739/com.mycompany.myapp E/MediaPlayer﹕ error (1, -2147483648)
01-23 14:32:14.619    8726-8726/com.mycompany.myapp D/MyMediaPlayer﹕ resetting mediaPlayer
01-23 14:32:23.588    9136-9136/com.mycompany.myapp D/MyMediaPlayer﹕ service.onStartCommand()
01-23 14:32:23.588    9136-9136/com.mycompany.myapp D/MediaPlayerService﹕ onStartCommand()
01-23 14:32:23.588    9136-9136/com.mycompany.myapp D/MyMediaPlayer﹕ intent is null (restarted after service crashed); returning now
01-23 14:38:12.939    9136-9136/com.mycompany.myapp D/dalvikvm﹕ GC_EXPLICIT freed 49K, 1% free 8874K/8960K, paused 5ms+4ms, total 47ms
01-23 14:39:58.627  10507-10507/com.mycompany.myapp D/MyMediaPlayer﹕ service.onStartCommand()
01-23 14:39:58.627  10507-10507/com.mycompany.myapp D/MediaPlayerService﹕ onStartCommand()
01-23 14:39:58.627  10507-10507/com.mycompany.myapp D/MyMediaPlayer﹕ intent is null (restarted after service crashed); returning now
01-23 14:45:06.166  11567-11567/com.mycompany.myapp D/MyMediaPlayer﹕ service.onStartCommand()
01-23 14:45:06.166  11567-11567/com.mycompany.myapp D/MediaPlayerService﹕ onStartCommand()
01-23 14:45:06.166  11567-11567/com.mycompany.myapp D/MyMediaPlayer﹕ intent is null (restarted after service crashed); returning now
01-23 14:48:12.556  11567-11567/com.mycompany.myapp D/dalvikvm﹕ GC_EXPLICIT freed 40K, 1% free 8874K/8952K, paused 5ms+3ms, total 42ms
01-23 14:50:54.744  11567-11567/com.mycompany.myapp D/dalvikvm﹕ GC_EXPLICIT freed 1K, 1% free 8873K/8952K, paused 3ms+3ms, total 32ms
01-23 14:52:52.205  11567-11567/com.mycompany.myapp D/dalvikvm﹕ GC_EXPLICIT freed <1K, 1% free 8873K/8952K, paused 4ms+3ms, total 36ms

Any ideas?

EDIT

I did a bit more digging and setup an HttpURLConnection to the link provided above. When I parsed the headers, this is what I found (key=value):

null=[HTTP/1.1 200 OK]
Connection=[close]
Content-Length=[244]
Content-Type=[video/x-ms-asf]

And when I did a search on the Content-Type, I found this on Wikipedia:

...and .WMV (files containing video, using the Windows Media Audio and Video codecs, with MIME-type 'video/x-ms-asf')

Does this mean the stream is encoded as a .WMV file? (and, therefore, is unsupported?)

EDIT 2

I have been assured that the stream is encoded as an .MP3. I don't know why MediaPlayer won't read it.

AutonomousApps
  • 3,503
  • 2
  • 27
  • 39

2 Answers2

0

use this :

            MediaPlayer Music = new MediaPlayer();
            Music = MediaPlayer.create(G.context, Uri.parse("PUT YOUR URL HERE"));
            Music.prepare();
            Music.start();
Saman
  • 1,557
  • 4
  • 16
  • 35
  • I tried and that didn't work. Got the exact same response, except for this slight change in the logcat output: `D/MediaPlayer: Couldn't open file on client side, trying server side` – AutonomousApps Jan 23 '15 at 21:17
  • make sure have INTERNET permission – Saman Jan 23 '15 at 21:26
  • I have INTERNET and WAKE_LOCK permissions declared. – AutonomousApps Jan 23 '15 at 21:46
  • I took a look at the MediaPlayer source on [GrepCode](http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/media/MediaPlayer.java#MediaPlayer), and it appears that error message ("Couldn't open file...") would only be called if there was either an `IOException` or `SecurityException` when trying to use a URI as a data source. Unfortunately, both those `catch` blocks are empty, so I can't get a more specific error message. – AutonomousApps Jan 24 '15 at 00:55
0

Thanks so much to this answer on SO, and despite the fact that the URL insisted its Content-Type was media, I parsed it like it was a text file and found out that it was a text file--basically, a playlist containing a link to the actual media stream.

For anyone else that might come across this issue, here's the code I used to parse the URL and learn the actual streaming media link:

        String url = "http://smoke.wavestreamer.com:7562/listen.asx";
        String charset = "UTF-8";
        String param1 = "1";

        try {
            String query = String.format("sid=%s", URLEncoder.encode(param1, charset));

            // Open a connection and InputStream to URL
            URLConnection connection = new URL(url + "?" + query).openConnection();
            connection.setRequestProperty("Accept-Charset", charset);
            InputStream response = connection.getInputStream();

            // Get status
            int status = ((HttpURLConnection) connection).getResponseCode();
            System.out.println("HttpURLConnection STATUS = " + status);

            // Get headers
            for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
                System.out.println(header.getKey() + "=" + header.getValue());
            }

            // Read response InputStream
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response/*, charset*/))) {
                System.out.println("Reading 'response' InputStream:");
                for (String line; (line = reader.readLine()) != null;) {
                    System.out.println(line);
                }
            }

        } catch (UnsupportedEncodingException e) {
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
Community
  • 1
  • 1
AutonomousApps
  • 3,503
  • 2
  • 27
  • 39