Commit 81b3ba15 by 范玉宾

meditation type error when enter playDetail from floatView

parent 1669b637
......@@ -116,9 +116,9 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
it?.start()
it?.setVolume(0.0F, 0.0F)
}
video_view?.setOnCompletionListener { video_view?.start() }
video_view?.setOnCompletionListener { video_view?.start() }
bean.mditationListResponse?.forEach {
meditationTitles.add(it.comment)
......
......@@ -21,21 +21,19 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#999999">
android:layout_height="match_parent">
<com.yidianling.home.widget.AdaptiveVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false" />
android:focusableInTouchMode="false"/>
<!-- <ImageView-->
<!-- android:id="@+id/iv_video_background"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:scaleType="fitCenter"/>-->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88999999"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
......
package com.yidianling.muse.activity
//import com.yidianling.muse.dialog.ChooseMusicDialog
import android.content.Intent
import android.graphics.Color
import android.media.MediaPlayer
import android.os.Bundle
import android.os.Handler
......@@ -12,8 +12,6 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.event.MeditationEvent
......@@ -29,7 +27,6 @@ import com.yidianling.home.http.MuseHttp
import com.yidianling.muse.R
import com.yidianling.muse.bean.MeditationPlayModuleBean
import com.yidianling.muse.constants.MuseBIConstants
//import com.yidianling.muse.dialog.ChooseMusicDialog
import com.yidianling.muse.event.MeditationFloatEvent
import com.yidianling.muse.helper.MediaPlayerManager
import com.yidianling.muse.utils.MediaPlayerTimeUtil
......@@ -44,7 +41,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import jp.wasabeef.blurry.Blurry
import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlinx.android.synthetic.main.activity_play_meditation.iv_close
import kotlinx.android.synthetic.main.activity_play_meditation.tv_title
......@@ -58,25 +54,24 @@ import kotlin.math.roundToInt
@Route(path = "/muse/play")
class PlayMeditationActivity : BaseActivity() {
private var meditationId: Long? = null
private var meditationType: Int? = null
private var mediaId: Long? = null
private var mediaUrl = ""
private var mediaCoverUrl = ""
private var mMeditationId: Long? = null
private var mMeditationType: Int? = null
private var mMediaId: Long? = null
private var mMediaUrl = ""
private var mMediaCoverUrl = ""
private var mTitle = ""
private var mDesc = ""
private var mStatus = 0
private var businessType = 0
private var mBusinessType = 0
private var mediaListLink: String? = null
private var mediaListLink = ""
private var meditations = mutableListOf<MeditationPlayModuleBean.MeditationDetail>()
private var currentMeditation: MeditationPlayModuleBean.MeditationDetail? = null
private var currentMeditationIndex = 0
private var shareTitle = ""
private var shareUrl = ""
private var shareContent = ""
private var shareImageUrl = ""
private var collected = false
private var isPlaying = false
......@@ -94,8 +89,9 @@ class PlayMeditationActivity : BaseActivity() {
private var mObservable: Observable<Long>? = null
private var mObserver: Observer<Long>? = null
private var status = 0
private var buried: String? = null
private var mBuried: String? = null
private var broadcastTime = 0
override fun onCreate(savedInstanceState: Bundle?) {
setTransparentForImageView(this, null)
......@@ -110,11 +106,12 @@ class PlayMeditationActivity : BaseActivity() {
EventBus.getDefault().register(this)
mediaId = intent?.getLongExtra("MEDIA_ID", 0L)
meditationId = intent?.getLongExtra("MEDITATION_ID", 0L)
meditationType = intent?.getIntExtra("MEDITATION_TYPE", 0)
mediaUrl = intent?.getStringExtra("MEDIA_URL") ?: ""
mediaCoverUrl = intent?.getStringExtra("MEDIA_COVER_URL") ?: ""
mMediaId = intent?.getLongExtra("MEDIA_ID", 0L)
mMeditationId = intent?.getLongExtra("MEDITATION_ID", 0L)
mMeditationType = intent?.getIntExtra("MEDITATION_TYPE", 0)
mMediaUrl = intent?.getStringExtra("MEDIA_URL") ?: ""
mMediaCoverUrl = intent?.getStringExtra("MEDIA_COVER_URL") ?: ""
broadcastTime = intent?.getIntExtra("BROAD_CAST_TIME",0)?:0
initView()
getData()
......@@ -126,72 +123,48 @@ class PlayMeditationActivity : BaseActivity() {
private fun getData() {
updateUIByMeditationType()
if (meditationType == null || (mediaId == null && meditationType != 0)) {
if (mMeditationId == null || (mMediaId == null && mMeditationType != 0)) {
return
}
// 声音详情
if (meditationType == 0) {
if (mMeditationType == 0) {
MuseHttp.getInstance().getPureMusicPlayDetail(
meditionType = meditationType!!,
meditationId = meditationId!!
meditionType = mMeditationType!!,
meditationId = mMeditationId!!
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (it.code.equals("200") && it.data != null) {
val module = it.data
mediaId = module.mediaId
mediaListLink = module.playDetailUrl
module.mediaList?.forEach { meditationPlayBean ->
if (meditationPlayBean.mediaId == mediaId) {
currentMeditation = meditationPlayBean.copy(
mediaType = meditationType,
meditationId = meditationId!!
)
mediaId = module?.mediaId ?: 0L
val title = meditationPlayBean.title ?: "未知标题"
val desc = meditationPlayBean.desc ?: ""
val mediaUrl = meditationPlayBean.mediaUrl
val currentPosition = meditationPlayBean.broadcastTime
businessType = meditationPlayBean.businessType
status = meditationPlayBean.status
buried = meditationPlayBean.buried
collected = status == 1
tv_title.text = title
tv_content.text = desc
shareTitle = title
shareContent = desc
shareUrl = mediaUrl
iv_collect.setImageResource(
if (status == 0) {
R.drawable.icon_play_meditation_collect
} else {
R.drawable.icon_meditation_collected
}
)
initMediaPlayer(mediaUrl, currentPosition)
//快进点击事件
mMediaId = module.mediaId
mediaListLink = module.playDetailUrl?:""
val mediaList = module.mediaList
if(!mediaList.isNullOrEmpty()){
val meditation = mediaList[0]
currentMeditation = meditation.copy(mMeditationType,mMeditationId)
mTitle = meditation.title
mDesc = meditation.desc?:""
mMediaUrl = meditation.mediaUrl
mMediaCoverUrl = meditation.coverImageUrl
val currentPosition = meditation.broadcastTime
mBusinessType = meditation.businessType
mBuried = meditation.buried
mStatus = meditation.status
updateUI()
initMediaPlayer(mTitle, currentPosition)
//快进点击事件
ActionCountUtils.baiDuCountSign3(
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PAGE_VISIT,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
}
}
}
}, object : ThrowableConsumer() {
......@@ -199,11 +172,11 @@ class PlayMeditationActivity : BaseActivity() {
show(msg)
}
})
} else if (meditationType == 1) {
} else if (mMeditationType == 1) {
MuseHttp.getInstance().getMeditationPlayDetail(
meditionType = 1,
mediaId = mediaId!!,
meditationId = meditationId!!
mediaId = mMediaId!!,
meditationId = mMeditationId!!
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -212,7 +185,7 @@ class PlayMeditationActivity : BaseActivity() {
if (it.code.equals("200") && it.data != null) {
val module = it.data
mediaId = module.mediaId
mMediaId = module.mediaId
meditations.clear()
......@@ -220,50 +193,32 @@ class PlayMeditationActivity : BaseActivity() {
meditations.add(meditationPlayBean)
if (meditationPlayBean.mediaId == mediaId) {
if (meditationPlayBean.mediaId == mMediaId) {
currentMeditation =
meditationPlayBean.copy(meditationId = meditationId!!)
mediaId = module?.mediaId ?: 0L
val title = meditationPlayBean.title
val desc = meditationPlayBean.desc ?: ""
meditationPlayBean.copy(meditationId = mMeditationId!!)
val bgImageUrl = meditationPlayBean.coverImageUrl
mMediaId = module?.mediaId ?: 0L
mTitle = meditationPlayBean.title
mDesc = meditationPlayBean.desc ?: ""
Glide.with(this)
.load(bgImageUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.into(iv_bg)
mMediaCoverUrl = meditationPlayBean.coverImageUrl
val mediaUrl = meditationPlayBean.mediaUrl
mMediaUrl = meditationPlayBean.mediaUrl
val currentPosition = meditationPlayBean.broadcastTime
businessType = meditationPlayBean.businessType
mBusinessType = meditationPlayBean.businessType
status = meditationPlayBean.status
mStatus = meditationPlayBean.status
buried = meditationPlayBean.buried
mBuried = meditationPlayBean.buried
collected = status == 1
collected = mStatus == 1
tv_title.text = title
tv_content.text = desc
updateUI()
shareTitle = title
shareContent = desc
shareUrl = mediaUrl
iv_collect.setImageResource(
if (status == 0) {
R.drawable.icon_play_meditation_collect
} else {
R.drawable.icon_meditation_collected
}
)
initMediaPlayer(mediaUrl, currentPosition)
initMediaPlayer(mMediaUrl, currentPosition)
}
}
}
......@@ -280,7 +235,7 @@ class PlayMeditationActivity : BaseActivity() {
EventBus.getDefault().post(event)
// 声音类型
if (meditationType == 0) {
if (mMeditationType == 0) {
exo_rew.visibility = View.GONE
exo_ffwd.visibility = View.GONE
exo_prev.visibility = View.GONE
......@@ -318,7 +273,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_LIST_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
if (!mediaListLink.isNullOrBlank()) {
......@@ -338,7 +293,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_COLLECT_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
......@@ -347,11 +302,11 @@ class PlayMeditationActivity : BaseActivity() {
) {
return@setOnClickListener
}
if (meditationId == null || mediaId == null) return@setOnClickListener
if (mMeditationId == null || mMediaId == null) return@setOnClickListener
MuseHttp.getInstance().collectMeditation(
meditationId = meditationId!!,
mediaId = mediaId!!,
status = if (collected) 0 else 1, businessType = businessType
meditationId = mMeditationId!!,
mediaId = mMediaId!!,
status = if (collected) 0 else 1, businessType = mBusinessType
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -384,55 +339,74 @@ class PlayMeditationActivity : BaseActivity() {
private fun initView() {
shareImageUrl = mediaCoverUrl
Glide.with(this)
.load(mediaCoverUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.into(iv_bg)
iv_close.setOnClickListener {
//关闭点击事件
ActionCountUtils.baiDuCountSign3(
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_CLOSE_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
if (quitDialog == null) {
quitDialog = QuitMeditationDialog.newInstance()
}
if (quitDialog != null && quitDialog?.isAdded == false) {
quitDialog?.setListener(object : QuitMeditationDialog.ClickListener {
override fun quit() {
stopPlay()
if (meditationId != null && mediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = meditationId!!.toInt(),
isQuit = 1, mediaId = mediaId!!,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 0
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if(mMeditationType == 0){
stopPlay()
if (mMeditationId != null && mMediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = mMeditationId!!.toInt(),
isQuit = 1, mediaId = mMediaId!!,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 0
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
finish()
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
finish()
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
finish()
}
}
})
} else {
finish()
}
}else{
if (quitDialog == null) {
quitDialog = QuitMeditationDialog.newInstance()
}
if (quitDialog != null && quitDialog?.isAdded == false) {
quitDialog?.setListener(object : QuitMeditationDialog.ClickListener {
override fun quit() {
stopPlay()
if (mMeditationId != null && mMediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = mMeditationId!!.toInt(),
isQuit = 1, mediaId = mMediaId!!,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 0
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
finish()
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
finish()
}
}
}
})
} else {
finish()
})
} else {
finish()
}
}
}
})
quitDialog?.show(supportFragmentManager, QuitMeditationDialog.TAG)
})
quitDialog?.show(supportFragmentManager, QuitMeditationDialog.TAG)
}
}
}
iv_back.setOnClickListener {
......@@ -441,10 +415,11 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PACK_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
val event = MeditationFloatEvent(true, meditationDetail = currentMeditation)
val event = MeditationFloatEvent(true,
meditationDetail = currentMeditation?.copy(meditationType = mMeditationType))
EventBus.getDefault().post(event)
Handler().postDelayed({
......@@ -458,16 +433,16 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_SHARE_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
if (shareDialog == null) {
shareDialog = ShareMeditationDialog
.newInstance(
shareTitle = shareTitle,
shareContent = shareContent,
shareUrl = shareUrl,
shareImageUrl = shareImageUrl
shareTitle = mTitle,
shareContent = mDesc,
shareUrl = mMediaUrl,
shareImageUrl = mMediaCoverUrl
)
}
if (shareDialog != null && shareDialog?.isAdded == false) {
......@@ -482,7 +457,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_IOC_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
startActivityForResult(
......@@ -497,7 +472,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_IOC_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
startActivityForResult(
......@@ -509,18 +484,23 @@ class PlayMeditationActivity : BaseActivity() {
exo_play.setOnClickListener {
if (isPlaying) {
mMediaPlayer?.pause()
if (meditationId == null || mediaId == null) return@setOnClickListener
postPlayRecord(
if (mMeditationId == null || mMediaId == null) return@setOnClickListener
val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt()
MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId?.toInt(),
mediaId = mMediaId,
isQuit = 0,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
playTime = playTime,
isComplete = 0
)
//暂停埋点
ActionCountUtils.baiDuCountSign3(
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PAUSE_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
......@@ -546,7 +526,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PLAY_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
}
......@@ -565,40 +545,34 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_LAST_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
val currentPosition = meditations.indexOf(currentMeditation)
if (currentPosition > 0) {
if (meditationId == null || mediaId == null) return@setOnClickListener
postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0)
if (mMeditationId == null || mMediaId == null) return@setOnClickListener
val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt()
MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId?.toInt(),
mediaId = mMediaId,
isQuit = 0,
playTime = playTime,
isComplete = 0
)
val meditation = meditations[currentPosition - 1]
currentMeditation = meditation.copy(meditationId = meditationId!!)
currentMeditation = meditation.copy(meditationId = mMeditationId!!)
mediaId = meditation.mediaId
val mediaCoverUrl = meditation.coverImageUrl
val mediaUrl = meditation.mediaUrl
mMediaId = meditation.mediaId
mMediaCoverUrl = meditation.coverImageUrl
mMediaUrl = meditation.mediaUrl
val currentPosition = meditation.broadcastTime
val status = meditation.status
mStatus = meditation.status
Glide.with(this)
.load(mediaCoverUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.into(iv_bg)
updateUI()
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
}
)
initMediaPlayer(mediaUrl, currentPosition)
initMediaPlayer(mMediaUrl, currentPosition)
} else {
ToastUtil.toastShort("当前已经是第一首")
}
......@@ -610,40 +584,34 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_NEXT_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
val currentPosition = meditations.indexOf(currentMeditation)
if (currentPosition < meditations.size - 1) {
if (meditationId == null || mediaId == null) return@setOnClickListener
postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0)
if (mMeditationId == null || mMediaId == null) return@setOnClickListener
val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt()
MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId?.toInt(),
mediaId = mMediaId,
isQuit = 0,
playTime = playTime,
isComplete = 0
)
val meditation = meditations[currentPosition + 1]
currentMeditation = meditation
mediaId = meditation.mediaId
val mediaCoverUrl = meditation.coverImageUrl
val mediaUrl = meditation.mediaUrl
mMediaId = meditation.mediaId
mMediaCoverUrl = meditation.coverImageUrl
mMediaUrl = meditation.mediaUrl
val currentPosition = meditation.broadcastTime
val status = meditation.status
mStatus = meditation.status
Glide.with(this)
.load(mediaCoverUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.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
}
)
updateUI()
initMediaPlayer(mediaUrl, currentPosition)
initMediaPlayer(mMediaUrl, currentPosition)
} else {
ToastUtil.toastShort("当前已经是最后一首")
}
......@@ -655,7 +623,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_REW_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
val currentPosition = MediaPlayerManager
......@@ -672,7 +640,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_SPEED_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
val currentPosition = MediaPlayerManager
......@@ -701,7 +669,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PROGRESS_CLICK,
currentMeditation?.title ?: "",
buried ?: "",
mBuried ?: "",
""
)
isSeekbarChanging = true
......@@ -733,13 +701,16 @@ class PlayMeditationActivity : BaseActivity() {
}
private fun initPlayCompletionListener(isLoop: Boolean = false, isSingle: Boolean = false) {
mMediaPlayer?.setOnCompletionListener {
postPlayRecord(
val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt()
MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId?.toInt(),
mediaId = mMediaId,
isQuit = 0,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 1)
playTime = playTime,
isComplete = 1
)
if (isLoop){
if (isSingle || meditations.size == 1){
......@@ -756,11 +727,11 @@ class PlayMeditationActivity : BaseActivity() {
currentMeditation = meditations[currentMeditationIndex]
val event = MeditationEvent(
currentMeditation?.mediaId?.toInt()?:0,
meditationId?:0L,
meditationType?:0,
businessType,
status = status,
buried = buried?:"",
mMeditationId?:0L,
mMeditationType?:0,
mBusinessType,
status = mStatus,
buried = mBuried?:"",
mediaUrl = currentMeditation?.mediaUrl?:"",
mediaCoverUrl = currentMeditation?.coverImageUrl?:"",
title = currentMeditation?.title?:"",
......@@ -783,26 +754,6 @@ class PlayMeditationActivity : BaseActivity() {
}
}
private fun postPlayRecord(isQuit: Int, playTime: Int, isComplete: Int) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = meditationId!!.toInt(),
isQuit = isQuit, mediaId = mediaId!!,
playTime = playTime,
isComplete = isComplete
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
}
}
})
}
private fun initMediaPlayer(path: String, current: Int) {
if (MediaPlayerManager.getInstance(this)?.getAudioPath() != null
......@@ -885,7 +836,7 @@ class PlayMeditationActivity : BaseActivity() {
if (resultCode == RESULT_OK && request_code == requestCode) {
val minute = data?.extras?.getInt("TIME_OFF_MINUTE", 0)
if (minute != null && minute > 0) {
if (meditationType == 0) {
if (mMeditationType == 0) {
initPlayCompletionListener(isLoop = true, isSingle = true)
tv_time_off_pure_music.visibility = View.VISIBLE
tv_time_off.visibility = View.GONE
......@@ -912,6 +863,22 @@ class PlayMeditationActivity : BaseActivity() {
}
}
private fun updateUI(){
tv_title.text = mTitle
tv_content.text = mDesc
Glide.with(this)
.load(mMediaCoverUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.into(iv_bg)
iv_collect.setImageResource(
if (mStatus == 0) {
R.drawable.icon_play_meditation_collect
} else {
R.drawable.icon_meditation_collected
}
)
}
private fun initRxTimeOff(time: Long, meditationType: Int) {
mObservable = Observable.interval(0, 1, TimeUnit.SECONDS)
.take(time / 1000 + 1)
......@@ -962,27 +929,15 @@ class PlayMeditationActivity : BaseActivity() {
fun onEventMainThread(event: MeditationEvent) {
if (event != null) {
Glide.with(this)
.load(event.mediaCoverUrl)
.transition(DrawableTransitionOptions.withCrossFade())
.into(iv_bg)
tv_title.text = event.title
tv_content.text = event.desc
shareTitle = event.title
shareContent = event.desc
shareUrl = event.mediaUrl
shareImageUrl = event.mediaCoverUrl
val status = event.status
iv_collect.setImageResource(
if (status == 0) {
R.drawable.icon_play_meditation_collect
} else {
R.drawable.icon_meditation_collected
}
)
mTitle = event.title
mDesc = event.desc
mMediaUrl = event.mediaUrl
mMediaCoverUrl = event.mediaCoverUrl
mStatus = event.status
updateUI()
if (event.mediaUrl == MediaPlayerManager.getInstance(this)?.getAudioPath()) {
return
......
......@@ -16,7 +16,7 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
var mediaList: ArrayList<MeditationDetail>? = null
data class MeditationDetail(
val mediaType:Int? = null,
val meditationType:Int? = null,
val mediaId:Long?=null,
val meditationId:Long,
val title:String,
......
......@@ -7,4 +7,5 @@ class MeditationFloatEvent(
val stop: Boolean?=null,
val time:Long?=null,
val meditationDetail: MeditationPlayModuleBean.MeditationDetail?=null
)
\ No newline at end of file
)
......@@ -143,7 +143,6 @@ class MeditationWindowService : LifecycleService() {
}
}
}
private fun updateFloatView(meditation: MeditationPlayModuleBean.MeditationDetail) {
......@@ -155,8 +154,12 @@ class MeditationWindowService : LifecycleService() {
val intent = Intent(this, PlayMeditationActivity::class.java)
intent.putExtra("MEDIA_ID", meditation.mediaId)
intent.putExtra("MEDITATION_ID", meditation.meditationId)
intent.putExtra("MEDITATION_TYPE", meditation.mediaType)
intent.putExtra("MEDITATION_TYPE", meditation.meditationType)
intent.putExtra("MEDIA_COVER_URL", meditation.coverImageUrl)
intent.putExtra("MEDIA_URL", meditation.mediaUrl)
intent.putExtra("BROAD_CAST_TIME",
(ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0)
intent.flags = FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
......@@ -279,6 +282,7 @@ class MeditationWindowService : LifecycleService() {
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this)
}
mDisposable?.dispose()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
stopForeground(true)
}
......@@ -328,7 +332,6 @@ class MeditationWindowService : LifecycleService() {
}
private fun postPlayRecord(
isQuit: Int,
playTime: Int,
......
package com.yidianling.muse.utils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.yidianling.home.http.MuseHttp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
class MediaPlayerTimeUtil {
companion object{
......@@ -64,6 +69,29 @@ class MediaPlayerTimeUtil {
}
fun uploadPlayRecord(meditationId:Int?,mediaId:Long?,
isQuit:Int,playTime:Int,isComplete:Int){
if (meditationId != null && mediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = meditationId!!.toInt(),
isQuit = isQuit, mediaId = mediaId!!,
playTime = playTime,
isComplete = isComplete
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
}
}
})
}
}
}
}
\ No newline at end of file
......@@ -493,7 +493,7 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
jtv_test?.postDelayed({ YdlBuryPointUtil.sendClick("ClickEvent") }, 500)
} else if (id == R.id.ll_meditation) { //冥想
count(UserMyPageEvent.YDL_USER_MY_MIDDLE_TYPE_CLICK, "冥想")
val h5Params3 = H5Params(MH5_URL + "meditation?hideNavBar=1", null)
val h5Params3 = H5Params(MH5_URL + "meditation/list?hideNavBar=1", null)
NewH5Activity.start(activity, h5Params3)
}
}
......
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