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
790e7057
Commit
790e7057
authored
May 24, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix switch play list
parent
1ae1e421
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
62 deletions
+109
-62
config.gradle
config.gradle
+4
-4
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+7
-0
HomeMuseView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
+5
-0
build.gradle
m-muse/build.gradle
+1
-1
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+80
-52
MediaPlayerManager.kt
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
+12
-5
No files found.
config.gradle
View file @
790e7057
...
...
@@ -9,12 +9,12 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.10"
,
"m-home"
:
"0.0.23.5
0
"
,
"m-home"
:
"0.0.23.5
2
"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.3
0
"
,
"m-muse"
:
"0.0.28.3
2
"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
...
...
@@ -94,12 +94,12 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.10"
,
"m-home"
:
"0.0.23.5
0
"
,
"m-home"
:
"0.0.23.5
2
"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.8"
,
"m-muse"
:
"0.0.28.3
0
"
,
"m-muse"
:
"0.0.28.3
2
"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
//-------------- 业务模块 API 层 --------------
...
...
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
790e7057
...
...
@@ -64,6 +64,10 @@ class MeditationTypeAdapter(
holder
.
cvLayout
?.
setOnClickListener
{
if
(
meditationType
==
0
){
if
(
Utils
.
isFastClick
())
{
//防止连击
return
@setOnClickListener
}
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
))
{
return
@setOnClickListener
}
...
...
@@ -79,6 +83,9 @@ class MeditationTypeAdapter(
//防止连击
return
@setOnClickListener
}
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
))
{
return
@setOnClickListener
}
val
homeLink
=
"${homeLink}mark=$mark&cateId=$cateId&meditationId=${data[position].meditationId}"
if
(!
homeLink
.
isNullOrBlank
())
{
NewH5Activity
.
start
(
context
,
H5Params
(
homeLink
,
null
))
...
...
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
View file @
790e7057
...
...
@@ -18,12 +18,14 @@ import com.google.android.material.tabs.TabLayoutMediator
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydl_image.module.GlideApp
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.utils.Utils
import
com.yidianling.home.MeditationViewPagerAdapter
import
com.yidianling.home.R
import
com.yidianling.home.constract.HomeViewConfig
import
com.yidianling.home.event.IHomeEvent
import
com.yidianling.home.model.bean.MeditationModuleBean
import
com.yidianling.user.api.service.IUserService
import
kotlinx.android.synthetic.ydl.home_muse_view.view.*
/**
...
...
@@ -67,6 +69,9 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
//防止连击
return
@setOnClickListener
}
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
))
{
return
@setOnClickListener
}
if
(!
moreLink
.
isNullOrBlank
())
{
NewH5Activity
.
start
(
context
,
H5Params
(
moreLink
,
null
))
}
...
...
m-muse/build.gradle
View file @
790e7057
...
...
@@ -63,7 +63,7 @@ dependencies {
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling
//
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation
"androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation
"com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
...
...
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
790e7057
...
...
@@ -17,8 +17,10 @@ import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.setTransparentForImageVi
import
com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import
com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.utils.remind.ToastHelper.Companion.show
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.widget.QuitMeditationDialog
...
...
@@ -52,9 +54,9 @@ class PlayMeditationActivity : BaseActivity() {
private
var
businessType
=
0
private
var
mediaListLink
:
String
?
=
null
private
va
l
newPath
=
"http://file.diyring.cc/UserRingWorksFile/0/50284096.mp3"
private
va
r
meditations
=
mutableListOf
<
MeditationPlayModuleBean
.
MeditationDetail
>()
private
var
currentMeditation
:
MeditationPlayModuleBean
.
MeditationDetail
?
=
null
private
var
shareTitle
=
""
private
var
shareUrl
=
""
...
...
@@ -118,10 +120,10 @@ class PlayMeditationActivity : BaseActivity() {
.
subscribe
(
Consumer
{
if
(
it
.
code
.
equals
(
"200"
)
&&
it
.
data
!=
null
)
{
val
module
=
it
.
data
val
currentM
ediaId
=
module
.
mediaId
m
ediaId
=
module
.
mediaId
mediaListLink
=
module
.
playDetailUrl
module
.
mediaList
?.
forEach
{
meditationPlayBean
->
if
(
meditationPlayBean
.
mediaId
==
currentM
ediaId
)
{
if
(
meditationPlayBean
.
mediaId
==
m
ediaId
)
{
mediaId
=
module
?.
mediaId
?:
0L
val
title
=
meditationPlayBean
.
title
?:
"未知标题"
val
desc
=
meditationPlayBean
.
desc
?:
""
...
...
@@ -173,9 +175,18 @@ class PlayMeditationActivity : BaseActivity() {
if
(
it
.
code
.
equals
(
"200"
)
&&
it
.
data
!=
null
)
{
val
module
=
it
.
data
val
currentMediaId
=
module
.
mediaId
mediaId
=
module
.
mediaId
meditations
.
clear
()
module
.
mediaList
?.
forEach
{
meditationPlayBean
->
if
(
meditationPlayBean
.
mediaId
==
currentMediaId
)
{
meditations
.
add
(
meditationPlayBean
)
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
currentMeditation
=
meditationPlayBean
mediaId
=
module
?.
mediaId
?:
0L
val
title
=
meditationPlayBean
.
title
val
desc
=
meditationPlayBean
.
desc
?:
""
...
...
@@ -417,56 +428,75 @@ class PlayMeditationActivity : BaseActivity() {
}
exo_prev
.
setOnClickListener
{
if
(
meditationId
==
null
||
mediaId
==
null
)
return
@setOnClickListener
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
MediaPlayerManager
.
getInstance
(
this
)
?.
setAudioPath
(
newPath
)
isPlaying
=
if
(
MediaPlayerManager
.
getInstance
(
this
@PlayMeditationActivity
)
?.
getMediaPlayer
()
?.
isPlaying
==
true
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
seekbar_play_progress
.
progress
=
MediaPlayerManager
.
getInstance
(
this
@PlayMeditationActivity
)
?.
getMediaPlayer
()
?.
currentPosition
?:
0
val
currentPosition
=
meditations
.
indexOf
(
currentMeditation
)
if
(
currentPosition
>
0
){
if
(
meditationId
==
null
||
mediaId
==
null
)
return
@setOnClickListener
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
val
meditation
=
meditations
[
currentPosition
-
1
]
currentMeditation
=
meditation
mediaId
=
meditation
.
mediaId
val
mediaCoverUrl
=
meditation
.
coverImageUrl
val
mediaUrl
=
meditation
.
mediaUrl
val
currentPosition
=
meditation
.
broadcastTime
val
status
=
meditation
.
status
Glide
.
with
(
this
)
.
load
(
mediaCoverUrl
)
.
into
(
iv_bg
)
tv_title
.
text
=
meditation
.
title
tv_content
.
text
=
meditation
.
desc
iv_collect
.
setImageResource
(
if
(
status
==
0
)
{
R
.
drawable
.
icon_play_meditation_collect
}
else
{
R
.
drawable
.
icon_meditation_collected
}
},
0
,
50
)
true
}
else
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
false
)
initMediaPlayer
(
mediaUrl
,
currentPosition
)
}
else
{
ToastUtil
.
toastShort
(
"当前已经是第一首"
)
}
}
exo_next
.
setOnClickListener
{
if
(
meditationId
==
null
||
mediaId
==
null
)
return
@setOnClickListener
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
val
currentPosition
=
meditations
.
indexOf
(
currentMeditation
)
if
(
currentPosition
<
meditations
.
size
-
1
){
if
(
meditationId
==
null
||
mediaId
==
null
)
return
@setOnClickListener
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
MediaPlayerManager
.
getInstance
(
this
)
?.
setAudioPath
(
newPath
)
isPlaying
=
if
(
MediaPlayerManager
.
getInstance
(
this
@PlayMeditationActivity
)
?.
getMediaPlayer
()
?.
isPlaying
==
true
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
if
(!
isSeekbarChanging
)
{
seekbar_play_progress
.
progress
=
MediaPlayerManager
.
getInstance
(
this
@PlayMeditationActivity
)
?.
getMediaPlayer
()
?.
currentPosition
?:
0
}
val
meditation
=
meditations
[
currentPosition
+
1
]
currentMeditation
=
meditation
mediaId
=
meditation
.
mediaId
val
mediaCoverUrl
=
meditation
.
coverImageUrl
val
mediaUrl
=
meditation
.
mediaUrl
val
currentPosition
=
meditation
.
broadcastTime
val
status
=
meditation
.
status
Glide
.
with
(
this
)
.
load
(
mediaCoverUrl
)
.
into
(
iv_bg
)
tv_title
.
text
=
meditation
.
title
tv_content
.
text
=
meditation
.
desc
iv_collect
.
setImageResource
(
if
(
status
==
0
)
{
R
.
drawable
.
icon_play_meditation_collect
}
else
{
R
.
drawable
.
icon_meditation_collected
}
},
0
,
50
)
true
}
else
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
false
)
initMediaPlayer
(
mediaUrl
,
currentPosition
)
}
else
{
ToastUtil
.
toastShort
(
"当前已经是最后一首"
)
}
}
...
...
@@ -565,10 +595,8 @@ class PlayMeditationActivity : BaseActivity() {
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
true
}
else
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
false
}
val
currentPosition
=
mMediaPlayer
?.
currentPosition
...
...
@@ -753,7 +781,7 @@ class PlayMeditationActivity : BaseActivity() {
}
private
fun
stopPlay
()
{
MediaPlayerManager
.
getInstance
(
this
)
?.
stop
()
}
companion
object
{
...
...
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
View file @
790e7057
package
com.yidianling.muse.helper
import
android.content.Context
import
android.media.AudioAttributes
import
android.media.AudioManager
import
android.media.MediaPlayer
import
android.net.Uri
import
kotlin.properties.Delegates
class
MediaPlayerManager
private
constructor
()
{
...
...
@@ -10,9 +11,17 @@ class MediaPlayerManager private constructor() {
private
var
listener
:
OnMediaPlayerManagerListener
?=
null
fun
setAudioPath
(
path
:
String
){
val
attrs
=
AudioAttributes
.
Builder
()
.
setContentType
(
AudioAttributes
.
CONTENT_TYPE_MUSIC
)
.
setUsage
(
AudioAttributes
.
USAGE_MEDIA
)
.
setLegacyStreamType
(
AudioManager
.
STREAM_MUSIC
)
.
build
()
mPath
=
path
mMediaPlayer
?.
reset
()
mMediaPlayer
?.
setDataSource
(
mContext
,
Uri
.
parse
(
path
))
mMediaPlayer
?.
setAudioAttributes
(
attrs
)
mMediaPlayer
?.
setDataSource
(
path
)
mMediaPlayer
?.
prepareAsync
()
mMediaPlayer
?.
setOnPreparedListener
{
listener
?.
onPrepared
(
it
)
...
...
@@ -39,9 +48,7 @@ class MediaPlayerManager private constructor() {
}
fun
stop
()
{
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
mMediaPlayer
?.
reset
()
}
mMediaPlayer
?.
reset
()
}
fun
release
()
{
...
...
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