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
90413816
Commit
90413816
authored
May 28, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix play bug
parent
c0250f53
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
27 deletions
+42
-27
config.gradle
config.gradle
+3
-3
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+23
-18
MediaPlayerManager.kt
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
+10
-2
MeditationWindowService.kt
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
+6
-4
No files found.
config.gradle
View file @
90413816
...
@@ -9,12 +9,12 @@ ext {
...
@@ -9,12 +9,12 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.19"
,
"m-user"
:
"0.0.62.19"
,
"m-home"
:
"0.0.23.
69
"
,
"m-home"
:
"0.0.23.
70
"
,
"m-im"
:
"0.0.21.44"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.10"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.5
1
"
,
"m-muse"
:
"0.0.28.5
2
"
,
"m-tests"
:
"0.0.24.18"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
"m-course"
:
"0.0.43.37"
,
...
@@ -94,7 +94,7 @@ ext {
...
@@ -94,7 +94,7 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.19"
,
"m-user"
:
"0.0.62.19"
,
"m-home"
:
"0.0.23.
69
"
,
"m-home"
:
"0.0.23.
70
"
,
"m-im"
:
"0.0.21.44"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.8"
,
"m-article"
:
"0.0.0.8"
,
...
...
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
90413816
...
@@ -94,6 +94,12 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -94,6 +94,12 @@ class PlayMeditationActivity : BaseActivity() {
private
var
broadcastTime
=
0
private
var
broadcastTime
=
0
/**
* 传递过来的mediaId 用于判断正在播放的是否是同一条音频
*/
private
var
mMediaIdFromLocal
:
Long
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
setTransparentForImageView
(
this
,
null
)
setTransparentForImageView
(
this
,
null
)
statusBarLightMode
(
this
)
statusBarLightMode
(
this
)
...
@@ -107,7 +113,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -107,7 +113,7 @@ class PlayMeditationActivity : BaseActivity() {
EventBus
.
getDefault
().
register
(
this
)
EventBus
.
getDefault
().
register
(
this
)
mMediaId
=
intent
?.
getLongExtra
(
"MEDIA_ID"
,
0L
)
mMediaId
FromLocal
=
intent
?.
getLongExtra
(
"MEDIA_ID"
,
0L
)
mMeditationId
=
intent
?.
getLongExtra
(
"MEDITATION_ID"
,
0L
)
mMeditationId
=
intent
?.
getLongExtra
(
"MEDITATION_ID"
,
0L
)
mMeditationType
=
intent
?.
getIntExtra
(
"MEDITATION_TYPE"
,
0
)
mMeditationType
=
intent
?.
getIntExtra
(
"MEDITATION_TYPE"
,
0
)
mMediaUrl
=
intent
?.
getStringExtra
(
"MEDIA_URL"
)
?:
""
mMediaUrl
=
intent
?.
getStringExtra
(
"MEDIA_URL"
)
?:
""
...
@@ -123,7 +129,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -123,7 +129,7 @@ class PlayMeditationActivity : BaseActivity() {
private
fun
getData
()
{
private
fun
getData
()
{
updateUIByMeditationType
()
updateUIByMeditationType
()
if
(
mMeditationId
==
null
||
(
mMediaId
==
null
&&
mMeditationType
!=
0
))
{
if
(
mMeditationId
==
null
||
(
mMediaId
FromLocal
==
null
&&
mMeditationType
!=
0
))
{
return
return
}
}
// 声音详情
// 声音详情
...
@@ -143,7 +149,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -143,7 +149,7 @@ class PlayMeditationActivity : BaseActivity() {
val
mediaList
=
module
.
mediaList
val
mediaList
=
module
.
mediaList
if
(!
mediaList
.
isNullOrEmpty
()){
if
(!
mediaList
.
isNullOrEmpty
()){
val
meditation
=
mediaList
[
0
]
val
meditation
=
mediaList
[
0
]
currentMeditation
=
meditation
.
copy
(
m
MeditationType
,
mMeditationId
)
currentMeditation
=
meditation
.
copy
(
m
editationType
=
mMeditationType
,
meditationId
=
mMeditationId
!!
)
mTitle
=
meditation
.
title
mTitle
=
meditation
.
title
mDesc
=
meditation
.
desc
?:
""
mDesc
=
meditation
.
desc
?:
""
mMediaUrl
=
meditation
.
mediaUrl
mMediaUrl
=
meditation
.
mediaUrl
...
@@ -155,7 +161,11 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -155,7 +161,11 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
//快进点击事件
//快进点击事件
ActionCountUtils
.
baiDuCountSign3
(
ActionCountUtils
.
baiDuCountSign3
(
...
@@ -175,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -175,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() {
}
else
{
}
else
{
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
meditionType
=
1
,
mediaId
=
mMediaId
!!
,
mediaId
=
mMediaId
FromLocal
!!
,
meditationId
=
mMeditationId
!!
meditationId
=
mMeditationId
!!
)
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
...
@@ -196,7 +206,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -196,7 +206,7 @@ class PlayMeditationActivity : BaseActivity() {
if
(
meditationPlayBean
.
mediaId
==
mMediaId
)
{
if
(
meditationPlayBean
.
mediaId
==
mMediaId
)
{
currentMeditation
=
currentMeditation
=
meditationPlayBean
.
copy
(
meditationId
=
mMeditationId
!!
)
meditationPlayBean
.
copy
(
meditation
Type
=
mMeditationType
,
meditation
Id
=
mMeditationId
!!
)
mMediaId
=
module
?.
mediaId
?:
0L
mMediaId
=
module
?.
mediaId
?:
0L
mTitle
=
meditationPlayBean
.
title
mTitle
=
meditationPlayBean
.
title
...
@@ -218,7 +228,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -218,7 +228,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
}
}
}
}
}
...
@@ -553,7 +563,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -553,7 +563,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
}
else
{
ToastUtil
.
toastShort
(
"当前已经是第一首"
)
ToastUtil
.
toastShort
(
"当前已经是第一首"
)
}
}
...
@@ -592,7 +602,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -592,7 +602,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
}
else
{
ToastUtil
.
toastShort
(
"当前已经是最后一首"
)
ToastUtil
.
toastShort
(
"当前已经是最后一首"
)
}
}
...
@@ -741,15 +751,11 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -741,15 +751,11 @@ class PlayMeditationActivity : BaseActivity() {
}
}
}
}
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
)
{
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
,
isSameOne
:
Boolean
=
false
)
{
// val event = MeditationFloatEvent(show = false,stop = false,meditation = currentMeditation)
// EventBus.getDefault().post(event)
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
!=
null
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
!=
null
&&
&&
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
==
path
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaId
()
==
mMediaId
)
{
)
{
MediaPlayerManager
.
getInstance
(
this
)
?.
play
()
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
}
else
{
}
else
{
...
@@ -759,7 +765,6 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -759,7 +765,6 @@ class PlayMeditationActivity : BaseActivity() {
val
currentPosition
=
mMediaPlayer
?.
currentPosition
val
currentPosition
=
mMediaPlayer
?.
currentPosition
duration
=
mMediaPlayer
?.
duration
?:
0
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
current
>
0
)
{
if
(
current
>
0
)
{
mMediaPlayer
?.
seekTo
(
current
*
1000
)
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
progress
=
current
seekbar_play_progress
.
progress
=
current
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
current
)
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
current
)
...
@@ -932,7 +937,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -932,7 +937,7 @@ class PlayMeditationActivity : BaseActivity() {
if
(
event
.
mediaUrl
==
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
())
{
if
(
event
.
mediaUrl
==
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
())
{
return
return
}
}
initMediaPlayer
(
event
.
mediaUrl
,
0
)
initMediaPlayer
(
event
.
mediaUrl
,
0
,
mMediaIdFromLocal
==
mMediaId
)
}
}
}
}
...
...
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
View file @
90413816
...
@@ -15,6 +15,14 @@ class MediaPlayerManager private constructor() {
...
@@ -15,6 +15,14 @@ class MediaPlayerManager private constructor() {
private
var
mMediaPlayCallBack
:
MediaPlayCallBack
?=
null
private
var
mMediaPlayCallBack
:
MediaPlayCallBack
?=
null
private
var
mAudioPaths
=
mutableListOf
<
String
>()
private
var
mAudioPaths
=
mutableListOf
<
String
>()
private
var
mMediaId
:
Long
?
=
null
fun
setMediaId
(
mediaId
:
Long
?){
mMediaId
=
mediaId
}
fun
getMediaId
():
Long
?
=
mMediaId
fun
setAudioPath
(
path
:
String
,
isLoop
:
Boolean
=
false
){
fun
setAudioPath
(
path
:
String
,
isLoop
:
Boolean
=
false
){
val
attrs
=
AudioAttributes
.
Builder
()
val
attrs
=
AudioAttributes
.
Builder
()
...
@@ -56,11 +64,11 @@ class MediaPlayerManager private constructor() {
...
@@ -56,11 +64,11 @@ class MediaPlayerManager private constructor() {
}
}
fun
stop
()
{
fun
stop
()
{
mMediaPlayer
?.
reset
()
mMediaPlayer
?.
stop
()
}
}
fun
release
()
{
fun
release
()
{
mMediaPlayer
?.
reset
()
mMediaPlayer
?.
stop
()
}
}
fun
setOnPreparedListener
(
listener
:
OnMediaPlayerManagerListener
){
fun
setOnPreparedListener
(
listener
:
OnMediaPlayerManagerListener
){
...
...
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
View file @
90413816
...
@@ -70,10 +70,10 @@ class MeditationWindowService : LifecycleService() {
...
@@ -70,10 +70,10 @@ class MeditationWindowService : LifecycleService() {
private
var
mObservable
:
Observable
<
Long
>?
=
null
private
var
mObservable
:
Observable
<
Long
>?
=
null
private
var
mObserver
:
Observer
<
Long
>?
=
null
private
var
mObserver
:
Observer
<
Long
>?
=
null
private
var
mProgressTimer
=
Timer
()
private
lateinit
var
mSeekBar
:
AppCompatSeekBar
private
lateinit
var
mSeekBar
:
AppCompatSeekBar
private
var
currentMediaId
:
Long
?
=
null
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
...
@@ -157,6 +157,10 @@ class MeditationWindowService : LifecycleService() {
...
@@ -157,6 +157,10 @@ class MeditationWindowService : LifecycleService() {
}
}
private
fun
updateFloatView
(
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
)
{
private
fun
updateFloatView
(
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
)
{
currentMediaId
=
meditation
.
mediaId
MediaPlayerManager
.
getInstance
(
this
)
?.
setMediaId
(
currentMediaId
)
mMediaPlayer
=
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaPlayer
()
mMediaPlayer
=
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaPlayer
()
floatRootView
?.
setOnClickListener
{
floatRootView
?.
setOnClickListener
{
//悬浮窗暂停点击事件
//悬浮窗暂停点击事件
...
@@ -168,8 +172,6 @@ class MeditationWindowService : LifecycleService() {
...
@@ -168,8 +172,6 @@ class MeditationWindowService : LifecycleService() {
intent
.
putExtra
(
"MEDITATION_TYPE"
,
meditation
.
meditationType
)
intent
.
putExtra
(
"MEDITATION_TYPE"
,
meditation
.
meditationType
)
intent
.
putExtra
(
"MEDIA_COVER_URL"
,
meditation
.
coverImageUrl
)
intent
.
putExtra
(
"MEDIA_COVER_URL"
,
meditation
.
coverImageUrl
)
intent
.
putExtra
(
"MEDIA_URL"
,
meditation
.
mediaUrl
)
intent
.
putExtra
(
"MEDIA_URL"
,
meditation
.
mediaUrl
)
intent
.
putExtra
(
"BROAD_CAST_TIME"
,
(
ivProgress
?.
curProcess
?.
div
(
1000.00
))
?.
roundToInt
()
?:
0
)
intent
.
flags
=
FLAG_ACTIVITY_NEW_TASK
intent
.
flags
=
FLAG_ACTIVITY_NEW_TASK
startActivity
(
intent
)
startActivity
(
intent
)
...
...
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