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
Show 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 {
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"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-dynamic"
:
"0.0.7.73"
,
"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-course"
:
"0.0.43.37"
,
...
...
@@ -94,7 +94,7 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"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-dynamic"
:
"0.0.7.73"
,
"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() {
private
var
broadcastTime
=
0
/**
* 传递过来的mediaId 用于判断正在播放的是否是同一条音频
*/
private
var
mMediaIdFromLocal
:
Long
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
setTransparentForImageView
(
this
,
null
)
statusBarLightMode
(
this
)
...
...
@@ -107,7 +113,7 @@ class PlayMeditationActivity : BaseActivity() {
EventBus
.
getDefault
().
register
(
this
)
mMediaId
=
intent
?.
getLongExtra
(
"MEDIA_ID"
,
0L
)
mMediaId
FromLocal
=
intent
?.
getLongExtra
(
"MEDIA_ID"
,
0L
)
mMeditationId
=
intent
?.
getLongExtra
(
"MEDITATION_ID"
,
0L
)
mMeditationType
=
intent
?.
getIntExtra
(
"MEDITATION_TYPE"
,
0
)
mMediaUrl
=
intent
?.
getStringExtra
(
"MEDIA_URL"
)
?:
""
...
...
@@ -123,7 +129,7 @@ class PlayMeditationActivity : BaseActivity() {
private
fun
getData
()
{
updateUIByMeditationType
()
if
(
mMeditationId
==
null
||
(
mMediaId
==
null
&&
mMeditationType
!=
0
))
{
if
(
mMeditationId
==
null
||
(
mMediaId
FromLocal
==
null
&&
mMeditationType
!=
0
))
{
return
}
// 声音详情
...
...
@@ -143,7 +149,7 @@ class PlayMeditationActivity : BaseActivity() {
val
mediaList
=
module
.
mediaList
if
(!
mediaList
.
isNullOrEmpty
()){
val
meditation
=
mediaList
[
0
]
currentMeditation
=
meditation
.
copy
(
m
MeditationType
,
mMeditationId
)
currentMeditation
=
meditation
.
copy
(
m
editationType
=
mMeditationType
,
meditationId
=
mMeditationId
!!
)
mTitle
=
meditation
.
title
mDesc
=
meditation
.
desc
?:
""
mMediaUrl
=
meditation
.
mediaUrl
...
...
@@ -155,7 +161,11 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
//快进点击事件
ActionCountUtils
.
baiDuCountSign3
(
...
...
@@ -175,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() {
}
else
{
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
mediaId
=
mMediaId
!!
,
mediaId
=
mMediaId
FromLocal
!!
,
meditationId
=
mMeditationId
!!
)
.
subscribeOn
(
Schedulers
.
io
())
...
...
@@ -196,7 +206,7 @@ class PlayMeditationActivity : BaseActivity() {
if
(
meditationPlayBean
.
mediaId
==
mMediaId
)
{
currentMeditation
=
meditationPlayBean
.
copy
(
meditationId
=
mMeditationId
!!
)
meditationPlayBean
.
copy
(
meditation
Type
=
mMeditationType
,
meditation
Id
=
mMeditationId
!!
)
mMediaId
=
module
?.
mediaId
?:
0L
mTitle
=
meditationPlayBean
.
title
...
...
@@ -218,7 +228,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
}
}
...
...
@@ -553,7 +563,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
ToastUtil
.
toastShort
(
"当前已经是第一首"
)
}
...
...
@@ -592,7 +602,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
()
initMediaPlayer
(
mMediaUrl
,
currentPosition
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
ToastUtil
.
toastShort
(
"当前已经是最后一首"
)
}
...
...
@@ -741,15 +751,11 @@ class PlayMeditationActivity : BaseActivity() {
}
}
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
)
{
// val event = MeditationFloatEvent(show = false,stop = false,meditation = currentMeditation)
// EventBus.getDefault().post(event)
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
,
isSameOne
:
Boolean
=
false
)
{
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
!=
null
&&
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
==
path
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
!=
null
&&
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaId
()
==
mMediaId
)
{
MediaPlayerManager
.
getInstance
(
this
)
?.
play
()
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
}
else
{
...
...
@@ -759,7 +765,6 @@ class PlayMeditationActivity : BaseActivity() {
val
currentPosition
=
mMediaPlayer
?.
currentPosition
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
current
>
0
)
{
mMediaPlayer
?.
seekTo
(
current
*
1000
)
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
progress
=
current
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
current
)
...
...
@@ -932,7 +937,7 @@ class PlayMeditationActivity : BaseActivity() {
if
(
event
.
mediaUrl
==
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
())
{
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() {
private
var
mMediaPlayCallBack
:
MediaPlayCallBack
?=
null
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
){
val
attrs
=
AudioAttributes
.
Builder
()
...
...
@@ -56,11 +64,11 @@ class MediaPlayerManager private constructor() {
}
fun
stop
()
{
mMediaPlayer
?.
reset
()
mMediaPlayer
?.
stop
()
}
fun
release
()
{
mMediaPlayer
?.
reset
()
mMediaPlayer
?.
stop
()
}
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() {
private
var
mObservable
:
Observable
<
Long
>?
=
null
private
var
mObserver
:
Observer
<
Long
>?
=
null
private
var
mProgressTimer
=
Timer
()
private
lateinit
var
mSeekBar
:
AppCompatSeekBar
private
var
currentMediaId
:
Long
?
=
null
override
fun
onCreate
()
{
super
.
onCreate
()
...
...
@@ -157,6 +157,10 @@ class MeditationWindowService : LifecycleService() {
}
private
fun
updateFloatView
(
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
)
{
currentMediaId
=
meditation
.
mediaId
MediaPlayerManager
.
getInstance
(
this
)
?.
setMediaId
(
currentMediaId
)
mMediaPlayer
=
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaPlayer
()
floatRootView
?.
setOnClickListener
{
//悬浮窗暂停点击事件
...
...
@@ -168,8 +172,6 @@ class MeditationWindowService : LifecycleService() {
intent
.
putExtra
(
"MEDITATION_TYPE"
,
meditation
.
meditationType
)
intent
.
putExtra
(
"MEDIA_COVER_URL"
,
meditation
.
coverImageUrl
)
intent
.
putExtra
(
"MEDIA_URL"
,
meditation
.
mediaUrl
)
intent
.
putExtra
(
"BROAD_CAST_TIME"
,
(
ivProgress
?.
curProcess
?.
div
(
1000.00
))
?.
roundToInt
()
?:
0
)
intent
.
flags
=
FLAG_ACTIVITY_NEW_TASK
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