1

我正在尝试在 android 本机 mp3 播放器中播放驻留在这个地方的音频。我尝试使用 MediaPlayer 类,但没有用。尝试使用意图,但它只适用于三星集。请推荐一些好的材料,我可以在安卓本机应用程序中播放链接的 mp3 音频。路径是 basicalvarado.com/assets/sermons/bible-doctrine-series/032413-pm-The Doctrine of the Devil.mp3。空间有什么不同吗?我是安卓新手。

这是代码。

包 com.example.audiotest;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent playIntent = new Intent(Intent.ACTION_GET_CONTENT, Uri.parse("http://www.fundamentalalvarado.com/assets/sermons/bible-doctrine-series/032413-pm-The%20Doctrine%20of%20the%20Devil.mp3"));
//      playIntent.setType("audio/mp3");
        startActivity(Intent.createChooser(playIntent, "Select an audio player"));

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
4

0 回答 0