Commit efb77ca4 by 范玉宾

fix time off discard error & enter meditation for mine need login

parent 0bc54e84
...@@ -9,12 +9,12 @@ ext { ...@@ -9,12 +9,12 @@ ext {
"m-consultant" : "0.0.60.25", "m-consultant" : "0.0.60.25",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.19", "m-user" : "0.0.62.19",
"m-home" : "0.0.23.73", "m-home" : "0.0.23.75",
"m-im" : "0.0.21.44", "m-im" : "0.0.21.44",
"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.55", "m-muse" : "0.0.28.56",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
...@@ -94,12 +94,12 @@ ext { ...@@ -94,12 +94,12 @@ ext {
"m-consultant" : "0.0.60.25", "m-consultant" : "0.0.60.25",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.19", "m-user" : "0.0.62.19",
"m-home" : "0.0.23.73", "m-home" : "0.0.23.75",
"m-im" : "0.0.21.44", "m-im" : "0.0.21.44",
"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.55", "m-muse" : "0.0.28.56",
"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 层 --------------
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
<activity android:name=".activity.ChooseMusicActivity" <activity android:name=".activity.ChooseMusicActivity"
android:screenOrientation="portrait"
android:theme="@style/un_full_screen_activity"/> android:theme="@style/un_full_screen_activity"/>
<service android:name=".service.MeditationWindowService"/> <service android:name=".service.MeditationWindowService"/>
......
...@@ -92,8 +92,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -92,8 +92,6 @@ class PlayMeditationActivity : BaseActivity() {
private var mBuried: String? = null private var mBuried: String? = null
private var broadcastTime = 0
/** /**
* 传递过来的mediaId 用于判断正在播放的是否是同一条音频 * 传递过来的mediaId 用于判断正在播放的是否是同一条音频
*/ */
...@@ -870,9 +868,19 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -870,9 +868,19 @@ class PlayMeditationActivity : BaseActivity() {
R.drawable.icon_meditation_collected R.drawable.icon_meditation_collected
} }
) )
val timeOff = MediaPlayerManager.getInstance(this)?.getTimeOff()
if (timeOff!=null && timeOff>0 && mMeditationType!=null){
initRxTimeOff(timeOff, mMeditationType!!)
}
} }
private fun initRxTimeOff(time: Long, meditationType: Int) { private fun initRxTimeOff(time: Long, meditationType: Int) {
MediaPlayerManager.getInstance(this)?.initRxTimeOff(time)
mObservable = Observable.interval(0, 1, TimeUnit.SECONDS) mObservable = Observable.interval(0, 1, TimeUnit.SECONDS)
.take(time / 1000 + 1) .take(time / 1000 + 1)
.map { t -> time - t * 1000 } .map { t -> time - t * 1000 }
......
...@@ -4,7 +4,12 @@ import android.content.Context ...@@ -4,7 +4,12 @@ import android.content.Context
import android.media.AudioAttributes import android.media.AudioAttributes
import android.media.AudioManager import android.media.AudioManager
import android.media.MediaPlayer import android.media.MediaPlayer
import com.yidianling.muse.helper.MediaPlayerManager.MediaPlayCallBack.Companion.TYPE_LIST import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
import kotlin.properties.Delegates import kotlin.properties.Delegates
class MediaPlayerManager private constructor() { class MediaPlayerManager private constructor() {
...@@ -12,10 +17,14 @@ class MediaPlayerManager private constructor() { ...@@ -12,10 +17,14 @@ class MediaPlayerManager private constructor() {
private var listener:OnMediaPlayerManagerListener?=null private var listener:OnMediaPlayerManagerListener?=null
private var mCurrentListIndex = 0 private var mCurrentListIndex = 0
private var mMediaPlayCallBack:MediaPlayCallBack?=null
private var mAudioPaths = mutableListOf<String>() private var mAudioPaths = mutableListOf<String>()
private var mMediaId:Long? = null private var mMediaId:Long? = null
private var mTime = 0L
private var mDisposable:Disposable? = null
private var mObservable: Observable<Long>? = null
private var mObserver: Observer<Long>? = null
fun setMediaId(mediaId:Long?){ fun setMediaId(mediaId:Long?){
mMediaId = mediaId mMediaId = mediaId
...@@ -23,6 +32,8 @@ class MediaPlayerManager private constructor() { ...@@ -23,6 +32,8 @@ class MediaPlayerManager private constructor() {
fun getMediaId():Long? = mMediaId fun getMediaId():Long? = mMediaId
fun getTimeOff():Long = mTime
fun setAudioPath(path: String,isLoop:Boolean = false){ fun setAudioPath(path: String,isLoop:Boolean = false){
val attrs = AudioAttributes.Builder() val attrs = AudioAttributes.Builder()
...@@ -75,6 +86,45 @@ class MediaPlayerManager private constructor() { ...@@ -75,6 +86,45 @@ class MediaPlayerManager private constructor() {
this.listener = listener this.listener = listener
} }
fun initRxTimeOff(time: Long) {
mObservable = Observable.interval(0, 1, TimeUnit.SECONDS)
.take(time / 1000 + 1)
.map { t -> time - t * 1000 }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
mObserver = object : Observer<Long> {
override fun onSubscribe(d: Disposable) {
mDisposable = d
}
override fun onNext(t: Long) {
mTime = t
}
override fun onError(e: Throwable) {
}
override fun onComplete() {
}
}
if (mObserver != null && mObserver is Observer<Long>) {
mObservable?.subscribe(mObserver as Observer<Long>)
}
if (mDisposable?.isDisposed == true && mObserver != null && mObserver is Observer<Long>) {
mObservable?.subscribe(mObserver as Observer<Long>)
}
}
private fun dispose() {
mDisposable?.dispose()
}
companion object { companion object {
private var mContext: Context by Delegates.notNull() private var mContext: Context by Delegates.notNull()
...@@ -106,23 +156,4 @@ class MediaPlayerManager private constructor() { ...@@ -106,23 +156,4 @@ class MediaPlayerManager private constructor() {
fun onPrepared(mediaPlayer: MediaPlayer) fun onPrepared(mediaPlayer: MediaPlayer)
} }
interface MediaPlayCallBack {
companion object{
const val STATE_START = 0
const val STATE_PLAY = 1
const val STATE_PAUSE = 2
const val STATE_STOP = 3
const val STATE_CUT = 4
const val TYPE_SINGLE = 0
const val TYPE_LIST = 1
}
fun mediaPlayCallBack(type:Int,state:Int,position:Int){}
}
} }
\ No newline at end of file
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
android:fitsSystemWindows="false" android:fitsSystemWindows="false"
android:background="#B3000000"> android:background="#B3000000">
<ImageView <ImageView
android:id="@+id/iv_bg" android:id="@+id/iv_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -18,7 +17,7 @@ ...@@ -18,7 +17,7 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#CC282E3F" /> android:background="#33282E3F" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#CC282E3F" /> android:background="#33282E3F" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="150dp" android:layout_marginTop="150dp"
xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@drawable/shape_bg_solid_282e3f_r_top_20">
android:background="@drawable/shape_bg_solid_282e3f_r_top_20"
> <WebView
android:id="@+id/wv_choose_music"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#282E3F"
android:scrollbars="none" />
<LinearLayout <LinearLayout
android:id="@+id/ll_close" android:id="@+id/ll_close"
android:layout_width="match_parent" android:layout_width="match_parent"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:layout_height="38dp" android:layout_height="38dp">
app:layout_constraintTop_toTopOf="parent"
>
<ImageView <ImageView
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="10dp" android:layout_height="10dp"
android:src="@drawable/ic_close_choose_music" android:src="@drawable/ic_close_choose_music"
android:layout_marginTop="12dp" android:layout_marginTop="12dp" />
/>
</LinearLayout> </LinearLayout>
<WebView </FrameLayout>
android:id="@+id/wv_choose_music" \ No newline at end of file
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/ll_close"
app:layout_constraintBottom_toBottomOf="parent"
android:background="#282E3F"
android:scrollbars="none"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -493,8 +493,14 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View. ...@@ -493,8 +493,14 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
jtv_test?.postDelayed({ YdlBuryPointUtil.sendClick("ClickEvent") }, 500) jtv_test?.postDelayed({ YdlBuryPointUtil.sendClick("ClickEvent") }, 500)
} else if (id == R.id.ll_meditation) { //冥想 } else if (id == R.id.ll_meditation) { //冥想
count(UserMyPageEvent.YDL_USER_MY_MIDDLE_TYPE_CLICK, "冥想") count(UserMyPageEvent.YDL_USER_MY_MIDDLE_TYPE_CLICK, "冥想")
val h5Params3 = H5Params(MH5_URL + "meditation/list?hideNavBar=1", null) mActivity?.let {
NewH5Activity.start(activity, h5Params3) if (!startLoginByStatus(it, true)) {
return
}
val h5Params3 = H5Params(MH5_URL + "meditation/list?hideNavBar=1", null)
NewH5Activity.start(it, 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