Skip to content

Commit

Permalink
兼容4.4机器某些情况下的崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
lizixian committed Mar 1, 2019
1 parent a5b0d78 commit 9f5b75c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,21 @@ demo 代码请点击这里 [NiceMusic](https://github.com/lizixian18/NiceMusic)


## QQ群

微信同号

<a href="art/qq_qun.jpg"><img src="art/qq_qun.jpg" width="30%"/></a>

<br><br>



你的打赏是我的动力,愿意的话可以佛性打赏,我会非常开心。

<a href="art/biaoqing.gif"><img src="art/biaoqing.gif"/></a>
<a href="art/WechatIMG1.jpeg"><img src="art/WechatIMG1.jpeg" width="30%"/></a>


## 关于我

An android developer in GuangZhou
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lzx/musiclib/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void onCreate(Bundle savedInstanceState) {

SongInfo s1 = new SongInfo();
s1.setSongId("111");
s1.setSongUrl("http://music.163.com/song/media/outer/url?id=317151.mp3");
s1.setSongUrl("http://music.163.com/song/media/outer/url?id=317151.mp3&a=我");
s1.setSongCover("https://www.qqkw.com/d/file/p/2018/04-21/c24fd86006670f964e63cb8f9c129fc6.jpg");
s1.setSongName("心雨");
s1.setArtist("贤哥");
Expand Down
Binary file added art/WechatIMG1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/biaoqing.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ public void play(QueueItem item) {
MediaMetadataCompat track = mMusicProvider.getMusic(item.getDescription().getMediaId());

String source = track.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI);
if (source != null) {
source = source.replaceAll(" ", "%20"); // Escape spaces for URLs
if (TextUtils.isEmpty(source)) {
return;
}
source = source.replaceAll(" ", "%20"); // Escape spaces for URLs
//缓存歌曲
if (ExoDownload.getInstance().isOpenCache()) {
ExoDownload.getInstance().getDownloadTracker().toggleDownload(mediaId, Uri.parse(source), "");
}

if (mExoPlayer == null) {
//轨道选择
TrackSelection.Factory trackSelectionFactory;
Expand Down Expand Up @@ -211,7 +213,7 @@ public void play(QueueItem item) {
mExoPlayer.setAudioAttributes(audioAttributes, true); //第二个参数能使ExoPlayer自动管理焦点

DataSource.Factory dataSourceFactory = ExoDownload.getInstance().buildDataSourceFactory(mContext);
//buildDataSourceFactory();

MediaSource mediaSource = buildMediaSource(dataSourceFactory, Uri.parse(source), null);

mExoPlayer.prepare(mediaSource);
Expand Down

0 comments on commit 9f5b75c

Please sign in to comment.