Commit 6566127c by konghaorui

新增通知栏音乐播放打开意图

parent 2175c230
......@@ -30,9 +30,13 @@
android:theme="@style/platform_NoTitleTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.ydl.media.ACTION_MUSIC_CLICK" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<meta-data
......
......@@ -17,7 +17,7 @@ import com.ydl.media.music.AudioPlayer;
import com.ydl.media.music.OnPlayerEventListener;
import com.ydl.media.music.enums.PlayModeEnum;
import com.ydl.media.music.model.Music;
import com.ydl.media.music.utils.ImageUtils;
import com.ydl.media.music.utils.CoverImageUtils;
import com.yidianling.common.tools.ToastUtil;
import java.util.Locale;
......@@ -200,9 +200,11 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
tvArtist.setText(music.getArtist());
sbProgress.setProgress((int) AudioPlayer.Companion.get().getAudioPosition());
sbProgress.setSecondaryProgress(0);
sbProgress.setMax((int) AudioPlayer.Companion.get().getDuration());
mLastProgress = 0;
tvCurrentTime.setText(R.string.play_time_start);
tvTotalTime.setText(formatTime(AudioPlayer.Companion.get().getDuration()));
setCoverAndBg(music);
if (AudioPlayer.Companion.get().isPlaying() || AudioPlayer.Companion.get().isPreparing()) {
......@@ -250,8 +252,8 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
}
void setCoverAndBg(Music music) {
ImageUtils.INSTANCE.loadRound(Objects.requireNonNull(music.getCoverPath()), bitmap -> ivCover.setImageBitmap(bitmap));
ImageUtils.INSTANCE.loadBlur(music.getCoverPath(), bitmap -> ivPlayingBg.setImageBitmap(bitmap));
CoverImageUtils.INSTANCE.loadRound(Objects.requireNonNull(music.getCoverPath()), bitmap -> ivCover.setImageBitmap(bitmap));
CoverImageUtils.INSTANCE.loadBlur(music.getCoverPath(), bitmap -> ivPlayingBg.setImageBitmap(bitmap));
}
String formatTime(long time) {
......
......@@ -360,11 +360,7 @@ class AudioPlayer private constructor() {
else -> playPosition + 1
}
play(playPosition);
}
/**
......@@ -421,6 +417,10 @@ class AudioPlayer private constructor() {
return musicList
}
fun getDuration(): Long{
return if (isPlaying) mediaPlayer!!.duration else 0
}
companion object {
private val STATE_IDLE = 0
......
......@@ -8,7 +8,7 @@ import android.support.v4.media.session.PlaybackStateCompat
import com.ydl.media.music.AudioPlayer
import com.ydl.media.music.PlayService
import com.ydl.media.music.model.Music
import com.ydl.media.music.utils.ImageUtils
import com.ydl.media.music.utils.CoverImageUtils
/**
......@@ -79,7 +79,7 @@ class MediaSessionManager private constructor() {
return
}
ImageUtils.loadThumb(music.coverPath!!,object :ImageUtils.OnCoverLoadListenre{
CoverImageUtils.loadThumb(music.coverPath!!,object :CoverImageUtils.OnCoverLoadListenre{
override fun onComplete(bitmap: Bitmap) {
val metaData = MediaMetadataCompat.Builder()
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, music.title)
......
......@@ -68,11 +68,10 @@ class NotifyManager private constructor() {
music: Music,
isPlaying: Boolean
): Notification {
// TODO: 2019-10-26 by:HaoRui
// Intent intent = new Intent(context, MusicActivity.class);
val intent = Intent()
intent.action= "com.ydl.media.ACTION_MUSIC_CLICK"
intent.putExtra(Extras.EXTRA_NOTIFICATION, true)
intent.action = Intent.ACTION_VIEW
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
......
......@@ -29,6 +29,7 @@ class StatusBarReceiver : BroadcastReceiver() {
companion object {
val ACTION_STATUS_BAR = "com.ydl.media.STATUS_BAR_ACTIONS"
val ACTION_MUSIC_CLICK = "com.ydl.media.ACTION_MUSIC_CLICK"
val EXTRA = "extra"
val EXTRA_NEXT = "next"
val EXTRA_PLAY_PAUSE = "play_pause"
......
......@@ -13,7 +13,7 @@ import com.ydl.ydlcommon.base.BaseApp
* Created by haorui on 2019-10-27 .
* Des:
*/
object ImageUtils {
object CoverImageUtils {
private val BLUR_RADIUS = 50
fun blur(source: Bitmap?): Bitmap? {
......@@ -373,7 +373,7 @@ object ImageUtils {
RequestOptions().format(DecodeFormat.PREFER_RGB_565).disallowHardwareConfig()
Glide.with(BaseApp.getApp()).asBitmap().apply(disallowHardwareConfig).load(url).into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap?, transition: Transition<in Bitmap>?) {
onCoverLoadListener.onComplete(ImageUtils.blur(resource)!!)
onCoverLoadListener.onComplete(CoverImageUtils.blur(resource)!!)
}
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment