1

error :
Couldn't open file on client side, trying server side Unable to to create media player

protected void onListItemClick(ListView l, View v, int position, long id) {

        //get selected items
        String selectedValue = (String) getListAdapter().getItem(position);

        try {

            MediaPlayer objMediaPlayer = new MediaPlayer();
            objMediaPlayer = new MediaPlayer();
            objMediaPlayer.setDataSource("http://192.168.1.3:3000/songs/WakaWaka.mp3");
            objMediaPlayer.prepare();
            objMediaPlayer.start();


        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}
4

4 回答 4

3

尝试这个:

私人媒体播放器 objMediaPlayer = 新媒体播放器();

objMediaPlayer = new MediaPlayer();

       try {
        objMediaPlayer.setDataSource(path);


        objMediaPlayer.prepare();

        objMediaPlayer.start();

    } catch (IllegalArgumentException e) {

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

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

        e.printStackTrace();
    }
于 2012-06-18T11:28:03.513 回答
2

检查 Android 媒体播放器状态图

您必须在调用 start() 之前调用 reset() e prepare()。

于 2012-06-18T11:03:34.180 回答
2

这可能对某些人有所帮助.. 为了从在线流式传输视频,您必须添加到“AndroidManifest.xml”

<uses-permission android:name="android.permission.INTERNET" />
于 2012-06-27T19:16:55.997 回答
1

我解决了你的问题。但无法得到太多。可以肯定的一件事是,您在此处指定的网址不存在。所以我利用了我自己的并做了一个样本。一探究竟,

 mediaPlayer mp=new MediaPlayer();
        try {


    mp.setDataSource("http://182.71.230.252/developers/blind_willie.mp3");
                mp.prepare();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            mp.start();
于 2012-06-18T12:45:48.973 回答