Commit 1ae1e421 by 刘鹏

Merge branch 'd/lancet/4.3.93_muse' into 'd/4.3.93_muse'

fix  17946  17947

See merge request app_android_lib/YDL-Component!34
parents db37a4cd 4a3ac3bc
...@@ -21,9 +21,9 @@ import java.util.List; ...@@ -21,9 +21,9 @@ import java.util.List;
public final class DemoGlobalConfig implements IConfigModule { public final class DemoGlobalConfig implements IConfigModule {
String APP_DOMAIN = "https://api.github.com/"; String APP_DOMAIN = "https://api.github.com/";
// public static String appEnv = YDLConstants.ENV_AUTO_TEST; // 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_NEW_TEST;//配置未上传到maven库
public static String appEnv = YDLConstants.ENV_PROD; // public static String appEnv = YDLConstants.ENV_PROD;
@Override @Override
public void injectAppLifecycle(@NotNull Context context, @NotNull List<IAppLifecycles> lifecycles) { public void injectAppLifecycle(@NotNull Context context, @NotNull List<IAppLifecycles> lifecycles) {
lifecycles.add(new DemoAppLifecycles()); lifecycles.add(new DemoAppLifecycles());
......
...@@ -13,9 +13,11 @@ import com.alibaba.android.arouter.launcher.ARouter ...@@ -13,9 +13,11 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.Utils import com.ydl.ydlcommon.utils.Utils
import com.yidianling.home.model.bean.MeditationModuleBean import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.router.HomeIn import com.yidianling.home.router.HomeIn
import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.ydl.home_fragment.* import kotlinx.android.synthetic.ydl.home_fragment.*
class MeditationTypeAdapter( class MeditationTypeAdapter(
...@@ -62,7 +64,7 @@ class MeditationTypeAdapter( ...@@ -62,7 +64,7 @@ class MeditationTypeAdapter(
holder.cvLayout?.setOnClickListener { holder.cvLayout?.setOnClickListener {
if (meditationType == 0){ if (meditationType == 0){
if (HomeIn.getUserService().loginByOneKeyLogin(context, true)) { if (!ModularServiceManager.provide(IUserService::class.java).loginByOneKeyLogin(context,true)) {
return@setOnClickListener return@setOnClickListener
} }
ARouter.getInstance().build("/muse/play") ARouter.getInstance().build("/muse/play")
......
...@@ -2,6 +2,7 @@ package com.yidianling.home.ui.view ...@@ -2,6 +2,7 @@ package com.yidianling.home.ui.view
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.Color
import android.graphics.Typeface import android.graphics.Typeface
import android.media.MediaPlayer import android.media.MediaPlayer
import android.text.SpannableString import android.text.SpannableString
...@@ -14,12 +15,10 @@ import androidx.recyclerview.widget.RecyclerView ...@@ -14,12 +15,10 @@ import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.google.gson.Gson
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.utils.Utils import com.ydl.ydlcommon.utils.Utils
import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.MeditationViewPagerAdapter import com.yidianling.home.MeditationViewPagerAdapter
import com.yidianling.home.R import com.yidianling.home.R
import com.yidianling.home.constract.HomeViewConfig import com.yidianling.home.constract.HomeViewConfig
...@@ -92,10 +91,11 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -92,10 +91,11 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
.into(iv_video_background) .into(iv_video_background)
}else{ }else{
GlideApp.with(this) GlideApp.with(this)
.load(videoUrl) .load(bean.mditationIndexInfo?.mditationIndexUrl)
.into(iv_video_background) .into(iv_video_background)
video_view?.setVideoPath(videoUrl) video_view?.setVideoPath(videoUrl)
video_view?.setOnErrorListener { mp, what, extra -> video_view?.setOnErrorListener { mp, what, extra ->
Glide.with(this) Glide.with(this)
.load(bean.mditationIndexInfo?.mditationIndexUrl) .load(bean.mditationIndexInfo?.mditationIndexUrl)
...@@ -106,7 +106,8 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -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) it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
video_view?.setOnInfoListener { mp, what, extra -> video_view?.setOnInfoListener { mp, what, extra ->
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START){ 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 true
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
android:id="@+id/iv_video_background" android:id="@+id/iv_video_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitXY" /> android:scaleType="fitCenter"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -13,7 +13,6 @@ import com.ydl.ydlcommon.base.BaseActivity ...@@ -13,7 +13,6 @@ import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.ThrowableConsumer import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.event.MeditationEvent 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.setTransparentForImageView
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import com.ydl.ydlcommon.utils.Utils import com.ydl.ydlcommon.utils.Utils
...@@ -25,7 +24,6 @@ import com.yidianling.muse.utils.MediaPlayerTimeUtil ...@@ -25,7 +24,6 @@ import com.yidianling.muse.utils.MediaPlayerTimeUtil
import com.yidianling.muse.widget.QuitMeditationDialog import com.yidianling.muse.widget.QuitMeditationDialog
import com.yidianling.muse.widget.ShareMeditationDialog import com.yidianling.muse.widget.ShareMeditationDialog
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
import de.greenrobot.event.ThreadMode
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
...@@ -153,7 +151,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -153,7 +151,6 @@ class PlayMeditationActivity : BaseActivity() {
} }
) )
initMediaPlayer(mediaUrl, currentPosition) initMediaPlayer(mediaUrl, currentPosition)
} }
} }
...@@ -167,7 +164,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -167,7 +164,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseHttp.getInstance().getMeditationPlayDetail( MuseHttp.getInstance().getMeditationPlayDetail(
meditionType = 1, meditionType = 1,
mediaId = mediaId!!, mediaId = mediaId!!,
meditationId = 1 meditationId = meditationId!!
) )
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
...@@ -532,6 +529,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -532,6 +529,9 @@ class PlayMeditationActivity : BaseActivity() {
exo_play.setImageResource(R.drawable.icon_pause_meditation) exo_play.setImageResource(R.drawable.icon_pause_meditation)
false false
} }
if (mMediaPlayer?.isPlaying == true){
mMediaPlayer?.pause()
}
} }
} }
...@@ -558,7 +558,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -558,7 +558,7 @@ class PlayMeditationActivity : BaseActivity() {
private fun initMediaPlayer(path: String, current: Int) { 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)?.getAudioPath() == path
) { ) {
MediaPlayerManager.getInstance(this)?.play() MediaPlayerManager.getInstance(this)?.play()
...@@ -573,7 +573,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -573,7 +573,7 @@ class PlayMeditationActivity : BaseActivity() {
val currentPosition = mMediaPlayer?.currentPosition val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0 duration = mMediaPlayer?.duration ?: 0
if (current != null && current > 0) { if (current > 0) {
mMediaPlayer?.seekTo(current * 1000) mMediaPlayer?.seekTo(current * 1000)
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
seekbar_play_progress.progress = current seekbar_play_progress.progress = current
...@@ -583,13 +583,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -583,13 +583,9 @@ class PlayMeditationActivity : BaseActivity() {
seekbar_play_progress.progress = current seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(currentPosition / 1000) 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() { mTimer.schedule(object : TimerTask() {
override fun run() { override fun run() {
if (!isSeekbarChanging) { if (!isSeekbarChanging) {
...@@ -607,15 +603,13 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -607,15 +603,13 @@ class PlayMeditationActivity : BaseActivity() {
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
exo_play.setImageResource(R.drawable.icon_pause_play) exo_play.setImageResource(R.drawable.icon_pause_play)
true
} else { } else {
exo_play.setImageResource(R.drawable.icon_pause_meditation) exo_play.setImageResource(R.drawable.icon_pause_meditation)
false
} }
val currentPosition = mMediaPlayer?.currentPosition val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0 duration = mMediaPlayer?.duration ?: 0
if (current != null && current > 0) { if (current > 0) {
mMediaPlayer?.seekTo(current * 1000) mMediaPlayer?.seekTo(current * 1000)
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
seekbar_play_progress.progress = current seekbar_play_progress.progress = current
...@@ -626,9 +620,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -626,9 +620,7 @@ class PlayMeditationActivity : BaseActivity() {
exo_position.text = exo_position.text =
MediaPlayerTimeUtil.calculateTime(currentPosition / 1000) 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() { mTimer.schedule(object : TimerTask() {
override fun run() { override fun run() {
...@@ -695,7 +687,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -695,7 +687,6 @@ class PlayMeditationActivity : BaseActivity() {
} }
override fun onComplete() { override fun onComplete() {
show("倒计时结束,停止播放吧!")
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
mMediaPlayer?.stop() mMediaPlayer?.stop()
exo_play.setImageResource(R.drawable.icon_pause_meditation) exo_play.setImageResource(R.drawable.icon_pause_meditation)
......
package com.yidianling.muse.helper package com.yidianling.muse.helper
import android.content.Context import android.content.Context
import android.media.AudioManager
import android.media.MediaPlayer import android.media.MediaPlayer
import android.net.Uri import android.net.Uri
import java.io.IOException
import kotlin.properties.Delegates import kotlin.properties.Delegates
class MediaPlayerManager private constructor() { class MediaPlayerManager private constructor() {
...@@ -13,36 +11,36 @@ class MediaPlayerManager private constructor() { ...@@ -13,36 +11,36 @@ class MediaPlayerManager private constructor() {
fun setAudioPath(path: String){ fun setAudioPath(path: String){
mPath = path mPath = path
if(mMediaPlayer.isPlaying) mMediaPlayer.reset() mMediaPlayer?.reset()
mMediaPlayer.setDataSource(mContext, Uri.parse(path)) mMediaPlayer?.setDataSource(mContext, Uri.parse(path))
mMediaPlayer.prepareAsync() mMediaPlayer?.prepareAsync()
mMediaPlayer.setOnPreparedListener { mMediaPlayer?.setOnPreparedListener {
listener?.onPrepared(it) listener?.onPrepared(it)
} }
} }
fun getMediaPlayer():MediaPlayer = mMediaPlayer fun getMediaPlayer():MediaPlayer? = mMediaPlayer
fun getAudioPath():String? = mPath fun getAudioPath():String? = mPath
fun isPlaying() = mMediaPlayer.isPlaying fun isPlaying() = mMediaPlayer?.isPlaying
fun play() { fun play() {
if (mMediaPlayer.isPlaying) return if (mMediaPlayer?.isPlaying == true) return
mMediaPlayer.start() mMediaPlayer?.start()
} }
fun pause() { fun pause() {
if (mMediaPlayer.isPlaying) mMediaPlayer.pause() if (mMediaPlayer?.isPlaying == true) mMediaPlayer?.pause()
} }
fun seekTo(position: Int) { fun seekTo(position: Int) {
mMediaPlayer.seekTo(position) mMediaPlayer?.seekTo(position)
} }
fun stop() { fun stop() {
if (mMediaPlayer!!.isPlaying) { if (mMediaPlayer?.isPlaying == true) {
mMediaPlayer.reset() mMediaPlayer?.reset()
} }
} }
...@@ -58,7 +56,7 @@ class MediaPlayerManager private constructor() { ...@@ -58,7 +56,7 @@ class MediaPlayerManager private constructor() {
private var mContext: Context by Delegates.notNull() private var mContext: Context by Delegates.notNull()
private var mMediaPlayer:MediaPlayer by Delegates.notNull() private var mMediaPlayer:MediaPlayer? = null
private var mPath:String? = null private var mPath:String? = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment