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
4a3ac3bc
Commit
4a3ac3bc
authored
2 years ago
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 17946 17947
parent
db37a4cd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
42 deletions
+34
-42
DemoGlobalConfig.java
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
+2
-2
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+3
-1
HomeMuseView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
+5
-4
home_muse_view.xml
m-home/src/ydl/res/layout/home_muse_view.xml
+1
-1
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+10
-19
MediaPlayerManager.kt
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
+13
-15
No files found.
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
View file @
4a3ac3bc
...
...
@@ -21,9 +21,9 @@ import java.util.List;
public
final
class
DemoGlobalConfig
implements
IConfigModule
{
String
APP_DOMAIN
=
"https://api.github.com/"
;
// public static String appEnv = YDLConstants.ENV_AUTO_TEST;
//
public static String appEnv = YDLConstants.ENV_TEST;
public
static
String
appEnv
=
YDLConstants
.
ENV_TEST
;
// public static String appEnv = YDLConstants.ENV_NEW_TEST;//配置未上传到maven库
public
static
String
appEnv
=
YDLConstants
.
ENV_PROD
;
//
public static String appEnv = YDLConstants.ENV_PROD;
@Override
public
void
injectAppLifecycle
(
@NotNull
Context
context
,
@NotNull
List
<
IAppLifecycles
>
lifecycles
)
{
lifecycles
.
add
(
new
DemoAppLifecycles
());
...
...
This diff is collapsed.
Click to expand it.
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
4a3ac3bc
...
...
@@ -13,9 +13,11 @@ import com.alibaba.android.arouter.launcher.ARouter
import
com.bumptech.glide.Glide
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.utils.Utils
import
com.yidianling.home.model.bean.MeditationModuleBean
import
com.yidianling.home.router.HomeIn
import
com.yidianling.user.api.service.IUserService
import
kotlinx.android.synthetic.ydl.home_fragment.*
class
MeditationTypeAdapter
(
...
...
@@ -62,7 +64,7 @@ class MeditationTypeAdapter(
holder
.
cvLayout
?.
setOnClickListener
{
if
(
meditationType
==
0
){
if
(
HomeIn
.
getUserService
().
loginByOneKeyLogin
(
context
,
true
))
{
if
(
!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
))
{
return
@setOnClickListener
}
ARouter
.
getInstance
().
build
(
"/muse/play"
)
...
...
This diff is collapsed.
Click to expand it.
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
View file @
4a3ac3bc
...
...
@@ -2,6 +2,7 @@ package com.yidianling.home.ui.view
import
android.annotation.SuppressLint
import
android.content.Context
import
android.graphics.Color
import
android.graphics.Typeface
import
android.media.MediaPlayer
import
android.text.SpannableString
...
...
@@ -14,12 +15,10 @@ import androidx.recyclerview.widget.RecyclerView
import
com.bumptech.glide.Glide
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayoutMediator
import
com.google.gson.Gson
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydl_image.module.GlideApp
import
com.ydl.ydlcommon.utils.Utils
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.MeditationViewPagerAdapter
import
com.yidianling.home.R
import
com.yidianling.home.constract.HomeViewConfig
...
...
@@ -92,10 +91,11 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
.
into
(
iv_video_background
)
}
else
{
GlideApp
.
with
(
this
)
.
load
(
video
Url
)
.
load
(
bean
.
mditationIndexInfo
?.
mditationIndex
Url
)
.
into
(
iv_video_background
)
video_view
?.
setVideoPath
(
videoUrl
)
video_view
?.
setOnErrorListener
{
mp
,
what
,
extra
->
Glide
.
with
(
this
)
.
load
(
bean
.
mditationIndexInfo
?.
mditationIndexUrl
)
...
...
@@ -106,7 +106,8 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
it
?.
setVideoScalingMode
(
MediaPlayer
.
VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
)
video_view
?.
setOnInfoListener
{
mp
,
what
,
extra
->
if
(
what
==
MediaPlayer
.
MEDIA_INFO_VIDEO_RENDERING_START
){
iv_video_background
.
visibility
=
GONE
iv_video_background
.
visibility
=
View
.
GONE
video_view
.
setBackgroundColor
(
Color
.
TRANSPARENT
)
}
true
}
...
...
This diff is collapsed.
Click to expand it.
m-home/src/ydl/res/layout/home_muse_view.xml
View file @
4a3ac3bc
...
...
@@ -36,7 +36,7 @@
android:id=
"@+id/iv_video_background"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fit
XY"
/>
android:scaleType=
"fit
Center"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
4a3ac3bc
...
...
@@ -13,7 +13,6 @@ import com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.bean.StatusBarOptions
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.ydl.ydlcommon.event.MeditationEvent
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.StatusBarUtils.Companion.setTransparentForImageView
import
com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import
com.ydl.ydlcommon.utils.Utils
...
...
@@ -25,7 +24,6 @@ import com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.widget.QuitMeditationDialog
import
com.yidianling.muse.widget.ShareMeditationDialog
import
de.greenrobot.event.EventBus
import
de.greenrobot.event.ThreadMode
import
io.reactivex.Observable
import
io.reactivex.Observer
import
io.reactivex.android.schedulers.AndroidSchedulers
...
...
@@ -153,7 +151,6 @@ class PlayMeditationActivity : BaseActivity() {
}
)
initMediaPlayer
(
mediaUrl
,
currentPosition
)
}
}
...
...
@@ -167,7 +164,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
mediaId
=
mediaId
!!
,
meditationId
=
1
meditationId
=
meditationId
!!
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
@@ -532,6 +529,9 @@ class PlayMeditationActivity : BaseActivity() {
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
false
}
if
(
mMediaPlayer
?.
isPlaying
==
true
){
mMediaPlayer
?.
pause
()
}
}
}
...
...
@@ -558,7 +558,7 @@ class PlayMeditationActivity : BaseActivity() {
private
fun
initMediaPlayer
(
path
:
String
,
current
:
Int
)
{
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
=
=
null
if
(
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
!
=
null
&&
MediaPlayerManager
.
getInstance
(
this
)
?.
getAudioPath
()
==
path
)
{
MediaPlayerManager
.
getInstance
(
this
)
?.
play
()
...
...
@@ -573,7 +573,7 @@ class PlayMeditationActivity : BaseActivity() {
val
currentPosition
=
mMediaPlayer
?.
currentPosition
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
current
!=
null
&&
current
>
0
)
{
if
(
current
>
0
)
{
mMediaPlayer
?.
seekTo
(
current
*
1000
)
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
progress
=
current
...
...
@@ -583,13 +583,9 @@ class PlayMeditationActivity : BaseActivity() {
seekbar_play_progress
.
progress
=
current
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
currentPosition
/
1000
)
}
if
(
duration
!=
null
)
{
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
}
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
seekbar_play_progress
.
max
=
duration
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
if
(!
isSeekbarChanging
)
{
...
...
@@ -607,15 +603,13 @@ 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
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
current
!=
null
&&
current
>
0
)
{
if
(
current
>
0
)
{
mMediaPlayer
?.
seekTo
(
current
*
1000
)
seekbar_play_progress
.
max
=
duration
seekbar_play_progress
.
progress
=
current
...
...
@@ -626,9 +620,7 @@ class PlayMeditationActivity : BaseActivity() {
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
currentPosition
/
1000
)
}
if
(
duration
!=
null
)
{
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
}
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
...
...
@@ -695,7 +687,6 @@ class PlayMeditationActivity : BaseActivity() {
}
override
fun
onComplete
()
{
show
(
"倒计时结束,停止播放吧!"
)
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
mMediaPlayer
?.
stop
()
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/helper/MediaPlayerManager.kt
View file @
4a3ac3bc
package
com.yidianling.muse.helper
import
android.content.Context
import
android.media.AudioManager
import
android.media.MediaPlayer
import
android.net.Uri
import
java.io.IOException
import
kotlin.properties.Delegates
class
MediaPlayerManager
private
constructor
()
{
...
...
@@ -13,36 +11,36 @@ class MediaPlayerManager private constructor() {
fun
setAudioPath
(
path
:
String
){
mPath
=
path
if
(
mMediaPlayer
.
isPlaying
)
mMediaPlayer
.
reset
()
mMediaPlayer
.
setDataSource
(
mContext
,
Uri
.
parse
(
path
))
mMediaPlayer
.
prepareAsync
()
mMediaPlayer
.
setOnPreparedListener
{
mMediaPlayer
?
.
reset
()
mMediaPlayer
?
.
setDataSource
(
mContext
,
Uri
.
parse
(
path
))
mMediaPlayer
?
.
prepareAsync
()
mMediaPlayer
?
.
setOnPreparedListener
{
listener
?.
onPrepared
(
it
)
}
}
fun
getMediaPlayer
():
MediaPlayer
=
mMediaPlayer
fun
getMediaPlayer
():
MediaPlayer
?
=
mMediaPlayer
fun
getAudioPath
():
String
?
=
mPath
fun
isPlaying
()
=
mMediaPlayer
.
isPlaying
fun
isPlaying
()
=
mMediaPlayer
?
.
isPlaying
fun
play
()
{
if
(
mMediaPlayer
.
isPlaying
)
return
mMediaPlayer
.
start
()
if
(
mMediaPlayer
?.
isPlaying
==
true
)
return
mMediaPlayer
?
.
start
()
}
fun
pause
()
{
if
(
mMediaPlayer
.
isPlaying
)
mMediaPlayer
.
pause
()
if
(
mMediaPlayer
?.
isPlaying
==
true
)
mMediaPlayer
?
.
pause
()
}
fun
seekTo
(
position
:
Int
)
{
mMediaPlayer
.
seekTo
(
position
)
mMediaPlayer
?
.
seekTo
(
position
)
}
fun
stop
()
{
if
(
mMediaPlayer
!!
.
isPlaying
)
{
mMediaPlayer
.
reset
()
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
mMediaPlayer
?
.
reset
()
}
}
...
...
@@ -58,7 +56,7 @@ class MediaPlayerManager private constructor() {
private
var
mContext
:
Context
by
Delegates
.
notNull
()
private
var
mMediaPlayer
:
MediaPlayer
by
Delegates
.
notNull
()
private
var
mMediaPlayer
:
MediaPlayer
?
=
null
private
var
mPath
:
String
?
=
null
...
...
This diff is collapsed.
Click to expand it.
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