我正在开发一个音频播放器的应用程序。我想播放来自url的音频,我正在做代码,但它播放本地目录的音频,即原始文件夹。我想从播放列表中一次播放单个URL的歌曲,如何在doinbackground方法中实现代码来播放单个文件。在下面的代码中从url播放音频需要做些什么?建议我!如何从android中的URL播放音频文件?
public class RelaxationLvAudioPlayerActivity1 extends Activity implements SeekBar.OnSeekBarChangeListener {
private ImageButton btnPlay;
private ImageButton btnForward;
private ImageButton btnBackward;
private ImageButton btnNext;
private ImageButton btnPrevious;
private ImageButton btnPlaylist;
private ImageButton btnRepeat;
private ImageButton btnShuffle;
private SeekBar songProgressBar;
private TextView songTitleLabel;
private TextView songCurrentDurationLabel;
private TextView songTotalDurationLabel;
// Media Player
private MediaPlayer mp;
// Handler to update UI timer, progress bar etc,.
private Handler mHandler = new Handler();;
private AudioPlayerManager songManager;
private Utilities utils;
private int seekForwardTime = 5000; // 5000 milliseconds
private int seekBackwardTime = 5000; // 5000 milliseconds
private int currentSongIndex = 0;
private boolean isShuffle = false;
private boolean isRepeat = false;
private ArrayList> songsList = new ArrayList>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_relaxationlv_audioplayer);
// All player buttons
btnPlay = (ImageButton) findViewById(R.id.btnPlay);
// btnForward = (ImageButton) findViewById(R.id.btnForward);
// btnBackward = (ImageButton) findViewById(R.id.btnBackward);
btnNext = (ImageButton) findViewById(R.id.btnNext);
btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
// btnRepeat = (ImageButton) findViewById(R.id.bt