Commit 004e2b7f by 范玉宾

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

fix play record bug

See merge request app_android_lib/YDL-Component!59
parents a0f8b9d0 7aea9a74
......@@ -22,11 +22,14 @@ import com.ydl.media.view.PlayTypeEnum;
import com.ydl.media.view.PlayerFloatHelper;
import com.ydl.ydlcommon.utils.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.muse.event.MeditationFloatEvent;
import java.util.HashMap;
import java.util.Locale;
import java.util.Objects;
import de.greenrobot.event.EventBus;
/**
* Created by haorui on 2019-10-28 .
* Des:
......@@ -61,6 +64,7 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
EventBus.getDefault().register(this);
initPlayMode();
onChangeImpl(AudioPlayer.Companion.get().getPlayMusic());
AudioPlayer.Companion.get().addOnPlayEventListener(this);
......@@ -261,6 +265,9 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
public void onDestroy() {
AudioPlayer.Companion.get().removeOnPlayEventListener(this);
PlayerFloatHelper.Companion.onDestroy();
if(EventBus.getDefault().isRegistered(this)){
EventBus.getDefault().unregister(this);
}
super.onDestroy();
}
......@@ -290,4 +297,9 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
ivPrev = bindSource.findViewById(R.id.iv_prev);
ivCover = bindSource.findViewById(R.id.iv_cover);
}
public void onEventMainThread(MeditationFloatEvent event){
}
}
......@@ -77,6 +77,8 @@
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="14dp"
app:tabTextColor="#88FFFFFF"
app:tabSelectedTextColor="#FFFFFF"
style="@style/MeditationTabLayoutStyle" />
<androidx.viewpager2.widget.ViewPager2
......
......@@ -20,14 +20,14 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="#88000000">
<ImageView
android:id="@+id/iv_meditation_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:src="@drawable/play_page_default_bg" />
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/tv_meditation_type"
......@@ -35,6 +35,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
tools:text="溪流"
android:singleLine="true"
android:ellipsize="end"
android:textColor="@color/white"
android:textSize="14sp"
android:layout_marginStart="6dp"
......
......@@ -60,6 +60,7 @@ dependencies {
implementation 'com.github.weidongjian:androidWheelView:1.0.0'
implementation 'com.github.feeeei:CircleSeekbar:v1.1.2'
implementation 'jp.wasabeef:blurry:4.0.1'
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling
......
package com.yidianling.muse.activity
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import com.blankj.utilcode.util.SPUtils
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
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.iv_close
class MeditationTimeOffActivity : BaseActivity() {
......@@ -20,6 +24,17 @@ class MeditationTimeOffActivity : BaseActivity() {
}
private fun initView() {
Handler().postDelayed({
Blurry.with(this)
.radius(25)
.sampling(1)
.color(Color.parseColor("#FF173F5D"))
.async()
.capture(iv_bg)
.into(iv_bg)
},300)
iv_close?.setOnClickListener { finish() }
tv_save_setting?.setOnClickListener {
......
package com.yidianling.muse.activity
import android.content.Intent
import android.graphics.Color
import android.media.MediaPlayer
import android.os.Bundle
import android.os.Handler
......@@ -41,6 +42,7 @@ 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
......@@ -731,36 +733,35 @@ class PlayMeditationActivity : BaseActivity() {
postPlayRecord(
isQuit = 0,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 1
)
if (isLoop) {
if (isSingle || meditations.size == 1) {
MediaPlayerManager.getInstance(this)
?.setAudioPath(currentMeditation?.mediaUrl ?: "")
} else {
currentMeditationIndex = meditations.indexOf(currentMeditation)
if (currentMeditationIndex == meditations.size - 1) {
currentMeditationIndex = 0
} else {
currentMeditationIndex++
}
currentMeditation = meditations[currentMeditationIndex]
val event = MeditationEvent(
currentMeditation?.mediaId?.toInt() ?: 0,
meditationId ?: 0L,
meditationType ?: 0,
businessType,
status = status,
buried = buried ?: "",
mediaUrl = currentMeditation?.mediaUrl ?: "",
mediaCoverUrl = currentMeditation?.coverImageUrl ?: "",
title = currentMeditation?.title ?: "",
desc = currentMeditation?.desc ?: ""
)
EventBus.getDefault().post(event)
}
isComplete = 1)
if (isLoop){
if (isSingle || meditations.size == 1){
MediaPlayerManager
.getInstance(this)?.setAudioPath(currentMeditation?.mediaUrl?:"",isLoop = true)
}else{
currentMeditationIndex = meditations.indexOf(currentMeditation)
if(currentMeditationIndex == meditations.size - 1){
currentMeditationIndex = 0
}else{
currentMeditationIndex++
}
currentMeditation = meditations[currentMeditationIndex]
val event = MeditationEvent(
currentMeditation?.mediaId?.toInt()?:0,
meditationId?:0L,
meditationType?:0,
businessType,
status = status,
buried = buried?:"",
mediaUrl = currentMeditation?.mediaUrl?:"",
mediaCoverUrl = currentMeditation?.coverImageUrl?:"",
title = currentMeditation?.title?:"",
desc = currentMeditation?.desc?:""
)
EventBus.getDefault().post(event)
}
}
isPlaying = if (it.isPlaying) {
......@@ -891,7 +892,7 @@ class PlayMeditationActivity : BaseActivity() {
mDisposable?.dispose()
initRxTimeOff((minute * 60 * 1000).toLong(), 1)
}
val event = MeditationFloatEvent(false,(minute * 60 * 1000).toLong())
val event = MeditationFloatEvent(false,time = (minute * 60 * 1000).toLong())
EventBus.getDefault().post(event)
} else {
initPlayCompletionListener()
......@@ -899,7 +900,7 @@ class PlayMeditationActivity : BaseActivity() {
tv_time_off.visibility = View.GONE
tv_time_off_pure_music.visibility = View.GONE
mMediaPlayer?.isLooping = false
val event = MeditationFloatEvent(false,0)
val event = MeditationFloatEvent(false,time = 0)
EventBus.getDefault().post(event)
}
}
......
......@@ -4,6 +4,7 @@ import com.yidianling.muse.bean.MeditationPlayModuleBean
class MeditationFloatEvent(
val show: Boolean,
val stop: Boolean?=null,
val time:Long?=null,
val meditationDetail: MeditationPlayModuleBean.MeditationDetail?=null
)
\ No newline at end of file
......@@ -30,8 +30,10 @@ class MediaPlayerManager private constructor() {
mMediaPlayer?.prepareAsync()
mMediaPlayer?.setOnPreparedListener {
listener?.onPrepared(it)
if (isLoop){
mMediaPlayer?.seekTo(0)
}
}
}
fun getMediaPlayer():MediaPlayer? = mMediaPlayer
......@@ -65,22 +67,6 @@ class MediaPlayerManager private constructor() {
this.listener = listener
}
fun startPlayList(audioPaths:ArrayList<String>,
playCallBack: MediaPlayCallBack,startIndex:Int){
if(audioPaths.isNullOrEmpty() || startIndex>=mAudioPaths.size){
return
}
mMediaPlayCallBack = playCallBack
mAudioPaths = audioPaths
mCurrentListIndex = startIndex
mMediaPlayCallBack?.mediaPlayCallBack(TYPE_LIST,
MediaPlayCallBack.STATE_START,mCurrentListIndex)
setAudioPath(mAudioPaths[mCurrentListIndex])
}
companion object {
private var mContext: Context by Delegates.notNull()
......
......@@ -125,6 +125,13 @@ class MeditationWindowService : LifecycleService() {
}
}else{
if (!event.show) {
if (event.stop == true){
try {
mMediaPlayer?.stop()
}catch (e:Exception){
}
}
hideFloatWindow()
}
if (event.show && event.meditationDetail != null) {
......
......@@ -6,7 +6,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/_8c">
android:background="#CC282E3F">
<ImageView
android:id="@+id/iv_bg"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF173F5D">
android:id="@+id/root_layout">
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginEnd="24dp"
android:padding="12dp"
android:src="@drawable/icon_play_meditation_time_off_close"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:text="定时关闭"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_close" />
android:id="@+id/iv_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF173F5D"/>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
android:layout_height="match_parent"
android:background="@color/transparent">
<com.weigan.loopview.LoopView
android:id="@+id/wheel_hour"
android:layout_width="50dp"
android:layout_height="240dp"
app:awv_itemsVisibleCount="4"
app:awv_textsize="36"
app:awv_dividerTextColor="0x00FFFFFF"
app:awv_isLoop="false"
app:awv_outerTextColor="0x66FFFFFF"
app:awv_centerTextColor="@color/white" />
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginEnd="24dp"
android:padding="12dp"
android:src="@drawable/icon_play_meditation_time_off_close"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="小时"
android:layout_marginTop="90dp"
android:text="定时关闭"
android:textColor="@color/white"
android:textSize="18sp"/>
android:textStyle="bold"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_close" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<com.weigan.loopview.LoopView
android:id="@+id/wheel_hour"
android:layout_width="50dp"
android:layout_height="240dp"
app:awv_itemsVisibleCount="4"
app:awv_textsize="36"
app:awv_dividerTextColor="0x00FFFFFF"
app:awv_isLoop="false"
app:awv_outerTextColor="0x66FFFFFF"
app:awv_centerTextColor="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="小时"
android:textColor="@color/white"
android:textSize="18sp" />
<com.weigan.loopview.LoopView
android:id="@+id/wheel_minute"
android:layout_width="50dp"
android:layout_height="240dp"
android:layout_marginStart="60dp"
app:awv_itemsVisibleCount="4"
app:awv_textsize="36"
app:awv_dividerTextColor="0x00FFFFFF"
app:awv_isLoop="false"
app:awv_outerTextColor="0x66FFFFFF"
app:awv_centerTextColor="@color/white"/>
<com.weigan.loopview.LoopView
android:id="@+id/wheel_minute"
android:layout_width="50dp"
android:layout_height="240dp"
android:layout_marginStart="60dp"
app:awv_itemsVisibleCount="4"
app:awv_textsize="36"
app:awv_dividerTextColor="0x00FFFFFF"
app:awv_isLoop="false"
app:awv_outerTextColor="0x66FFFFFF"
app:awv_centerTextColor="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="分钟"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="分钟"
android:id="@+id/tv_cancel_time_off"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="50dp"
android:layout_marginHorizontal="16dp"
android:background="@drawable/bg_cancel_play_meditation_time_off"
android:text="关闭定时"
android:textColor="@color/white"
android:textSize="18sp"/>
android:textSize="16sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</LinearLayout>
<TextView
android:id="@+id/tv_cancel_time_off"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="50dp"
android:layout_marginHorizontal="16dp"
android:background="@drawable/bg_cancel_play_meditation_time_off"
android:text="关闭定时"
android:textColor="@color/white"
android:textSize="16sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:id="@+id/tv_save_setting"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="28dp"
android:layout_marginHorizontal="16dp"
android:background="@drawable/bg_save_play_meditation_time_off"
android:text="保存设置"
android:textColor="#FF282E3F"
android:textSize="16sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/tv_cancel_time_off" />
<TextView
android:id="@+id/tv_save_setting"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="28dp"
android:layout_marginHorizontal="16dp"
android:background="@drawable/bg_save_play_meditation_time_off"
android:text="保存设置"
android:textColor="#FF282E3F"
android:textSize="16sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/tv_cancel_time_off" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</FrameLayout>
\ No newline at end of file
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