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
989bd14e
Commit
989bd14e
authored
Jun 07, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix time off switch sound sequence err
Took 2 hours 51 minutes
parent
d6e9d2a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
33 deletions
+39
-33
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+37
-28
MediaPlayerManager.kt
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
+1
-4
MediaPlayerTimeUtil.kt
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
+1
-1
No files found.
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
989bd14e
...
...
@@ -284,8 +284,6 @@ class PlayMeditationActivity : BaseActivity() {
)
if
(!
mediaListLink
.
isNullOrBlank
())
{
ChooseMusicActivity
.
launch
(
this
,
H5Params
(
mediaListLink
,
""
)
)
// val chooseMusicDialog = ChooseMusicDialog(this,H5Params(mediaListLink!!, null))
// chooseMusicDialog.show()
}
}
...
...
@@ -571,7 +569,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
(
needRefresh
=
false
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
initMediaPlayer
(
mMediaUrl
,
0
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
ToastUtil
.
toastShort
(
"暂无内容"
)
}
...
...
@@ -621,7 +619,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI
(
needRefresh
=
false
)
initMediaPlayer
(
mMediaUrl
,
currentPosition
,
mMediaIdFromLocal
==
mMediaId
)
initMediaPlayer
(
mMediaUrl
,
0
,
mMediaIdFromLocal
==
mMediaId
)
}
else
{
ToastUtil
.
toastShort
(
"暂无内容"
)
}
...
...
@@ -734,30 +732,9 @@ class PlayMeditationActivity : BaseActivity() {
if
(
isLoop
){
if
(
isSingle
||
meditations
.
size
==
1
){
MediaPlayerManager
.
getInstance
(
this
)
?.
setAudioPath
(
currentMeditation
?.
mediaUrl
?:
""
,
isLoop
=
true
)
MediaPlayerManager
.
getInstance
(
this
)
?.
setAudioPath
(
mMediaUrl
)
}
else
{
currentMeditationIndex
=
meditations
.
indexOf
(
currentMeditation
)
if
(
currentMeditationIndex
==
meditations
.
size
-
1
){
currentMeditationIndex
=
0
}
else
{
currentMeditationIndex
++
}
currentMeditation
=
meditations
[
currentMeditationIndex
]
val
event
=
MeditationEvent
(
currentMeditation
?.
mediaId
?.
toInt
()
?:
0
,
mMeditationId
?:
0L
,
mMeditationType
?:
0
,
mBusinessType
,
status
=
mStatus
,
buried
=
mBuried
?:
""
,
mediaUrl
=
currentMeditation
?.
mediaUrl
?:
""
,
mediaCoverUrl
=
currentMeditation
?.
coverImageUrl
?:
""
,
title
=
currentMeditation
?.
title
?:
""
,
desc
=
currentMeditation
?.
desc
?:
""
)
EventBus
.
getDefault
().
post
(
event
)
switchSound
()
}
}
...
...
@@ -772,6 +749,38 @@ class PlayMeditationActivity : BaseActivity() {
mMediaPlayer
?.
pause
()
}
}
mMediaPlayer
?.
setOnErrorListener
{
mp
,
what
,
extra
->
true
}
}
private
fun
switchSound
(){
var
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
?
=
null
meditations
?.
forEachIndexed
{
index
,
meditationDetail
->
if
(
meditationDetail
.
mediaId
==
mMediaId
){
currentMeditationIndex
=
index
}
}
if
(
mMeditationId
==
null
||
mMediaId
==
null
)
return
if
(
currentMeditationIndex
<
meditations
.
size
-
1
)
{
meditation
=
meditations
[
currentMeditationIndex
+
1
]
}
else
{
meditation
=
meditations
[
0
]
}
currentMeditation
=
meditation
.
copy
(
meditationId
=
mMeditationId
!!
)
mMediaId
=
meditation
.
mediaId
mMediaCoverUrl
=
meditation
.
coverImageUrl
mMediaUrl
=
meditation
.
mediaUrl
mStatus
=
meditation
.
status
mTitle
=
meditation
.
title
mDesc
=
meditation
.
title
updateUI
(
needRefresh
=
false
)
initMediaPlayer
(
mMediaUrl
,
0
,
mMediaIdFromLocal
==
mMediaId
)
}
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
,
isSameOne
:
Boolean
=
false
)
{
...
...
@@ -787,7 +796,7 @@ class PlayMeditationActivity : BaseActivity() {
val
currentPosition
=
mMediaPlayer
?.
currentPosition
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
current
>
0
)
{
if
(
current
>
=
0
)
{
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
progress
=
current
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
current
)
...
...
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
View file @
989bd14e
...
...
@@ -45,7 +45,7 @@ class MediaPlayerManager private constructor() {
mTime
=
time
}
fun
setAudioPath
(
path
:
String
,
isLoop
:
Boolean
=
false
){
fun
setAudioPath
(
path
:
String
){
val
attrs
=
AudioAttributes
.
Builder
()
.
setContentType
(
AudioAttributes
.
CONTENT_TYPE_MUSIC
)
...
...
@@ -60,9 +60,6 @@ class MediaPlayerManager private constructor() {
mMediaPlayer
?.
prepareAsync
()
mMediaPlayer
?.
setOnPreparedListener
{
listener
?.
onPrepared
(
it
)
if
(
isLoop
){
mMediaPlayer
?.
seekTo
(
0
)
}
}
}
...
...
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
View file @
989bd14e
...
...
@@ -28,7 +28,7 @@ class MediaPlayerTimeUtil {
"$minute:$second"
}
}
}
else
if
(
time
in
1
..
59
){
}
else
if
(
time
in
0
..
59
){
second
=
time
return
if
(
second
in
0
..
9
){
"00:0$second"
...
...
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