android开源音乐播放器简单demo,Android开源在线音乐播放器——波尼音乐
波尼音樂
系列文章
前言
畢業設計作的項目,答辯完了,就共享出來。git
有問題請提Issues
若是喜歡,歡迎Star!
簡介
波尼音樂是一款開源Android在線音樂播放器。github
播放本地音樂與在線音樂
在線音樂排行榜,如熱歌榜、新歌榜等
高仿云音樂的黑膠唱片專輯封面
歌詞顯示,自動搜索歌詞
編輯歌曲信息
夜間模式
定時關閉
更新說明
v 1.3.0express
新增歌詞支持上下拖動
新增支持分屏模式
新增本地歌曲支持按大小和時長過濾
新增下載的歌曲文件自動添加專輯封面
新增編輯歌曲信息
新增5.0以上系統支持聯動系統媒體中心,鎖屏顯示播放信息
修復已知bug
v 1.2.3apache
新增通知欄播放控制
修復魅族手機掃描不到音樂的問題
修復已知bug
v 1.2.0canvas
修復在線音樂沒法加載的問題
修復弱網時播放網絡歌曲致使ANR的問題
修復每日啟動圖片沒法更新的問題
下載在線歌曲能夠顯示專輯封面了
修復已知bug
v 1.1.0api
支持 Android 6.0 運行時權限
修復已知bug
v 1.0.0緩存
First Release
下載地址
TODO
在線音樂能夠免下載加入個人音樂列表
在線音樂自動緩存
編輯音樂信息
項目
公開API
在線音樂:百度音樂
天氣數據:高德地圖
開源技術
關鍵代碼
黑膠唱片專輯封面繪制流程網絡
@Override
protected void onDraw(Canvas canvas) {
// 1.繪制頂部虛線
mTopLine.setBounds(0, 0, getWidth(), mTopLineHeight);
mTopLine.draw(canvas);
// 2.繪制黑膠唱片外側半透明邊框
mCoverBorder.setBounds(mDiscPoint.x - mCoverBorderWidth, mDiscPoint.y - mCoverBorderWidth,
mDiscPoint.x + mDiscBitmap.getWidth() + mCoverBorderWidth, mDiscPoint.y +
mDiscBitmap.getHeight() + mCoverBorderWidth);
mCoverBorder.draw(canvas);
// 3.繪制黑膠
// 設置旋轉中心和旋轉角度,setRotate和preTranslate順序很重要
mDiscMatrix.setRotate(mDiscRotation, mDiscCenterPoint.x, mDiscCenterPoint.y);
// 設置圖片起始坐標
mDiscMatrix.preTranslate(mDiscPoint.x, mDiscPoint.y);
canvas.drawBitmap(mDiscBitmap, mDiscMatrix, null);
// 4.繪制封面
mCoverMatrix.setRotate(mDiscRotation, mCoverCenterPoint.x, mCoverCenterPoint.y);
mCoverMatrix.preTranslate(mCoverPoint.x, mCoverPoint.y);
canvas.drawBitmap(mCoverBitmap, mCoverMatrix, null);
// 5.繪制指針
mNeedleMatrix.setRotate(mNeedleRotation, mNeedleCenterPoint.x, mNeedleCenterPoint.y);
mNeedleMatrix.preTranslate(mNeedlePoint.x, mNeedlePoint.y);
canvas.drawBitmap(mNeedleBitmap, mNeedleMatrix, null);
}
復制代碼
歌詞繪制流程app
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 中心Y坐標
float centerY = getHeight() / 2 + mTextSize / 2 + mAnimOffset;
// 無歌詞文件
if (!hasLrc()) {
float centerX = (getWidth() - mCurrentPaint.measureText(label)) / 2;
canvas.drawText(label, centerX, centerY, mCurrentPaint);
return;
}
// 畫當前行
String currStr = mLrcTexts.get(mCurrentLine);
float currX = (getWidth() - mCurrentPaint.measureText(currStr)) / 2;
canvas.drawText(currStr, currX, centerY, mCurrentPaint);
// 畫當前行上面的
for (int i = mCurrentLine - 1; i >= 0; i--) {
String upStr = mLrcTexts.get(i);
float upX = (getWidth() - mNormalPaint.measureText(upStr)) / 2;
float upY = centerY - (mTextSize + mDividerHeight) * (mCurrentLine - i);
// 超出屏幕中止繪制
if (upY - mTextSize < 0) {
break;
}
canvas.drawText(upStr, upX, upY, mNormalPaint);
}
// 畫當前行下面的
for (int i = mCurrentLine + 1; i < mLrcTimes.size(); i++) {
String downStr = mLrcTexts.get(i);
float downX = (getWidth() - mNormalPaint.measureText(downStr)) / 2;
float downY = centerY + (mTextSize + mDividerHeight) * (i - mCurrentLine);
// 超出屏幕中止繪制
if (downY > getHeight()) {
break;
}
canvas.drawText(downStr, downX, downY, mNormalPaint);
}
}
復制代碼
截圖
關于做者
License
Copyright 2016 wangchenyan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
復制代碼
遷移自個人簡書 2016.06.08
總結
以上是生活随笔為你收集整理的android开源音乐播放器简单demo,Android开源在线音乐播放器——波尼音乐的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网页实现凭证金额分割线_一位整理过500
- 下一篇: 后端:SpringBoot 的@Valu