播放页面数据解析
This commit is contained in:
parent
27158158fd
commit
77b8d09ca7
@ -51,9 +51,14 @@ dependencies {
|
|||||||
implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
|
implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
|
||||||
implementation("io.reactivex.rxjava2:rxjava:2.2.21")
|
implementation("io.reactivex.rxjava2:rxjava:2.2.21")
|
||||||
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
|
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
|
||||||
implementation ("com.squareup.okhttp3:logging-interceptor:4.11.0")
|
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
|
||||||
|
|
||||||
implementation ("androidx.paging:paging-runtime-ktx:3.3.2")
|
implementation("androidx.paging:paging-runtime-ktx:3.3.2")
|
||||||
|
|
||||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||||
|
|
||||||
|
//----------media3
|
||||||
|
implementation("androidx.media3:media3-exoplayer:1.4.1")
|
||||||
|
implementation("androidx.media3:media3-session:1.4.1")
|
||||||
|
//----------media3
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".MusicApplication"
|
android:name=".MusicApplication"
|
||||||
@ -23,19 +24,31 @@
|
|||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.HomeActivity"
|
android:name=".ui.activity.HomeActivity"
|
||||||
android:exported="false" />
|
android:exported="true" >
|
||||||
<activity
|
|
||||||
android:name=".ui.activity.MainActivity"
|
|
||||||
android:exported="false" />
|
|
||||||
<activity
|
|
||||||
android:name=".ui.activity.A_SplashActivity"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activity.MainActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activity.A_SplashActivity"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".media3.PlaybackService"
|
||||||
|
android:foregroundServiceType="mediaPlayback"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="androidx.media3.session.MediaSessionService"/>
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@ -2,7 +2,6 @@ package com.hi.music.player.adapter;
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.RoundedCorner;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -19,11 +18,8 @@ import com.bumptech.glide.request.target.Target;
|
|||||||
import com.hi.music.player.MusicApplication;
|
import com.hi.music.player.MusicApplication;
|
||||||
import com.hi.music.player.R;
|
import com.hi.music.player.R;
|
||||||
import com.hi.music.player.databinding.ItemCategoryBinding;
|
import com.hi.music.player.databinding.ItemCategoryBinding;
|
||||||
import com.hi.music.player.databinding.ItemHomeBinding;
|
|
||||||
import com.hi.music.player.databinding.ItemSingerBinding;
|
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.javabean.response.ResponseCategory;
|
import com.hi.music.player.javabean.response.child.ResponseCategory;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
|
||||||
|
|
||||||
public class AdapterCategory extends BaseAdapter<ResponseCategory, ItemCategoryBinding>{
|
public class AdapterCategory extends BaseAdapter<ResponseCategory, ItemCategoryBinding>{
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.hi.music.player.MusicApplication;
|
import com.hi.music.player.MusicApplication;
|
||||||
import com.hi.music.player.api.ClickSingerListener;
|
|
||||||
import com.hi.music.player.databinding.ItemFooterLoadingBinding;
|
import com.hi.music.player.databinding.ItemFooterLoadingBinding;
|
||||||
import com.hi.music.player.databinding.ItemHomeBinding;
|
import com.hi.music.player.databinding.ItemHomeBinding;
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.javabean.response.ResponseCategory;
|
import com.hi.music.player.javabean.response.child.ResponseCategory;
|
||||||
import com.hi.music.player.javabean.response.ResponseHomeChild;
|
import com.hi.music.player.javabean.response.child.ResponseHomeChild;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.hi.music.player.adapter;
|
package com.hi.music.player.adapter;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -19,12 +18,9 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.hi.music.player.MusicApplication;
|
import com.hi.music.player.MusicApplication;
|
||||||
import com.hi.music.player.R;
|
import com.hi.music.player.R;
|
||||||
import com.hi.music.player.databinding.ItemCategoryBinding;
|
|
||||||
import com.hi.music.player.databinding.ItemHomeBinding;
|
|
||||||
import com.hi.music.player.databinding.ItemSingerBinding;
|
import com.hi.music.player.databinding.ItemSingerBinding;
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.javabean.response.ResponseHomeChild;
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
|
||||||
|
|
||||||
public class AdapterSinger extends BaseAdapter<ResponseSingle, ItemSingerBinding> {
|
public class AdapterSinger extends BaseAdapter<ResponseSingle, ItemSingerBinding> {
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import androidx.viewbinding.ViewBinding;
|
|||||||
|
|
||||||
import com.hi.music.player.api.ClickSingerListener;
|
import com.hi.music.player.api.ClickSingerListener;
|
||||||
import com.hi.music.player.databinding.ItemFooterLoadingBinding;
|
import com.hi.music.player.databinding.ItemFooterLoadingBinding;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -17,11 +17,15 @@ public class CommonUtils {
|
|||||||
|
|
||||||
private static String TAG = "----MUSIC---------";
|
private static String TAG = "----MUSIC---------";
|
||||||
|
|
||||||
|
private static String TAG_ERROR = "----ERROR MUSIC---------";
|
||||||
|
|
||||||
public static void LogMsg(String msg) {
|
public static void LogMsg(String msg) {
|
||||||
Log.d(TAG, msg);
|
Log.d(TAG, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LogErrorMsg(String msg) {
|
||||||
|
Log.e(TAG_ERROR, msg);
|
||||||
|
}
|
||||||
|
|
||||||
public static JSONObject toJsonObject(ResponseBody body) {
|
public static JSONObject toJsonObject(ResponseBody body) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package com.hi.music.player.javabean.response;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.hi.music.player.javabean.response.child.ResponseHomeChild;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ResponseHome {
|
public class ResponseHome {
|
||||||
|
|||||||
@ -0,0 +1,108 @@
|
|||||||
|
package com.hi.music.player.javabean.response;
|
||||||
|
|
||||||
|
public class ResponsePlay {
|
||||||
|
|
||||||
|
//封面
|
||||||
|
private String covert;
|
||||||
|
//歌曲名字
|
||||||
|
private String SongTitle;
|
||||||
|
|
||||||
|
//歌手名字
|
||||||
|
private String SingerName;
|
||||||
|
|
||||||
|
//专辑名称
|
||||||
|
private String AlbumTitle;
|
||||||
|
|
||||||
|
//发行年份
|
||||||
|
private String Year;
|
||||||
|
|
||||||
|
//歌曲时长
|
||||||
|
private String Duration;
|
||||||
|
|
||||||
|
|
||||||
|
private String videoId;
|
||||||
|
private String playlistId;
|
||||||
|
private String params;
|
||||||
|
private String musicVideoType;
|
||||||
|
|
||||||
|
|
||||||
|
public String getDuration() {
|
||||||
|
return Duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(String duration) {
|
||||||
|
Duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCovert() {
|
||||||
|
return covert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCovert(String covert) {
|
||||||
|
this.covert = covert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSongTitle() {
|
||||||
|
return SongTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSongTitle(String songTitle) {
|
||||||
|
SongTitle = songTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSingerName() {
|
||||||
|
return SingerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSingerName(String singerName) {
|
||||||
|
SingerName = singerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlbumTitle() {
|
||||||
|
return AlbumTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlbumTitle(String albumTitle) {
|
||||||
|
AlbumTitle = albumTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return Year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(String year) {
|
||||||
|
Year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVideoId() {
|
||||||
|
return videoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoId(String videoId) {
|
||||||
|
this.videoId = videoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlaylistId() {
|
||||||
|
return playlistId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaylistId(String playlistId) {
|
||||||
|
this.playlistId = playlistId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(String params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMusicVideoType() {
|
||||||
|
return musicVideoType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMusicVideoType(String musicVideoType) {
|
||||||
|
this.musicVideoType = musicVideoType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.hi.music.player.javabean.response;
|
package com.hi.music.player.javabean.response.child;
|
||||||
|
|
||||||
public class ResponseCategory {
|
public class ResponseCategory {
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.hi.music.player.javabean.response;
|
package com.hi.music.player.javabean.response.child;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.hi.music.player.javabean.response;
|
package com.hi.music.player.javabean.response.child;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.hi.music.player.media3;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
|
||||||
|
import androidx.media3.common.MediaItem;
|
||||||
|
import androidx.media3.session.MediaController;
|
||||||
|
import androidx.media3.session.SessionToken;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import com.hi.music.player.MusicApplication;
|
||||||
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
|
import com.hi.music.player.network.RetrofitManager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
public class MyMediaController {
|
||||||
|
|
||||||
|
private static volatile MyMediaController MyMediaControllerInstance;
|
||||||
|
|
||||||
|
private MediaController mediaController;
|
||||||
|
public static MyMediaController getInstance() {
|
||||||
|
if (MyMediaControllerInstance == null) {
|
||||||
|
synchronized (RetrofitManager.class) {
|
||||||
|
if (MyMediaControllerInstance == null) {
|
||||||
|
MyMediaControllerInstance = new MyMediaController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MyMediaControllerInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(){
|
||||||
|
SessionToken sessionToken =
|
||||||
|
new SessionToken(MusicApplication.myApplication, new ComponentName(MusicApplication.myApplication, PlaybackService.class));
|
||||||
|
ListenableFuture<MediaController> controllerFuture =
|
||||||
|
new MediaController.Builder(MusicApplication.myApplication, sessionToken).buildAsync();
|
||||||
|
controllerFuture.addListener(() -> {
|
||||||
|
// Call controllerFuture.get() to retrieve the MediaController.
|
||||||
|
// MediaController implements the Player interface, so it can be
|
||||||
|
// attached to the PlayerView UI component.
|
||||||
|
// playerView.setPlayer(controllerFuture.get());
|
||||||
|
try {
|
||||||
|
mediaController = controllerFuture.get();
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
CommonUtils.LogErrorMsg(e.getMessage());
|
||||||
|
}
|
||||||
|
}, MoreExecutors.directExecutor());
|
||||||
|
|
||||||
|
|
||||||
|
List<MediaItem> mediaItems = new ArrayList<>();
|
||||||
|
mediaController.addMediaItems(mediaItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.hi.music.player.media3;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
|
import androidx.media3.session.MediaSession;
|
||||||
|
import androidx.media3.session.MediaSessionService;
|
||||||
|
|
||||||
|
public class PlaybackService extends MediaSessionService {
|
||||||
|
private MediaSession mediaSession = null;
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
ExoPlayer player = new ExoPlayer.Builder(this).build();
|
||||||
|
mediaSession = new MediaSession.Builder(this, player).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public MediaSession onGetSession(MediaSession.ControllerInfo controllerInfo) {
|
||||||
|
return mediaSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
mediaSession.getPlayer().release();
|
||||||
|
mediaSession.release();
|
||||||
|
mediaSession = null;
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,16 +1,18 @@
|
|||||||
package com.hi.music.player.network;
|
package com.hi.music.player.network;
|
||||||
|
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.javabean.response.ResponseCategory;
|
import com.hi.music.player.javabean.response.ResponsePlay;
|
||||||
|
import com.hi.music.player.javabean.response.child.ResponseCategory;
|
||||||
import com.hi.music.player.javabean.response.ResponseHome;
|
import com.hi.music.player.javabean.response.ResponseHome;
|
||||||
import com.hi.music.player.javabean.response.ResponseHomeChild;
|
import com.hi.music.player.javabean.response.child.ResponseHomeChild;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JsonHelper {
|
public class JsonHelper {
|
||||||
@ -76,6 +78,65 @@ public class JsonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<ResponsePlay> ResolvePlayJson(JSONObject jsonObject) {
|
||||||
|
List<ResponsePlay> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
JSONObject playlistPanelRenderer = jsonObject.getJSONObject("contents")
|
||||||
|
.getJSONObject("singleColumnMusicWatchNextResultsRenderer")
|
||||||
|
.getJSONObject("tabbedRenderer")
|
||||||
|
.getJSONObject("watchNextTabbedResultsRenderer")
|
||||||
|
.getJSONArray("tabs")
|
||||||
|
.getJSONObject(0)
|
||||||
|
.getJSONObject("tabRenderer")
|
||||||
|
.getJSONObject("content")
|
||||||
|
.getJSONObject("musicQueueRenderer")
|
||||||
|
.getJSONObject("content")
|
||||||
|
.getJSONObject("playlistPanelRenderer");
|
||||||
|
|
||||||
|
JSONArray contents = playlistPanelRenderer.getJSONArray("contents");
|
||||||
|
|
||||||
|
for (int i = 0; i < contents.length(); i++) {
|
||||||
|
ResponsePlay responsePlay = new ResponsePlay();
|
||||||
|
JSONObject playlistPanelVideoRenderer = contents.getJSONObject(i)
|
||||||
|
.getJSONObject("playlistPanelVideoRenderer");
|
||||||
|
|
||||||
|
String jsonUrl = getJsonUrl(playlistPanelVideoRenderer);
|
||||||
|
String songName = getJsonTitle(playlistPanelVideoRenderer.getJSONObject("title"), 0);
|
||||||
|
|
||||||
|
JSONObject longBylineText = playlistPanelVideoRenderer.getJSONObject("longBylineText");
|
||||||
|
String singerName = getJsonTitle(longBylineText, 0);
|
||||||
|
String AlbumTitle = getJsonTitle(longBylineText, 2);
|
||||||
|
String YearRelease = getJsonTitle(longBylineText, 4);
|
||||||
|
|
||||||
|
String SongDuration = getJsonTitle(playlistPanelVideoRenderer.getJSONObject("lengthText"), 0);
|
||||||
|
|
||||||
|
String[] watchEndPoint = getWatchEndPoint(playlistPanelVideoRenderer);
|
||||||
|
|
||||||
|
responsePlay.setCovert(jsonUrl);
|
||||||
|
responsePlay.setSongTitle(songName);
|
||||||
|
responsePlay.setSingerName(singerName);
|
||||||
|
responsePlay.setAlbumTitle(AlbumTitle);
|
||||||
|
responsePlay.setYear(YearRelease);
|
||||||
|
responsePlay.setDuration(SongDuration);
|
||||||
|
responsePlay.setVideoId(watchEndPoint[0]);
|
||||||
|
responsePlay.setPlaylistId(watchEndPoint[1]);
|
||||||
|
responsePlay.setParams(watchEndPoint[2]);
|
||||||
|
responsePlay.setMusicVideoType(watchEndPoint[3]);
|
||||||
|
|
||||||
|
list.add(responsePlay);
|
||||||
|
CommonUtils.LogMsg("----------歌曲名字=" + songName + "---" + Arrays.toString(watchEndPoint));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (JSONException exception) {
|
||||||
|
CommonUtils.LogMsg("----------exception=");
|
||||||
|
exception.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void getCommonHome(JSONObject sectionListRenderer, ResponseHome responseHome) throws JSONException {
|
private static void getCommonHome(JSONObject sectionListRenderer, ResponseHome responseHome) throws JSONException {
|
||||||
|
|
||||||
|
|
||||||
@ -106,10 +167,10 @@ public class JsonHelper {
|
|||||||
if (musicCarouselShelfRenderer != null) {
|
if (musicCarouselShelfRenderer != null) {
|
||||||
|
|
||||||
//模块标题
|
//模块标题
|
||||||
String title = getJsonText(musicCarouselShelfRenderer
|
String title = getJsonTitle(musicCarouselShelfRenderer
|
||||||
.getJSONObject("header")
|
.getJSONObject("header")
|
||||||
.getJSONObject("musicCarouselShelfBasicHeaderRenderer")
|
.getJSONObject("musicCarouselShelfBasicHeaderRenderer")
|
||||||
.getJSONObject("title"));
|
.getJSONObject("title"), 0);
|
||||||
CommonUtils.LogMsg("----------headertitle=" + title);
|
CommonUtils.LogMsg("----------headertitle=" + title);
|
||||||
responseHomeChild.setHeaderTitle(title);
|
responseHomeChild.setHeaderTitle(title);
|
||||||
JSONArray childContents = musicCarouselShelfRenderer
|
JSONArray childContents = musicCarouselShelfRenderer
|
||||||
@ -139,25 +200,19 @@ public class JsonHelper {
|
|||||||
.getJSONObject(g)
|
.getJSONObject(g)
|
||||||
.getJSONObject("musicResponsiveListItemFlexColumnRenderer")
|
.getJSONObject("musicResponsiveListItemFlexColumnRenderer")
|
||||||
.getJSONObject("text");
|
.getJSONObject("text");
|
||||||
String text = getJsonText(jsonObject);
|
String text = getJsonTitle(jsonObject, 0);
|
||||||
if (g == 0) {
|
if (g == 0) {
|
||||||
SongTitle = text;
|
SongTitle = text;
|
||||||
|
|
||||||
JSONObject watchEndpoint = jsonObject.getJSONArray("runs")
|
JSONObject runs = jsonObject.getJSONArray("runs")
|
||||||
.getJSONObject(0)
|
.getJSONObject(0);
|
||||||
.getJSONObject("navigationEndpoint")
|
|
||||||
.getJSONObject("watchEndpoint");
|
|
||||||
String videoId = watchEndpoint.getString("videoId");
|
|
||||||
String playlistId = watchEndpoint.getString("playlistId");
|
|
||||||
String params = watchEndpoint.getString("params");
|
|
||||||
String musicVideoType = watchEndpoint.getJSONObject("watchEndpointMusicSupportedConfigs")
|
|
||||||
.getJSONObject("watchEndpointMusicConfig")
|
|
||||||
.getString("musicVideoType");
|
|
||||||
|
|
||||||
responseSingle.setVideoId(videoId);
|
String[] watchEndPoint = getWatchEndPoint(runs);
|
||||||
responseSingle.setPlaylistId(playlistId);
|
|
||||||
responseSingle.setParams(params);
|
responseSingle.setVideoId(watchEndPoint[0]);
|
||||||
responseSingle.setMusicVideoType(musicVideoType);
|
responseSingle.setPlaylistId(watchEndPoint[1]);
|
||||||
|
responseSingle.setParams(watchEndPoint[2]);
|
||||||
|
responseSingle.setMusicVideoType(watchEndPoint[3]);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (g == 1) SingerName = text;
|
if (g == 1) SingerName = text;
|
||||||
@ -178,7 +233,7 @@ public class JsonHelper {
|
|||||||
.getJSONObject("thumbnailRenderer"));
|
.getJSONObject("thumbnailRenderer"));
|
||||||
|
|
||||||
JSONObject title1 = musicTwoRowItemRenderer.getJSONObject("title");
|
JSONObject title1 = musicTwoRowItemRenderer.getJSONObject("title");
|
||||||
String twoTitle = getJsonText(title1);
|
String twoTitle = getJsonTitle(title1, 0);
|
||||||
String twoSubtitle = getJsonTextNew(musicTwoRowItemRenderer.getJSONObject("subtitle"));
|
String twoSubtitle = getJsonTextNew(musicTwoRowItemRenderer.getJSONObject("subtitle"));
|
||||||
// String pageType = title1.getJSONObject("navigationEndpoint")
|
// String pageType = title1.getJSONObject("navigationEndpoint")
|
||||||
// .getJSONObject("browseEndpoint")
|
// .getJSONObject("browseEndpoint")
|
||||||
@ -190,7 +245,7 @@ public class JsonHelper {
|
|||||||
responseCategory.setTwoTitle(twoTitle);
|
responseCategory.setTwoTitle(twoTitle);
|
||||||
responseCategory.setTwoSubtitle(twoSubtitle);
|
responseCategory.setTwoSubtitle(twoSubtitle);
|
||||||
categoryList.add(responseCategory);
|
categoryList.add(responseCategory);
|
||||||
CommonUtils.LogMsg(" ----------2222222222----twoTitle=" + twoTitle + "-twoSubtitle=" + twoSubtitle );
|
CommonUtils.LogMsg(" ----------2222222222----twoTitle=" + twoTitle + "-twoSubtitle=" + twoSubtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,12 +259,50 @@ public class JsonHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String[] getWatchEndPoint(JSONObject job) {
|
||||||
|
|
||||||
|
String[] strings = new String[4];
|
||||||
|
try {
|
||||||
|
JSONObject watchEndpoint = job
|
||||||
|
.getJSONObject("navigationEndpoint")
|
||||||
|
.getJSONObject("watchEndpoint");
|
||||||
|
if (watchEndpoint.has("videoId")) {
|
||||||
|
strings[0] = watchEndpoint.getString("videoId");
|
||||||
|
}
|
||||||
|
if (watchEndpoint.has("playlistId")) {
|
||||||
|
strings[1] = watchEndpoint.getString("playlistId");
|
||||||
|
}
|
||||||
|
if (watchEndpoint.has("params")) {
|
||||||
|
strings[2] = watchEndpoint.getString("params");
|
||||||
|
}
|
||||||
|
if (watchEndpoint.has("watchEndpointMusicSupportedConfigs")) {
|
||||||
|
strings[3] = watchEndpoint.getJSONObject("watchEndpointMusicSupportedConfigs")
|
||||||
|
.getJSONObject("watchEndpointMusicConfig")
|
||||||
|
.getString("musicVideoType");
|
||||||
|
}
|
||||||
|
// String videoId = watchEndpoint.getString("videoId");
|
||||||
|
// String playlistId = watchEndpoint.getString("playlistId");
|
||||||
|
// String params = watchEndpoint.getString("params");
|
||||||
|
// String musicVideoType = watchEndpoint.getJSONObject("watchEndpointMusicSupportedConfigs")
|
||||||
|
// .getJSONObject("watchEndpointMusicConfig")
|
||||||
|
// .getString("musicVideoType");
|
||||||
|
} catch (JSONException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
//取最大的一张图片
|
||||||
private static String getJsonUrl(JSONObject jsonObject) {
|
private static String getJsonUrl(JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
JSONArray jsonArray = jsonObject.getJSONObject("musicThumbnailRenderer")
|
boolean b = jsonObject.has("musicThumbnailRenderer");
|
||||||
|
if (b) {
|
||||||
|
jsonObject = jsonObject.getJSONObject("musicThumbnailRenderer");
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = jsonObject
|
||||||
.getJSONObject("thumbnail")
|
.getJSONObject("thumbnail")
|
||||||
.getJSONArray("thumbnails");
|
.getJSONArray("thumbnails");
|
||||||
|
|
||||||
int length = jsonArray.length();
|
int length = jsonArray.length();
|
||||||
CommonUtils.LogMsg("----------length=" + (length - 1));
|
CommonUtils.LogMsg("----------length=" + (length - 1));
|
||||||
String pngUrl = jsonArray.getJSONObject(length - 1)
|
String pngUrl = jsonArray.getJSONObject(length - 1)
|
||||||
@ -222,24 +315,28 @@ public class JsonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getJsonText(JSONObject jsonObject) {
|
private static String getJsonTitle(JSONObject jsonObject, int index) {
|
||||||
|
String text = "";
|
||||||
try {
|
try {
|
||||||
String text = jsonObject.getJSONArray("runs")
|
JSONArray runs = jsonObject.getJSONArray("runs");
|
||||||
.getJSONObject(0)
|
if (index < runs.length()) {
|
||||||
|
text = runs
|
||||||
|
.getJSONObject(index)
|
||||||
.getString("text");
|
.getString("text");
|
||||||
|
|
||||||
return text;
|
|
||||||
} catch (JSONException exception) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (JSONException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getJsonTextNew(JSONObject jsonObject) {
|
private static String getJsonTextNew(JSONObject jsonObject) {
|
||||||
StringBuilder text= new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
JSONArray runs = jsonObject.getJSONArray("runs");
|
JSONArray runs = jsonObject.getJSONArray("runs");
|
||||||
for (int i =0;i<runs.length();i++){
|
for (int i = 0; i < runs.length(); i++) {
|
||||||
String text1 = runs.getJSONObject(i).getString("text");
|
String text1 = runs.getJSONObject(i).getString("text");
|
||||||
text.append(text1);
|
text.append(text1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,37 @@
|
|||||||
package com.hi.music.player.ui.activity;
|
package com.hi.music.player.ui.activity;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.View;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.media3.session.MediaController;
|
||||||
|
import androidx.media3.session.SessionToken;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.DataSource;
|
||||||
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import com.hi.music.player.MusicApplication;
|
||||||
|
import com.hi.music.player.R;
|
||||||
import com.hi.music.player.databinding.ActivityPlayBinding;
|
import com.hi.music.player.databinding.ActivityPlayBinding;
|
||||||
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.helper.MyValue;
|
import com.hi.music.player.helper.MyValue;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.ResponsePlay;
|
||||||
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
|
import com.hi.music.player.media3.PlaybackService;
|
||||||
import com.hi.music.player.ui.activity.viewmodel.VMPlay;
|
import com.hi.music.player.ui.activity.viewmodel.VMPlay;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class PlayActivity extends BaseActivity<ActivityPlayBinding> {
|
public class PlayActivity extends BaseActivity<ActivityPlayBinding> {
|
||||||
|
|
||||||
|
|
||||||
@ -24,17 +48,58 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> {
|
|||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
responseSingle = (ResponseSingle) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER);
|
responseSingle = (ResponseSingle) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER);
|
||||||
vmPlay = getActivityScopeViewModel(VMPlay.class);
|
vmPlay = getActivityScopeViewModel(VMPlay.class);
|
||||||
|
|
||||||
|
|
||||||
vb.btn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
vmPlay.getPlay(responseSingle);
|
vmPlay.getPlay(responseSingle);
|
||||||
|
|
||||||
|
vmPlay.data.observe(this, new Observer<List<ResponsePlay>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<ResponsePlay> playList) {
|
||||||
|
if (playList.size() > 0) {
|
||||||
|
ResponsePlay responsePlay = playList.get(0);
|
||||||
|
loadCovert(responsePlay.getCovert());
|
||||||
|
loadInfo(responsePlay);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadInfo(ResponsePlay data) {
|
||||||
|
vb.tvSongName.setText(data.getSongTitle());
|
||||||
|
vb.tvSingerName.setText(data.getSingerName());
|
||||||
|
vb.tvDuration.setText(data.getDuration());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCovert(String url) {
|
||||||
|
Glide.with(MusicApplication.myApplication)
|
||||||
|
.asDrawable()
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(16))))
|
||||||
|
.load(url)
|
||||||
|
.placeholder(R.mipmap.ic_launcher)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
CommonUtils.LogMsg(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into(vb.imCovert);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFullScreen() {
|
public boolean isFullScreen() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -7,19 +7,22 @@ import androidx.lifecycle.ViewModel;
|
|||||||
import com.hi.music.player.api.RequestListener;
|
import com.hi.music.player.api.RequestListener;
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.javabean.response.ResponseHome;
|
import com.hi.music.player.javabean.response.ResponseHome;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.ResponsePlay;
|
||||||
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
import com.hi.music.player.network.JsonHelper;
|
import com.hi.music.player.network.JsonHelper;
|
||||||
import com.hi.music.player.network.RetrofitManager;
|
import com.hi.music.player.network.RetrofitManager;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class VMPlay extends ViewModel {
|
public class VMPlay extends ViewModel {
|
||||||
|
|
||||||
|
|
||||||
private MutableLiveData<ResponseHome> _data = new MutableLiveData<ResponseHome>();
|
private MutableLiveData<List<ResponsePlay>> _data = new MutableLiveData<List<ResponsePlay>>();
|
||||||
public LiveData<ResponseHome> data = _data;
|
public LiveData<List<ResponsePlay>> data = _data;
|
||||||
|
|
||||||
private String continuation, clickTrackingParams, visitorData;
|
private String continuation, clickTrackingParams, visitorData;
|
||||||
|
|
||||||
@ -29,7 +32,7 @@ public class VMPlay extends ViewModel {
|
|||||||
String params = responseSingle.getParams();
|
String params = responseSingle.getParams();
|
||||||
String musicVideoType = responseSingle.getMusicVideoType();
|
String musicVideoType = responseSingle.getMusicVideoType();
|
||||||
|
|
||||||
RetrofitManager.getInstance().getNext(params,playlistId,videoId,musicVideoType,new RequestListener<ResponseBody>() {
|
RetrofitManager.getInstance().getNext(params, playlistId, videoId, musicVideoType, new RequestListener<ResponseBody>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFail(String errorMsg) {
|
public void onFail(String errorMsg) {
|
||||||
@ -40,9 +43,8 @@ public class VMPlay extends ViewModel {
|
|||||||
public void onSuccess(ResponseBody data) {
|
public void onSuccess(ResponseBody data) {
|
||||||
JSONObject jsonObject = CommonUtils.toJsonObject(data);
|
JSONObject jsonObject = CommonUtils.toJsonObject(data);
|
||||||
if (jsonObject != null) {
|
if (jsonObject != null) {
|
||||||
|
List<ResponsePlay> responsePlays = JsonHelper.ResolvePlayJson(jsonObject);
|
||||||
|
_data.setValue(responsePlays);
|
||||||
// _data.setValue(responseHome);
|
|
||||||
} else {
|
} else {
|
||||||
_data.setValue(null);
|
_data.setValue(null);
|
||||||
}
|
}
|
||||||
@ -52,6 +54,4 @@ public class VMPlay extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,15 +8,14 @@ import androidx.lifecycle.Observer;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.hi.music.player.R;
|
|
||||||
import com.hi.music.player.adapter.AdapterHome;
|
import com.hi.music.player.adapter.AdapterHome;
|
||||||
import com.hi.music.player.api.ClickSingerListener;
|
import com.hi.music.player.api.ClickSingerListener;
|
||||||
import com.hi.music.player.databinding.FragmentHomeBinding;
|
import com.hi.music.player.databinding.FragmentHomeBinding;
|
||||||
import com.hi.music.player.helper.CommonUtils;
|
import com.hi.music.player.helper.CommonUtils;
|
||||||
import com.hi.music.player.helper.MyValue;
|
import com.hi.music.player.helper.MyValue;
|
||||||
import com.hi.music.player.javabean.response.ResponseHome;
|
import com.hi.music.player.javabean.response.ResponseHome;
|
||||||
import com.hi.music.player.javabean.response.ResponseHomeChild;
|
import com.hi.music.player.javabean.response.child.ResponseHomeChild;
|
||||||
import com.hi.music.player.javabean.response.ResponseSingle;
|
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||||
import com.hi.music.player.ui.activity.PlayActivity;
|
import com.hi.music.player.ui.activity.PlayActivity;
|
||||||
import com.hi.music.player.ui.fragmnt.viewmodel.VMHome;
|
import com.hi.music.player.ui.fragmnt.viewmodel.VMHome;
|
||||||
|
|
||||||
|
|||||||
35
app/src/main/res/drawable/arrow_bottom.xml
Normal file
35
app/src/main/res/drawable/arrow_bottom.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="20dp"
|
||||||
|
android:height="20dp"
|
||||||
|
android:viewportWidth="20"
|
||||||
|
android:viewportHeight="20">
|
||||||
|
<path
|
||||||
|
android:pathData="M0,0h20v20h-20z"
|
||||||
|
android:fillColor="@color/color_transparent"/>
|
||||||
|
<group>
|
||||||
|
<clip-path
|
||||||
|
android:pathData="M-27,-60h375v812h-375z"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M-27,-60h375v812h-375z"
|
||||||
|
android:fillColor="@color/color_transparent"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M-27,-60h375v812h-375z"
|
||||||
|
android:fillColor="@color/color_transparent" />
|
||||||
|
<path
|
||||||
|
android:pathData="M-27,-60h375v812h-375z"
|
||||||
|
android:fillColor="@color/color_transparent" />
|
||||||
|
<path
|
||||||
|
android:pathData="M10,-12L10,-12A21,21 0,0 1,31 9L31,9A21,21 0,0 1,10 30L10,30A21,21 0,0 1,-11 9L-11,9A21,21 0,0 1,10 -12z"
|
||||||
|
android:fillColor="@color/color_transparent" />
|
||||||
|
<path
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:pathData="M10,-11.5L10,-11.5A20.5,20.5 0,0 1,30.5 9L30.5,9A20.5,20.5 0,0 1,10 29.5L10,29.5A20.5,20.5 0,0 1,-10.5 9L-10.5,9A20.5,20.5 0,0 1,10 -11.5z"
|
||||||
|
android:fillColor="@color/color_transparent" />
|
||||||
|
<path
|
||||||
|
android:pathData="M15.834,7.083L10,12.917L4.167,7.083"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:strokeColor="#ffffff"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
18
app/src/main/res/drawable/seekbar_progress_drawable.xml
Normal file
18
app/src/main/res/drawable/seekbar_progress_drawable.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/seek_bg_color" />
|
||||||
|
<corners android:radius="3dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<scale android:scaleWidth="100%">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
<corners android:radius="3dp" />
|
||||||
|
</shape>
|
||||||
|
</scale>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
10
app/src/main/res/drawable/seekbar_thumb.xml
Normal file
10
app/src/main/res/drawable/seekbar_thumb.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
|
||||||
|
<size
|
||||||
|
android:width="13dp"
|
||||||
|
android:height="13dp" />
|
||||||
|
|
||||||
|
</shape>
|
||||||
6
app/src/main/res/drawable/selector_icon_play.xml
Normal file
6
app/src/main/res/drawable/selector_icon_play.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_selected="false" android:drawable="@mipmap/icon_pause"/>
|
||||||
|
<item android:state_selected="true" android:drawable="@mipmap/icon_play"/>
|
||||||
|
|
||||||
|
</selector>
|
||||||
@ -4,14 +4,131 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"
|
||||||
tools:context=".ui.activity.PlayActivity">
|
tools:context=".ui.activity.PlayActivity">
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<ImageView
|
||||||
android:id="@+id/btn"
|
android:id="@+id/im_back"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="42dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="42dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:padding="9dp"
|
||||||
|
android:src="@drawable/arrow_bottom"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/im_covert"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="300dp"
|
||||||
|
android:layout_marginStart="40dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginEnd="40dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/im_back" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_song_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textColor="@color/text_color_1"
|
||||||
|
android:textSize="19sp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="@id/im_covert"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/im_covert" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_singer_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textColor="@color/white_60_color"
|
||||||
|
android:textSize="13sp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="@id/tv_song_name"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_song_name" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekbar"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:maxHeight="3dp"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:paddingRight="0dp"
|
||||||
|
android:progress="10"
|
||||||
|
android:progressDrawable="@drawable/seekbar_progress_drawable"
|
||||||
|
android:thumb="@drawable/seekbar_thumb"
|
||||||
|
app:layout_constraintLeft_toLeftOf="@id/im_covert"
|
||||||
|
app:layout_constraintRight_toRightOf="@id/im_covert"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_singer_name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_current"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="1:23"
|
||||||
|
android:textColor="@color/white_60_color"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/seekbar"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/seekbar" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="1:23"
|
||||||
|
android:textColor="@color/white_60_color"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/seekbar"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/seekbar" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_play"
|
||||||
|
android:layout_width="66dp"
|
||||||
|
android:layout_height="66dp"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:src="@drawable/selector_icon_play"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_duration" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_previous"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginEnd="36dp"
|
||||||
|
android:src="@mipmap/icon_previous_true"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/btn_play"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/btn_play"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/btn_play" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_next"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="36dp"
|
||||||
|
android:src="@mipmap/icon_next_true"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/btn_play"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/btn_play"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/btn_play" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_music_list"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginBottom="40dp"
|
||||||
|
android:src="@mipmap/icon_list"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="@id/im_covert" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
BIN
app/src/main/res/mipmap-xxxhdpi/icon_list.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_list.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 669 B |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_next_true.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_next_true.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 638 B |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_pause.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_pause.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_play.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_play.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_previous_true.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_previous_true.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 663 B |
@ -2,6 +2,10 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="color_transparent">#00000000</color>
|
||||||
<color name="text_color_1">#FFFFFF</color>
|
<color name="text_color_1">#FFFFFF</color>
|
||||||
<color name="text_color_2">#DFD0D0</color>
|
<color name="text_color_2">#DFD0D0</color>
|
||||||
|
|
||||||
|
<color name="seek_bg_color">#4DFFFFFF</color>
|
||||||
|
<color name="white_60_color">#99FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue
Block a user