Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
81b3ba15
Commit
81b3ba15
authored
May 27, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meditation type error when enter playDetail from floatView
parent
1669b637
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
268 additions
and
283 deletions
+268
-283
HomeMuseView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
+1
-1
home_muse_view.xml
m-home/src/ydl/res/layout/home_muse_view.xml
+6
-8
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+222
-267
MeditationPlayModuleBean.kt
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
+1
-1
MeditationFloatEvent.kt
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
+2
-2
MeditationWindowService.kt
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
+6
-3
MediaPlayerTimeUtil.kt
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
+29
-0
MineFragment.kt
m-user/src/main/java/com/yidianling/user/mine/MineFragment.kt
+1
-1
No files found.
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
View file @
81b3ba15
...
...
@@ -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
)
...
...
m-home/src/ydl/res/layout/home_muse_view.xml
View file @
81b3ba15
...
...
@@ -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"
...
...
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
81b3ba15
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
b
usinessType
=
0
private
var
mB
usinessType
=
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
(
m
editationType
==
null
||
(
mediaId
==
null
&&
m
editationType
!=
0
))
{
if
(
m
MeditationId
==
null
||
(
mMediaId
==
null
&&
mM
editationType
!=
0
))
{
return
}
// 声音详情
if
(
meditationType
==
0
)
{
if
(
m
M
editationType
==
0
)
{
MuseHttp
.
getInstance
().
getPureMusicPlayDetail
(
meditionType
=
meditationType
!!
,
meditationId
=
meditationId
!!
meditionType
=
m
M
editationType
!!
,
meditationId
=
m
M
editationId
!!
)
.
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
}
}
}
},
object
:
ThrowableConsumer
()
{
...
...
@@ -199,11 +172,11 @@ class PlayMeditationActivity : BaseActivity() {
show
(
msg
)
}
})
}
else
if
(
meditationType
==
1
)
{
}
else
if
(
m
M
editationType
==
1
)
{
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
mediaId
=
mediaId
!!
,
meditationId
=
meditationId
!!
mediaId
=
m
M
ediaId
!!
,
meditationId
=
m
M
editationId
!!
)
.
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
m
M
ediaId
=
module
.
mediaId
meditations
.
clear
()
...
...
@@ -220,50 +193,32 @@ class PlayMeditationActivity : BaseActivity() {
meditations
.
add
(
meditationPlayBean
)
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
if
(
meditationPlayBean
.
mediaId
==
m
M
ediaId
)
{
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
m
ediaUrl
=
meditationPlayBean
.
mediaUrl
mM
ediaUrl
=
meditationPlayBean
.
mediaUrl
val
currentPosition
=
meditationPlayBean
.
broadcastTime
b
usinessType
=
meditationPlayBean
.
businessType
mB
usinessType
=
meditationPlayBean
.
businessType
s
tatus
=
meditationPlayBean
.
status
mS
tatus
=
meditationPlayBean
.
status
b
uried
=
meditationPlayBean
.
buried
mB
uried
=
meditationPlayBean
.
buried
collected
=
s
tatus
==
1
collected
=
mS
tatus
==
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
(
m
M
editationType
==
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
...
...
@@ -347,11 +302,11 @@ class PlayMeditationActivity : BaseActivity() {
)
{
return
@setOnClickListener
}
if
(
m
editationId
==
null
||
m
ediaId
==
null
)
return
@setOnClickListener
if
(
m
MeditationId
==
null
||
mM
ediaId
==
null
)
return
@setOnClickListener
MuseHttp
.
getInstance
().
collectMeditation
(
meditationId
=
meditationId
!!
,
mediaId
=
mediaId
!!
,
status
=
if
(
collected
)
0
else
1
,
businessType
=
b
usinessType
meditationId
=
m
M
editationId
!!
,
mediaId
=
m
M
ediaId
!!
,
status
=
if
(
collected
)
0
else
1
,
businessType
=
mB
usinessType
)
.
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
if
(
shareDialog
==
null
)
{
shareDialog
=
ShareMeditationDialog
.
newInstance
(
shareTitle
=
share
Title
,
shareContent
=
shareContent
,
shareUrl
=
share
Url
,
shareImageUrl
=
shareImage
Url
shareTitle
=
m
Title
,
shareContent
=
mDesc
,
shareUrl
=
mMedia
Url
,
shareImageUrl
=
mMediaCover
Url
)
}
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
startActivityForResult
(
...
...
@@ -497,7 +472,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants
.
YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE
,
MuseBIConstants
.
YDL_MUSE_PLAY_IOC_CLICK
,
currentMeditation
?.
title
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
...
...
@@ -546,7 +526,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants
.
YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE
,
MuseBIConstants
.
YDL_MUSE_PLAY_PLAY_CLICK
,
currentMeditation
?.
title
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
}
...
...
@@ -565,40 +545,34 @@ class PlayMeditationActivity : BaseActivity() {
MuseBIConstants
.
YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE
,
MuseBIConstants
.
YDL_MUSE_PLAY_LAST_CLICK
,
currentMeditation
?.
title
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
=
m
M
editationId
!!
)
mediaId
=
meditation
.
mediaId
val
m
ediaCoverUrl
=
meditation
.
coverImageUrl
val
m
ediaUrl
=
meditation
.
mediaUrl
m
M
ediaId
=
meditation
.
mediaId
mM
ediaCoverUrl
=
meditation
.
coverImageUrl
mM
ediaUrl
=
meditation
.
mediaUrl
val
currentPosition
=
meditation
.
broadcastTime
val
s
tatus
=
meditation
.
status
mS
tatus
=
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
m
ediaCoverUrl
=
meditation
.
coverImageUrl
val
m
ediaUrl
=
meditation
.
mediaUrl
m
M
ediaId
=
meditation
.
mediaId
mM
ediaCoverUrl
=
meditation
.
coverImageUrl
mM
ediaUrl
=
meditation
.
mediaUrl
val
currentPosition
=
meditation
.
broadcastTime
val
s
tatus
=
meditation
.
status
mS
tatus
=
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
(
m
M
ediaUrl
,
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
?:
""
,
b
uried
?:
""
,
mB
uried
?:
""
,
""
)
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
,
b
usinessType
,
status
=
s
tatus
,
buried
=
b
uried
?:
""
,
m
M
editationId
?:
0L
,
m
M
editationType
?:
0
,
mB
usinessType
,
status
=
mS
tatus
,
buried
=
mB
uried
?:
""
,
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
(
m
M
editationType
==
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
...
...
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
View file @
81b3ba15
...
...
@@ -16,7 +16,7 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
var
mediaList
:
ArrayList
<
MeditationDetail
>?
=
null
data class
MeditationDetail
(
val
medi
a
Type
:
Int
?
=
null
,
val
medi
tation
Type
:
Int
?
=
null
,
val
mediaId
:
Long
?=
null
,
val
meditationId
:
Long
,
val
title
:
String
,
...
...
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
View file @
81b3ba15
...
...
@@ -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
)
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
View file @
81b3ba15
...
...
@@ -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
.
medi
a
Type
)
intent
.
putExtra
(
"MEDITATION_TYPE"
,
meditation
.
medi
tation
Type
)
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
,
...
...
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
View file @
81b3ba15
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
m-user/src/main/java/com/yidianling/user/mine/MineFragment.kt
View file @
81b3ba15
...
...
@@ -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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment