update
This commit is contained in:
parent
7704be296d
commit
4daa74c16b
@ -36,7 +36,6 @@ dependencies {
|
||||
implementation 'com.alibaba:fastjson:1.1.72.android'
|
||||
//noinspection GradleCompatible
|
||||
implementation 'com.android.support:support-media-compat:28.0.0'
|
||||
|
||||
|
||||
implementation 'androidx.palette:palette:1.0.0'
|
||||
|
||||
}
|
@ -19,8 +19,12 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".views.MainActivity" />
|
||||
<service android:name=".services.MusicService">
|
||||
<activity android:name=".views.MainActivity"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
android:fitsSystemWindows="true"
|
||||
/>
|
||||
<service android:name=".services.MusicService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.media.browse.MediaBrowserService" />
|
||||
</intent-filter>
|
||||
|
@ -3,6 +3,7 @@ package com.yutou.nas_music_player.containers;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -10,6 +11,8 @@ import com.yutou.nas_music_player.Interfaces.NetworkInterface;
|
||||
import com.yutou.nas_music_player.tools.NetworkTool;
|
||||
import com.yutou.nas_music_player.tools.StringUtil;
|
||||
|
||||
import androidx.palette.graphics.Palette;
|
||||
|
||||
public class MusicData {
|
||||
private String artist;//艺术家
|
||||
private String album;//专辑
|
||||
@ -172,4 +175,10 @@ public class MusicData {
|
||||
});
|
||||
return img;
|
||||
}
|
||||
public int getImageColor(){
|
||||
if(img==null){
|
||||
return -1;
|
||||
}
|
||||
return Palette.from(img).generate().getLightVibrantColor(Color.parseColor("#6DE1A1"));
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package com.yutou.nas_music_player.views;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.media.MediaMetadataCompat;
|
||||
import android.support.v4.media.session.MediaControllerCompat;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.MediaController;
|
||||
@ -15,6 +17,7 @@ import android.widget.MediaController;
|
||||
import com.yutou.nas_music_player.R;
|
||||
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
|
||||
import com.yutou.nas_music_player.containers.MusicContainer;
|
||||
import com.yutou.nas_music_player.containers.MusicData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -26,6 +29,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setBarColor(android.R.color.transparent);
|
||||
setContentView(R.layout.activity_main);
|
||||
MusicContainer.getInstance();
|
||||
play = findViewById(R.id.play);
|
||||
@ -47,13 +51,20 @@ public class MainActivity extends AppCompatActivity {
|
||||
previous.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
MusicData data=MusicContainer.getInstance().getNowPlayData();
|
||||
if(data!=null){
|
||||
setBarColor(data.getImageColor());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
browserHelper = new MediaBrowserHelper(this);
|
||||
browserHelper.regPlayListener(new PlayListener());
|
||||
}
|
||||
public void setBarColor(int color){
|
||||
getWindow().setStatusBarColor(color);
|
||||
getWindow().setNavigationBarColor(color);
|
||||
}
|
||||
|
||||
private class PlayListener extends MediaControllerCompat.Callback {
|
||||
@Override
|
||||
@ -78,5 +89,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void onQueueChanged(List<MediaSessionCompat.QueueItem> queue) {
|
||||
super.onQueueChanged(queue);
|
||||
}
|
||||
public void setImage(){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,8 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="500dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@ -21,25 +22,83 @@
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_launcher_background" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_launcher_foreground" />
|
||||
|
||||
</FrameLayout>
|
||||
android:layout_marginTop="150dp"
|
||||
android:src="@drawable/ic_launcher_foreground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:orientation="vertical"
|
||||
android:progressTint="#FF1313"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/positionTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:text="00:00"
|
||||
android:textColor="@color/colorBlack" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/durationTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:text="00:00"
|
||||
android:textColor="@color/colorBlack" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#000E0A0A"
|
||||
android:backgroundTint="#D12828"
|
||||
android:elevation="6dp"
|
||||
android:max="100"
|
||||
android:progress="50"
|
||||
android:progressBackgroundTintMode="add"
|
||||
android:progressTint="#EC1E1E"
|
||||
android:textColor="@color/colorBlack" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/frameLayout">
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/previous"
|
||||
@ -66,23 +125,38 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="title" />
|
||||
android:elevation="4dp"
|
||||
android:text="title"
|
||||
android:shadowColor="@color/textColorGray"
|
||||
android:shadowRadius="1"
|
||||
android:shadowDx="5"
|
||||
android:shadowDy="5"
|
||||
android:textColor="@color/musicTitle"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="artist-album" />
|
||||
android:text="artist-album"
|
||||
android:textColor="@color/musicArtist"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -3,4 +3,9 @@
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
<color name="colorBlack">#000000</color>
|
||||
|
||||
<color name="musicTitle">#000000</color>
|
||||
<color name="musicArtist">#000000</color>
|
||||
<color name="textColorGray">#DEDEDE</color>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user