An Android online music player like NetEase Cloud Music
后续可能会根据大家的反馈增加或调整功能
欢迎大家体验,如果发现功能问题或兼容性问题,可以提 GitHub Issue
其实有一些同仁已经将网易云 API 服务部署到公网了,我们可以直接用🐶。
这里不方便直接贴地址,下面教大家如何找到可以用的服务:
用 Google 搜索「网易云音乐API」,点击搜索结果链接,如果页面打开后是下图这样(注意:非作者的 github.io 页面),恭喜!你找到了可以直接使用的服务,拷贝地址栏链接,输入到步骤3即可。
如果设置域名后 APP 接口报错,说明这个域名不可用,可以尝试其他结果。
2.1.0
2.0.0
1.3.0
1.2.3
1.2.0
1.1.0
1.0.0
站在巨人的肩膀上
黑胶唱片专辑封面绘制流程
override fun onDraw(canvas: Canvas) {
// 1.绘制封面
val cover = coverBitmap
if (cover != null) {
coverMatrix.setRotate(discRotation, coverCenterPoint.x.toFloat(), coverCenterPoint.y.toFloat())
coverMatrix.preTranslate(coverStartPoint.x.toFloat(), coverStartPoint.y.toFloat())
coverMatrix.preScale(coverSize.toFloat() / cover.width, coverSize.toFloat() / cover.height)
canvas.drawBitmap(cover, coverMatrix, null)
}
// 2.绘制黑胶唱片外侧半透明边框
coverBorder.setBounds(
discStartPoint.x - COVER_BORDER_WIDTH,
discStartPoint.y - COVER_BORDER_WIDTH,
discStartPoint.x + discBitmap.width + COVER_BORDER_WIDTH,
discStartPoint.y + discBitmap.height + COVER_BORDER_WIDTH
)
coverBorder.draw(canvas)
// 3.绘制黑胶
// 设置旋转中心和旋转角度,setRotate和preTranslate顺序很重要
discMatrix.setRotate(discRotation, discCenterPoint.x.toFloat(),discCenterPoint.y.toFloat())
// 设置图片起始坐标
discMatrix.preTranslate(discStartPoint.x.toFloat(), discStartPoint.y.toFloat())
canvas.drawBitmap(discBitmap, discMatrix, null)
// 4.绘制指针
needleMatrix.setRotate(needleRotation, needleCenterPoint.x.toFloat(), needleCenterPoint.y.toFloat())
needleMatrix.preTranslate(needleStartPoint.x.toFloat(), needleStartPoint.y.toFloat())
canvas.drawBitmap(needleBitmap, needleMatrix, null)
}
歌词绘制流程
@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);
}
}
掘金: https://juejin.im/user/2313028193754168
微博: https://weibo.com/wangchenyan1993
Copyright 2023 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.