Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
6566127c
Commit
6566127c
authored
Oct 28, 2019
by
konghaorui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增通知栏音乐播放打开意图
parent
2175c230
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
15 deletions
+21
-15
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-1
PlayFragment.java
app/src/main/java/com/ydl/component/music/PlayFragment.java
+5
-3
AudioPlayer.kt
ydl-media/src/main/java/com/ydl/media/music/AudioPlayer.kt
+4
-4
MediaSessionManager.kt
ydl-media/src/main/java/com/ydl/media/music/manager/MediaSessionManager.kt
+2
-2
NotifyManager.kt
ydl-media/src/main/java/com/ydl/media/music/manager/NotifyManager.kt
+2
-3
StatusBarReceiver.kt
ydl-media/src/main/java/com/ydl/media/music/receiver/StatusBarReceiver.kt
+1
-0
CoverImageUtils.kt
ydl-media/src/main/java/com/ydl/media/music/utils/CoverImageUtils.kt
+2
-2
No files found.
app/src/main/AndroidManifest.xml
View file @
6566127c
...
...
@@ -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
...
...
app/src/main/java/com/ydl/component/music/PlayFragment.java
View file @
6566127c
...
...
@@ -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.
Cover
ImageUtils
;
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
));
Cover
ImageUtils
.
INSTANCE
.
loadRound
(
Objects
.
requireNonNull
(
music
.
getCoverPath
()),
bitmap
->
ivCover
.
setImageBitmap
(
bitmap
));
Cover
ImageUtils
.
INSTANCE
.
loadBlur
(
music
.
getCoverPath
(),
bitmap
->
ivPlayingBg
.
setImageBitmap
(
bitmap
));
}
String
formatTime
(
long
time
)
{
...
...
ydl-media/src/main/java/com/ydl/media/music/AudioPlayer.kt
View file @
6566127c
...
...
@@ -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
...
...
ydl-media/src/main/java/com/ydl/media/music/manager/MediaSessionManager.kt
View file @
6566127c
...
...
@@ -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.
Cover
ImageUtils
/**
...
...
@@ -79,7 +79,7 @@ class MediaSessionManager private constructor() {
return
}
ImageUtils
.
loadThumb
(
music
.
coverPath
!!
,
object
:
ImageUtils
.
OnCoverLoadListenre
{
CoverImageUtils
.
loadThumb
(
music
.
coverPath
!!
,
object
:
Cover
ImageUtils
.
OnCoverLoadListenre
{
override
fun
onComplete
(
bitmap
:
Bitmap
)
{
val
metaData
=
MediaMetadataCompat
.
Builder
()
.
putString
(
MediaMetadataCompat
.
METADATA_KEY_TITLE
,
music
.
title
)
...
...
ydl-media/src/main/java/com/ydl/media/music/manager/NotifyManager.kt
View file @
6566127c
...
...
@@ -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
)
...
...
ydl-media/src/main/java/com/ydl/media/music/receiver/StatusBarReceiver.kt
View file @
6566127c
...
...
@@ -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"
...
...
ydl-media/src/main/java/com/ydl/media/music/utils/ImageUtils.kt
→
ydl-media/src/main/java/com/ydl/media/music/utils/
Cover
ImageUtils.kt
View file @
6566127c
...
...
@@ -13,7 +13,7 @@ import com.ydl.ydlcommon.base.BaseApp
* Created by haorui on 2019-10-27 .
* Des:
*/
object
ImageUtils
{
object
Cover
ImageUtils
{
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
(
Cover
ImageUtils
.
blur
(
resource
)
!!
)
}
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment