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
2b429e33
Commit
2b429e33
authored
Aug 07, 2022
by
王佳洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
悬浮窗点击X关闭悬浮窗和音频时,如果之前的播放页并未关闭,再次回到播放页,点击播放按钮无效
此bug线上就存在,在新写的音频播放页修复此bug,之前的老逻辑不做改动
parent
cb0f4283
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
32 deletions
+64
-32
AudioPlayActivity.kt
m-course/src/main/java/com/yidianling/course/coursePlay/AudioPlayActivity.kt
+21
-7
AudioPlayView.kt
m-course/src/main/java/com/yidianling/course/widget/AudioPlayView.kt
+5
-4
CourseSpeedDialog.kt
m-course/src/main/java/com/yidianling/course/widget/CourseSpeedDialog.kt
+7
-4
AudioPlayer.kt
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
+6
-1
PlayerFloatView.kt
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatView.kt
+25
-16
No files found.
m-course/src/main/java/com/yidianling/course/coursePlay/AudioPlayActivity.kt
View file @
2b429e33
...
...
@@ -14,6 +14,7 @@ import com.bumptech.glide.request.target.ViewTarget
import
com.bumptech.glide.request.transition.Transition
import
com.ydl.media.audio.model.Music
import
com.ydl.media.view.PlayerFloatHelper
import
com.ydl.media.view.PlayerFloatView
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydlcommon.base.BaseMvpActivity
...
...
@@ -46,7 +47,7 @@ import java.util.*
*/
@Route
(
path
=
"/course/audioPlay"
)
class
AudioPlayActivity
:
BaseMvpActivity
<
IAudioPlayContract
.
View
,
IAudioPlayContract
.
Presenter
>(),
IAudioPlayContract
.
View
{
IAudioPlayContract
.
View
,
PlayerFloatView
.
FloatViewPlayListener
{
private
var
mCourseSpeedDialog
:
CourseSpeedDialog
?
=
null
private
var
mCourseListDialog
:
CourseListDialog
?
=
null
...
...
@@ -234,11 +235,11 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon
}
private
fun
speedClick
()
{
val
audioPlay
=
audio_play
showFragment
(
mCourseSpeedDialog
?:
CourseSpeedDialog
().
apply
{
mCourseSpeedDialog
=
this
mListener
=
{
speed
->
audio
P
lay
.
setSpeed
(
speed
)
showFragment
(
mCourseSpeedDialog
?:
CourseSpeedDialog
().
also
{
dialog
->
mCourseSpeedDialog
=
dialog
dialog
.
setSpeedPosition
(
audio_play
.
getSpeed
())
dialog
.
mListener
=
{
speed
->
audio
_p
lay
.
setSpeed
(
speed
)
}
},
"courseSpeed"
)
}
...
...
@@ -267,8 +268,20 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon
}
}
override
fun
onStop
()
{
PlayerFloatHelper
.
addClickListener
(
this
)
super
.
onStop
()
}
override
fun
onDestroy
()
{
audio_play
.
onDestroy
(
)
PlayerFloatHelper
.
removeClickListener
(
this
)
super
.
onDestroy
()
}
override
fun
onPreClose
():
Boolean
{
audio_play
.
pausePlay
()
PlayerFloatHelper
.
removeView
()
return
false
}
}
\ No newline at end of file
m-course/src/main/java/com/yidianling/course/widget/AudioPlayView.kt
View file @
2b429e33
...
...
@@ -197,13 +197,14 @@ class AudioPlayView(context: Context, attrs: AttributeSet?) :
return
"$m:$s"
}
fun
onDestroy
()
{
override
fun
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
()
AudioPlayer
.
get
().
removeOnPlayEventListener
(
this
)
}
fun
setSpeed
(
speed
:
Float
)
{
AudioPlayer
.
get
().
setSpeed
(
speed
)
}
fun
setSpeed
(
speed
:
Float
)
=
AudioPlayer
.
get
().
setSpeed
(
speed
)
fun
getSpeed
()
=
AudioPlayer
.
get
().
getSpeed
()
fun
isPlaying
()
=
AudioPlayer
.
get
().
isPlaying
...
...
m-course/src/main/java/com/yidianling/course/widget/CourseSpeedDialog.kt
View file @
2b429e33
...
...
@@ -18,8 +18,11 @@ import kotlinx.android.synthetic.main.item_course_speed.view.*
*/
class
CourseSpeedDialog
:
BaseDialogFragment
()
{
private
val
mSpeedList
=
floatArrayOf
(
0.5f
,
0.75f
,
1.0f
,
1.25f
,
1.5f
,
2.0f
,
3.0f
)
var
mListener
:
((
speed
:
Float
)
->
Unit
)?
=
null
private
var
mAdapter
:
CourseSpeedAdapter
?
=
null
private
var
mOldPosition
=
-
1
private
var
mCurrentPosition
=
2
override
fun
getLayoutResourceId
():
Int
=
R
.
layout
.
dialog_course_speed
override
fun
getGravity
():
Int
=
Gravity
.
BOTTOM
...
...
@@ -34,15 +37,15 @@ class CourseSpeedDialog : BaseDialogFragment() {
}
}
fun
setSpeedPosition
(
speed
:
Float
)
{
mCurrentPosition
=
mSpeedList
.
indexOf
(
speed
)
}
inner
class
CourseSpeedAdapter
(
context
:
Context
,
private
val
inflater
:
LayoutInflater
=
LayoutInflater
.
from
(
context
)
)
:
RecyclerView
.
Adapter
<
CourseSpeedAdapter
.
CourseSpeedVH
>()
{
private
val
mSpeedList
=
floatArrayOf
(
0.5f
,
0.75f
,
1.0f
,
1.25f
,
1.5f
,
2.0f
,
3.0f
)
private
var
mOldPosition
=
-
1
private
var
mCurrentPosition
=
2
inner
class
CourseSpeedVH
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
override
fun
onCreateViewHolder
(
viewGroup
:
ViewGroup
,
itemType
:
Int
):
CourseSpeedVH
=
...
...
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
View file @
2b429e33
...
...
@@ -516,9 +516,14 @@ class AudioPlayer private constructor() {
}
/**
* 倍速播放
*
设置
倍速播放
*/
fun
setSpeed
(
speed
:
Float
)
{
(
mediaPlayer
as
?
IjkMediaPlayer
)
?.
setSpeed
(
speed
)
}
/**
* 获取播放倍速
*/
fun
getSpeed
():
Float
=
(
mediaPlayer
as
?
IjkMediaPlayer
)
?.
getSpeed
(
0f
)
?:
1f
}
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatView.kt
View file @
2b429e33
...
...
@@ -34,8 +34,8 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
//全局变量,用以保存悬浮窗口的属性
var
mFloatViewParams
=
WindowManager
.
LayoutParams
()
private
var
m
Listeners
:
CopyOnWriteArraySet
<
FloatViewPlayListener
>
=
CopyOnWriteArraySet
()
private
var
m
StateChange
Listener
:
OnPlayerEventListener
?
=
null
private
var
m
FloatViewPlayListeners
=
HashSet
<
FloatViewPlayListener
>
()
private
var
m
AudioPlay
Listener
:
OnPlayerEventListener
?
=
null
private
val
mStatusBarHeight
:
Int
=
StatusBarUtil
.
getStatusBarHeight
(
context
)
...
...
@@ -55,7 +55,10 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
}
}
play_close
.
setOnClickListener
{
mListeners
.
forEach
{
mFloatViewPlayListeners
.
forEach
{
if
(!
it
.
onPreClose
())
return
@setOnClickListener
}
mFloatViewPlayListeners
.
forEach
{
it
.
onPauseClick
()
}
PlayerFloatHelper
.
removeResetView
()
...
...
@@ -63,23 +66,23 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
play_state
.
setOnClickListener
{
if
(
AudioPlayer
.
get
().
isPlaying
)
{
AudioPlayer
.
get
().
pausePlayer
()
mListeners
.
forEach
{
m
FloatViewPlay
Listeners
.
forEach
{
it
.
onPauseClick
()
}
}
else
if
(
AudioPlayer
.
get
().
isPausing
)
{
AudioPlayer
.
get
().
startPlayer
()
mListeners
.
forEach
{
m
FloatViewPlay
Listeners
.
forEach
{
it
.
onStartClick
()
}
}
}
if
(
m
StateChange
Listener
==
null
)
{
m
StateChange
Listener
=
object
:
OnPlayerEventListener
{
if
(
m
AudioPlay
Listener
==
null
)
{
m
AudioPlay
Listener
=
object
:
OnPlayerEventListener
{
override
fun
onComplete
()
{
tv_start
.
text
=
getStringTime
(
AudioPlayer
.
get
().
getDuration
().
toInt
())
setPlayDrawable
()
mListeners
.
forEach
{
m
FloatViewPlay
Listeners
.
forEach
{
it
.
onPlayFinish
()
}
}
...
...
@@ -125,7 +128,7 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
updatePlayState
()
}
}
AudioPlayer
.
get
().
addOnPlayEventListener
(
m
StateChange
Listener
!!
)
AudioPlayer
.
get
().
addOnPlayEventListener
(
m
AudioPlay
Listener
!!
)
}
}
...
...
@@ -229,7 +232,7 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
setPauseDrawable
()
}
else
{
setPlayDrawable
()
for
(
listener
in
mListeners
)
{
for
(
listener
in
m
FloatViewPlay
Listeners
)
{
listener
.
onPauseClick
()
}
}
...
...
@@ -270,8 +273,8 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
}
fun
remove
()
{
mListeners
.
clear
()
m
StateChange
Listener
?.
let
{
AudioPlayer
.
get
().
removeOnPlayEventListener
(
it
)
}
m
FloatViewPlay
Listeners
.
clear
()
m
AudioPlay
Listener
?.
let
{
AudioPlayer
.
get
().
removeOnPlayEventListener
(
it
)
}
mWindowManager
.
removeViewImmediate
(
this
)
}
...
...
@@ -281,20 +284,25 @@ class PlayerFloatView(ctx: Context) : FrameLayout(ctx.applicationContext) {
}
fun
addFloatClickListener
(
floatClickListener
:
FloatViewPlayListener
)
{
mListeners
.
add
(
floatClickListener
)
m
FloatViewPlay
Listeners
.
add
(
floatClickListener
)
}
fun
removeFloatClickListener
(
floatClickListener
:
FloatViewPlayListener
)
{
mListeners
.
remove
(
floatClickListener
)
m
FloatViewPlay
Listeners
.
remove
(
floatClickListener
)
}
interface
FloatViewPlayListener
{
fun
onPauseClick
()
{}
fun
onStartClick
()
{}
fun
onPlayFinish
()
{}
/**
* @return true: 允许关闭
*/
fun
onPreClose
():
Boolean
=
true
}
}
\ No newline at end of file
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