MediaPlayer正在从localhost播放文件,但不是从HTTP服务器播放

时间:2017-06-05 09:15:42

标签: android mysql http localhost android-mediaplayer

Android媒体播放器正在从localhost URL播放文件,但不是从HTTP服务器播放。我检查了文件路径和HTTP服务器上的权限一切正常。此外,我已经分别执行了他们正在工作的链接,但是当我从手机访问时,http链接无效。我还在清单中添加了所有权限。

Localurl = 192.168.1.3/songs/live_up.mp3

Httpurl = mydomainname.com/songs/live_up.mp3

private void initMediaPlayer() {
    if (mediaPlayer == null)
        mediaPlayer = new MediaPlayer();//new MediaPlayer instance

    //Set up MediaPlayer event listeners
    mediaPlayer.setOnCompletionListener(this);
    mediaPlayer.setOnErrorListener(this);
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setOnBufferingUpdateListener(this);
    mediaPlayer.setOnSeekCompleteListener(this);
    mediaPlayer.setOnInfoListener(this);
    //Reset so that the MediaPlayer is not pointing to another data source
    mediaPlayer.reset();


    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    try {
        // Set the data source to the mediaFile location
        mediaPlayer.setDataSource(activeAudio.getFile_path());
    } catch (IOException e) {
        e.printStackTrace();
        stopSelf();
    }
    mediaPlayer.prepareAsync();
}

有人请帮忙

logcat的

06-05 15:58:04.320 16454-16476/com.example.aparna.mediaplayer D/MediaHTTPConnection: filterOutInternalHeaders: key=User-Agent, val= stagefright/1.2 (Linux;Android 5.1.1)
06-05 15:58:04.321 16454-16475/com.example.aparna.mediaplayer D/MediaHTTPConnection: proxy null port 0
06-05 15:58:07.129 16454-28009/com.example.aparna.mediaplayer E/MediaPlayer: error (1, -2147483648)
06-05 15:58:07.130 16454-16454/com.example.aparna.mediaplayer E/MediaPlayer: Error (1,-2147483648)
06-05 15:58:07.130 16454-16454/com.example.aparna.mediaplayer D/MediaPlayer Error: MEDIA ERROR UNKNOWN -2147483648

0 个答案:

没有答案