Commit c1823cd6 by 范玉宾

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

D/lancet/4.3.93 muse

See merge request app_android_lib/YDL-Component!73
parents 32b354e7 b3b1f248
...@@ -14,7 +14,7 @@ ext { ...@@ -14,7 +14,7 @@ ext {
"m-dynamic" : "0.0.7.73", "m-dynamic" : "0.0.7.73",
"m-article" : "0.0.0.10", "m-article" : "0.0.0.10",
"m-muse" : "0.0.28.49", "m-muse" : "0.0.28.52",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
...@@ -99,7 +99,7 @@ ext { ...@@ -99,7 +99,7 @@ ext {
"m-dynamic" : "0.0.7.73", "m-dynamic" : "0.0.7.73",
"m-article" : "0.0.0.8", "m-article" : "0.0.0.8",
"m-muse" : "0.0.28.49", "m-muse" : "0.0.28.52",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
......
...@@ -60,7 +60,7 @@ dependencies { ...@@ -60,7 +60,7 @@ dependencies {
implementation 'com.github.weidongjian:androidWheelView:1.0.0' implementation 'com.github.weidongjian:androidWheelView:1.0.0'
implementation 'com.github.feeeei:CircleSeekbar:v1.1.2' implementation 'com.github.feeeei:CircleSeekbar:v1.1.2'
implementation 'jp.wasabeef:blurry:4.0.1' // implementation 'jp.wasabeef:blurry:4.0.1'
// solve build problem // solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory' // cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling // Comment out when compiling
......
...@@ -9,7 +9,6 @@ import com.ydl.ydlcommon.base.BaseActivity ...@@ -9,7 +9,6 @@ import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.R import com.yidianling.muse.R
import jp.wasabeef.blurry.Blurry
import kotlinx.android.synthetic.main.activity_play_meditation_time_off.* import kotlinx.android.synthetic.main.activity_play_meditation_time_off.*
import kotlinx.android.synthetic.main.activity_play_meditation_time_off.iv_close import kotlinx.android.synthetic.main.activity_play_meditation_time_off.iv_close
...@@ -25,15 +24,15 @@ class MeditationTimeOffActivity : BaseActivity() { ...@@ -25,15 +24,15 @@ class MeditationTimeOffActivity : BaseActivity() {
private fun initView() { private fun initView() {
Handler().postDelayed({ // Handler().postDelayed({
Blurry.with(this) // Blurry.with(this)
.radius(25) // .radius(25)
.sampling(1) // .sampling(1)
.color(Color.parseColor("#FF173F5D")) // .color(Color.parseColor("#FF173F5D"))
.async() // .async()
.capture(iv_bg) // .capture(iv_bg)
.into(iv_bg) // .into(iv_bg)
},300) // },300)
iv_close?.setOnClickListener { finish() } iv_close?.setOnClickListener { finish() }
......
...@@ -94,6 +94,12 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -94,6 +94,12 @@ class PlayMeditationActivity : BaseActivity() {
private var broadcastTime = 0 private var broadcastTime = 0
/**
* 传递过来的mediaId 用于判断正在播放的是否是同一条音频
*/
private var mMediaIdFromLocal: Long? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setTransparentForImageView(this, null) setTransparentForImageView(this, null)
statusBarLightMode(this) statusBarLightMode(this)
...@@ -107,7 +113,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -107,7 +113,7 @@ class PlayMeditationActivity : BaseActivity() {
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
mMediaId = intent?.getLongExtra("MEDIA_ID", 0L) mMediaIdFromLocal = intent?.getLongExtra("MEDIA_ID", 0L)
mMeditationId = intent?.getLongExtra("MEDITATION_ID", 0L) mMeditationId = intent?.getLongExtra("MEDITATION_ID", 0L)
mMeditationType = intent?.getIntExtra("MEDITATION_TYPE", 0) mMeditationType = intent?.getIntExtra("MEDITATION_TYPE", 0)
mMediaUrl = intent?.getStringExtra("MEDIA_URL") ?: "" mMediaUrl = intent?.getStringExtra("MEDIA_URL") ?: ""
...@@ -123,7 +129,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -123,7 +129,7 @@ class PlayMeditationActivity : BaseActivity() {
private fun getData() { private fun getData() {
updateUIByMeditationType() updateUIByMeditationType()
if (mMeditationId == null || (mMediaId == null && mMeditationType != 0)) { if (mMeditationId == null || (mMediaIdFromLocal == null && mMeditationType != 0)) {
return return
} }
// 声音详情 // 声音详情
...@@ -143,7 +149,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -143,7 +149,7 @@ class PlayMeditationActivity : BaseActivity() {
val mediaList = module.mediaList val mediaList = module.mediaList
if(!mediaList.isNullOrEmpty()){ if(!mediaList.isNullOrEmpty()){
val meditation = mediaList[0] val meditation = mediaList[0]
currentMeditation = meditation.copy(mMeditationType,mMeditationId) currentMeditation = meditation.copy(meditationType = mMeditationType,meditationId = mMeditationId!!)
mTitle = meditation.title mTitle = meditation.title
mDesc = meditation.desc?:"" mDesc = meditation.desc?:""
mMediaUrl = meditation.mediaUrl mMediaUrl = meditation.mediaUrl
...@@ -155,7 +161,11 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -155,7 +161,11 @@ class PlayMeditationActivity : BaseActivity() {
updateUI() updateUI()
initMediaPlayer(mMediaUrl, currentPosition) initMediaPlayer(
mMediaUrl,
currentPosition,
mMediaIdFromLocal == mMediaId
)
//快进点击事件 //快进点击事件
ActionCountUtils.baiDuCountSign3( ActionCountUtils.baiDuCountSign3(
...@@ -175,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -175,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() {
} else { } else {
MuseHttp.getInstance().getMeditationPlayDetail( MuseHttp.getInstance().getMeditationPlayDetail(
meditionType = 1, meditionType = 1,
mediaId = mMediaId!!, mediaId = mMediaIdFromLocal!!,
meditationId = mMeditationId!! meditationId = mMeditationId!!
) )
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
...@@ -196,7 +206,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -196,7 +206,7 @@ class PlayMeditationActivity : BaseActivity() {
if (meditationPlayBean.mediaId == mMediaId) { if (meditationPlayBean.mediaId == mMediaId) {
currentMeditation = currentMeditation =
meditationPlayBean.copy(meditationId = mMeditationId!!) meditationPlayBean.copy(meditationType = mMeditationType,meditationId = mMeditationId!!)
mMediaId = module?.mediaId ?: 0L mMediaId = module?.mediaId ?: 0L
mTitle = meditationPlayBean.title mTitle = meditationPlayBean.title
...@@ -218,7 +228,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -218,7 +228,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI() updateUI()
initMediaPlayer(mMediaUrl, currentPosition) initMediaPlayer(mMediaUrl, currentPosition,mMediaIdFromLocal == mMediaId)
} }
} }
} }
...@@ -553,7 +563,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -553,7 +563,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI() updateUI()
initMediaPlayer(mMediaUrl, currentPosition) initMediaPlayer(mMediaUrl, currentPosition, mMediaIdFromLocal == mMediaId)
} else { } else {
ToastUtil.toastShort("当前已经是第一首") ToastUtil.toastShort("当前已经是第一首")
} }
...@@ -592,7 +602,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -592,7 +602,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI() updateUI()
initMediaPlayer(mMediaUrl, currentPosition) initMediaPlayer(mMediaUrl, currentPosition, mMediaIdFromLocal == mMediaId)
} else { } else {
ToastUtil.toastShort("当前已经是最后一首") ToastUtil.toastShort("当前已经是最后一首")
} }
...@@ -741,15 +751,11 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -741,15 +751,11 @@ class PlayMeditationActivity : BaseActivity() {
} }
} }
private fun initMediaPlayer(path: String, current: Int) { private fun initMediaPlayer(path: String, current: Int, isSameOne: Boolean = false) {
// val event = MeditationFloatEvent(show = false,stop = false,meditation = currentMeditation)
// EventBus.getDefault().post(event)
if (MediaPlayerManager.getInstance(this)?.getAudioPath() != null if (MediaPlayerManager.getInstance(this)?.getAudioPath()!=null &&
&& MediaPlayerManager.getInstance(this)?.getAudioPath() == path MediaPlayerManager.getInstance(this)?.getMediaId() == mMediaId
) { ) {
MediaPlayerManager.getInstance(this)?.play()
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
exo_play.setImageResource(R.drawable.icon_pause_play) exo_play.setImageResource(R.drawable.icon_pause_play)
} else { } else {
...@@ -759,7 +765,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -759,7 +765,6 @@ class PlayMeditationActivity : BaseActivity() {
val currentPosition = mMediaPlayer?.currentPosition val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0 duration = mMediaPlayer?.duration ?: 0
if (current > 0) { if (current > 0) {
mMediaPlayer?.seekTo(current * 1000)
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
seekbar_play_progress.progress = current seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(current) exo_position.text = MediaPlayerTimeUtil.calculateTime(current)
...@@ -932,7 +937,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -932,7 +937,7 @@ class PlayMeditationActivity : BaseActivity() {
if (event.mediaUrl == MediaPlayerManager.getInstance(this)?.getAudioPath()) { if (event.mediaUrl == MediaPlayerManager.getInstance(this)?.getAudioPath()) {
return return
} }
initMediaPlayer(event.mediaUrl, 0) initMediaPlayer(event.mediaUrl, 0, mMediaIdFromLocal == mMediaId)
} }
} }
......
...@@ -15,6 +15,14 @@ class MediaPlayerManager private constructor() { ...@@ -15,6 +15,14 @@ class MediaPlayerManager private constructor() {
private var mMediaPlayCallBack:MediaPlayCallBack?=null private var mMediaPlayCallBack:MediaPlayCallBack?=null
private var mAudioPaths = mutableListOf<String>() 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){ fun setAudioPath(path: String,isLoop:Boolean = false){
val attrs = AudioAttributes.Builder() val attrs = AudioAttributes.Builder()
...@@ -56,11 +64,11 @@ class MediaPlayerManager private constructor() { ...@@ -56,11 +64,11 @@ class MediaPlayerManager private constructor() {
} }
fun stop() { fun stop() {
mMediaPlayer?.reset() mMediaPlayer?.stop()
} }
fun release() { fun release() {
mMediaPlayer?.reset() mMediaPlayer?.stop()
} }
fun setOnPreparedListener(listener: OnMediaPlayerManagerListener){ fun setOnPreparedListener(listener: OnMediaPlayerManagerListener){
......
...@@ -70,10 +70,10 @@ class MeditationWindowService : LifecycleService() { ...@@ -70,10 +70,10 @@ class MeditationWindowService : LifecycleService() {
private var mObservable: Observable<Long>? = null private var mObservable: Observable<Long>? = null
private var mObserver: Observer<Long>? = null private var mObserver: Observer<Long>? = null
private var mProgressTimer = Timer()
private lateinit var mSeekBar : AppCompatSeekBar private lateinit var mSeekBar : AppCompatSeekBar
private var currentMediaId:Long? = null
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
...@@ -157,6 +157,10 @@ class MeditationWindowService : LifecycleService() { ...@@ -157,6 +157,10 @@ class MeditationWindowService : LifecycleService() {
} }
private fun updateFloatView(meditation: MeditationPlayModuleBean.MeditationDetail) { private fun updateFloatView(meditation: MeditationPlayModuleBean.MeditationDetail) {
currentMediaId = meditation.mediaId
MediaPlayerManager.getInstance(this)?.setMediaId(currentMediaId)
mMediaPlayer = MediaPlayerManager.getInstance(this)?.getMediaPlayer() mMediaPlayer = MediaPlayerManager.getInstance(this)?.getMediaPlayer()
floatRootView?.setOnClickListener { floatRootView?.setOnClickListener {
//悬浮窗暂停点击事件 //悬浮窗暂停点击事件
...@@ -168,8 +172,6 @@ class MeditationWindowService : LifecycleService() { ...@@ -168,8 +172,6 @@ class MeditationWindowService : LifecycleService() {
intent.putExtra("MEDITATION_TYPE", meditation.meditationType) intent.putExtra("MEDITATION_TYPE", meditation.meditationType)
intent.putExtra("MEDIA_COVER_URL", meditation.coverImageUrl) intent.putExtra("MEDIA_COVER_URL", meditation.coverImageUrl)
intent.putExtra("MEDIA_URL", meditation.mediaUrl) intent.putExtra("MEDIA_URL", meditation.mediaUrl)
intent.putExtra("BROAD_CAST_TIME",
(ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0)
intent.flags = FLAG_ACTIVITY_NEW_TASK intent.flags = FLAG_ACTIVITY_NEW_TASK
startActivity(intent) startActivity(intent)
......
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