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
866feac3
Commit
866feac3
authored
Nov 19, 2019
by
严久程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
音视频播放
parent
92018119
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
431 additions
and
78 deletions
+431
-78
DemoGlobalConfig.java
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
+1
-1
config.gradle
config.gradle
+1
-1
build.gradle
m-course/build.gradle
+1
-0
AndroidManifest.xml
m-course/src/main/AndroidManifest.xml
+8
-1
CoursePlayActivity.kt
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayActivity.kt
+0
-0
CoursePlayItemViewAudio.kt
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayItemViewAudio.kt
+26
-23
CourseSearchActicity.kt
m-course/src/main/java/com/yidianling/course/courseSearch/CourseSearchActicity.kt
+5
-2
CourseSearchListApi.kt
m-course/src/main/java/com/yidianling/course/courseSearch/http/CourseSearchListApi.kt
+4
-0
CoursePlugin.kt
m-course/src/main/java/com/yidianling/course/flutterPlugin/CoursePlugin.kt
+62
-15
VideoProgressUtil.kt
m-course/src/main/java/com/yidianling/course/uitls/VideoProgressUtil.kt
+33
-0
CourseItemNewView.kt
m-course/src/main/java/com/yidianling/course/widget/CourseItemNewView.kt
+49
-5
HPlayView.kt
m-course/src/main/java/com/yidianling/course/widget/HPlayView.kt
+33
-30
VideoFloatHelper.kt
m-course/src/main/java/com/yidianling/course/widget/VideoFloatHelper.kt
+173
-0
course_float_video_view.xml
m-course/src/main/res/layout/course_float_video_view.xml
+35
-0
No files found.
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
View file @
866feac3
...
...
@@ -27,7 +27,7 @@ public final class DemoGlobalConfig implements IConfigModule {
public
void
applyOptions
(
@NotNull
Context
context
,
@NotNull
GlobalConfig
.
Builder
builder
)
{
builder
.
setFrom
(
"ydl"
.
equals
(
BuildConfig
.
FLAVOR
)
?
YDLConstants
.
FROM_YDL
:
YDLConstants
.
FROM_XLZX
)
.
addUrl
(
"github"
,
APP_DOMAIN
)
.
setEnv
(
YDLConstants
.
ENV_
TEST
)
.
setEnv
(
YDLConstants
.
ENV_
PROD
)
.
setDebug
(
BuildConfig
.
DEBUG
);
}
}
config.gradle
View file @
866feac3
ext
{
kotlin_version
=
"1.3.21"
dev_mode
=
fals
e
dev_mode
=
tru
e
ydl_app
=
[
appName
:
"心理咨询壹点灵"
,
...
...
m-course/build.gradle
View file @
866feac3
...
...
@@ -63,6 +63,7 @@ dependencies {
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
kapt
'com.alibaba:arouter-compiler:1.2.2'
implementation
'com.jakewharton:butterknife:8.8.1'
api
'com.github.princekin-f:EasyFloat:1.1.2'
// api 'com.dou361.ijkplayer-armv5:jjdxm-ijkplayer-armv5:1.0.0'
// api 'com.dou361.ijkplayer-arm64:jjdxm-ijkplayer-arm64:1.0.0'
...
...
m-course/src/main/AndroidManifest.xml
View file @
866feac3
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.yidianling.course"
>
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.yidianling.course"
>
<uses-sdk
tools:overrideLibrary=
"com.lzf.easyfloat"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<application>
<!--课程首页-->
<activity
...
...
@@ -42,6 +48,7 @@
android:name=
".course_special_list.activity.CourseSpecialListActivity"
android:screenOrientation=
"portrait"
/>
<service
android:name=
"com.lzf.easyfloat.service.FloatService"
/>
</application>
</manifest>
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayActivity.kt
View file @
866feac3
This diff is collapsed.
Click to expand it.
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayItemViewAudio.kt
View file @
866feac3
...
...
@@ -68,26 +68,26 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
playView
?.
listener
=
object
:
HPlayStatusListener
{
override
fun
isCanPlay
(
data
:
Music
?):
Boolean
{
var
canPlay
=
false
//非试听
if
(
courseExtra
!!
.
isBuy
)
{
//已购买
canPlay
=
true
}
else
{
//未购买,判断是否是试听课程
//即未购买,也不是试听,弹窗提示
if
(
activity
==
null
)
return
false
CommonDialog
(
activity
)
.
setMessage
(
"\n购买课程,获取完整课程内容\n"
)
.
setLeftOnclick
(
"放弃"
)
{
}
.
setRightClick
(
"购买"
)
{
//跳转支付页
activity
?.
addCourseOrder
()
}
.
setCancelAble
(
false
)
.
show
()
}
//非试听
if
(
courseExtra
!!
.
isBuy
)
{
//已购买
canPlay
=
true
}
else
{
//未购买,判断是否是试听课程
//即未购买,也不是试听,弹窗提示
if
(
activity
==
null
)
return
false
CommonDialog
(
activity
)
.
setMessage
(
"\n购买课程,获取完整课程内容\n"
)
.
setLeftOnclick
(
"放弃"
)
{
}
.
setRightClick
(
"购买"
)
{
//跳转支付页
activity
?.
addCourseOrder
()
}
.
setCancelAble
(
false
)
.
show
()
}
return
canPlay
}
...
...
@@ -102,7 +102,12 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
/**
* 设置显示数据
*/
override
fun
setData
(
index
:
Int
,
list
:
ArrayList
<
CourseMediaBean
>,
courseExtra
:
CourseExtraBean
,
from
:
Int
)
{
override
fun
setData
(
index
:
Int
,
list
:
ArrayList
<
CourseMediaBean
>,
courseExtra
:
CourseExtraBean
,
from
:
Int
)
{
if
(
list
.
isEmpty
())
return
playList
.
clear
()
...
...
@@ -110,8 +115,6 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
this
.
courseExtra
=
courseExtra
currentIndex
=
index
// YDLMusicHelper.course_id = courseExtra.id.toInt()
if
(
courseExtra
.
isBuy
)
{
playView
?.
setAutoNext
(
true
)
}
else
{
...
...
m-course/src/main/java/com/yidianling/course/courseSearch/CourseSearchActicity.kt
View file @
866feac3
...
...
@@ -208,9 +208,12 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
hideUnusualPage
()
if
(
type
)
{
courseList
.
clear
()
courseList
.
addAll
(
it
.
data
.
list
)
courseSearchAdapterWrapper
!!
.
notifyDataSetChanged
()
}
else
{
courseList
.
addAll
(
it
.
data
.
list
)
courseSearchAdapterWrapper
!!
.
insertData
()
}
courseList
.
addAll
(
it
.
data
.
list
)
courseSearchAdapterWrapper
!!
.
insertData
()
}
else
{
if
(!
type
)
{
courseSearchAdapterWrapper
!!
.
noMoreData
()
...
...
m-course/src/main/java/com/yidianling/course/courseSearch/http/CourseSearchListApi.kt
View file @
866feac3
package
com.yidianling.course.courseSearch.http
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.yidianling.course.courseSearch.CourseSearchBean
import
io.reactivex.Observable
...
...
@@ -16,5 +18,6 @@ interface CourseSearchListApi{
//专家课程搜索列表
@GET
(
"auth/course/getList"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
courseSearchList
(
@Query
(
"page"
)
page
:
Int
,
@Query
(
"keyWord"
)
keyWord
:
String
):
Observable
<
BaseAPIResponse
<
CourseSearchBean
>>
}
\ No newline at end of file
m-course/src/main/java/com/yidianling/course/flutterPlugin/CoursePlugin.kt
View file @
866feac3
import
android.app.AlertDialog
import
android.content.Intent
import
android.net.Uri
import
android.os.Handler
import
android.text.TextUtils
import
com.lzf.easyfloat.permission.PermissionUtils
import
com.ydl.media.audio.AudioPlayer
import
com.ydl.media.audio.model.Music
import
com.ydl.media.view.PlayTypeEnum
...
...
@@ -16,13 +18,14 @@ import com.ydl.ydlcommon.data.PlatformDataManager
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxDeviceTool
import
com.yidianling.co
urse.BuildConfig
import
com.yidianling.co
mmon.tools.ToastUtil
import
com.yidianling.course.CourseConstants
import
com.yidianling.course.bean.ScrollStatusChangeEvent
import
com.yidianling.course.courseNew.mine.MyCourseActivity
import
com.yidianling.course.course_special_list.activity.CourseSpecialListActivity
import
com.yidianling.course.flutterPlugin.CourseSendPlugin
import
com.yidianling.course.router.CourseIn
import
com.yidianling.course.widget.VideoFloatHelper
import
de.greenrobot.event.EventBus
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
...
...
@@ -66,7 +69,7 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
val
loginBean
=
ModularServiceManager
.
getPlatformUserService
()
?.
getUser
()
val
mMap
=
mutableMapOf
<
String
,
Any
>()
var
uid
=
loginBean
?.
userId
?:
""
mMap
[
"isDevelopment"
]
=
BuildConfig
.
DEBUG
mMap
[
"isDevelopment"
]
=
false
mMap
[
"uid"
]
=
if
(
TextUtils
.
isEmpty
(
uid
))
"0"
else
uid
mMap
[
"accessToken"
]
=
loginBean
?.
token
?:
""
?:
""
...
...
@@ -92,11 +95,21 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
return
}
when
{
jumpUrl
!!
.
contains
(
"user/login"
)
->
mFragment
!!
.
startActivity
(
CourseIn
.
loginWayIntent
(
mFragment
!!
.
activity
!!
)
)
jumpUrl
!!
.
contains
(
"user/login"
)
->
{
//TODO flutter 登录状态判断需要更改
val
loginBean
=
ModularServiceManager
.
getPlatformUserService
()
?.
getUser
()
if
(
loginBean
==
null
||
TextUtils
.
isEmpty
(
loginBean
.
userId
)
||
TextUtils
.
equals
(
loginBean
.
userId
,
"0"
)
)
{
mFragment
!!
.
startActivity
(
CourseIn
.
loginWayIntent
(
mFragment
!!
.
activity
!!
))
}
else
{
MyCourseActivity
.
start
(
mFragment
!!
.
activity
)
}
}
jumpUrl
.
contains
(
"course/myCourse"
)
->
MyCourseActivity
.
start
(
mFragment
!!
.
activity
)
jumpUrl
.
contains
(
"course/specialList"
)
->
//跳转专题列表页
mFragment
!!
.
activity
!!
.
startActivity
(
...
...
@@ -177,20 +190,29 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
if
(
demoType
==
1
)
{
music
.
path
=
url
val
hashMap
=
HashMap
<
String
,
String
>()
hashMap
[
"course_id"
]
=
fileInfo
[
"courseId"
].
toString
()
AudioPlayer
.
get
().
singlePlay
(
music
)
PlayerFloatHelper
.
show
(
mFragment
!!
.
activity
,
playTypeEnum
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
playTypeEnum
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
,
playData
=
hashMap
)
VideoFloatHelper
.
dismissFloat
(
mFragment
!!
.
activity
)
}
if
(
demoType
==
2
)
{
//todo 视屏播放
// YDLMusicHelper.playType = 1
// YDLMusicHelper.courseVideoUlr = url
//
// PlayerFloatHelper.show(mFragment!!.activity)
VideoFloatHelper
.
setVideoInfo
(
fileInfo
[
"courseId"
].
toString
(),
fileInfo
[
"url"
].
toString
(),
false
)
checkPermission
()
if
(
PlayerFloatHelper
.
isShow
(
mFragment
!!
.
activity
!!
))
{
PlayerFloatHelper
.
hide
()
PlayerFloatHelper
.
removeView
(
mFragment
!!
.
activity
!!
)
AudioPlayer
.
get
().
stopPlayer
()
}
}
Handler
().
postDelayed
({
CourseSendPlugin
.
sendMsg
(
true
)
},
300
)
...
...
@@ -215,4 +237,28 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
}
})
}
/**
* 检测浮窗权限是否开启,若没有给与申请提示框(非必须,申请依旧是EasyFloat内部内保进行)
*/
private
fun
checkPermission
()
{
if
(
PermissionUtils
.
checkPermission
(
mFragment
!!
.
activity
))
{
VideoFloatHelper
.
showVideoFloat
(
mFragment
!!
.
activity
)
}
else
{
AlertDialog
.
Builder
(
mFragment
!!
.
activity
)
.
setMessage
(
"使用浮窗功能,需要您授权悬浮窗权限。"
)
.
setPositiveButton
(
"去开启"
)
{
_
,
_
->
VideoFloatHelper
.
showVideoFloat
(
mFragment
!!
.
activity
)
}
.
setNegativeButton
(
"取消"
)
{
_
,
_
->
ToastUtil
.
toastLong
(
mFragment
!!
.
activity
,
"App正常工作需要内部存储使用权限,请开启"
)
}
.
show
()
}
}
}
\ No newline at end of file
m-course/src/main/java/com/yidianling/course/uitls/VideoProgressUtil.kt
0 → 100644
View file @
866feac3
package
com.yidianling.course.uitls
import
android.content.Context
import
android.text.TextUtils
/**
* 工具类
* Created by hgw on 2018/3/31.
*/
object
VideoProgressUtil
{
/**
* 保存播放进度
*/
fun
saveProgress
(
context
:
Context
?,
url
:
String
?,
progress
:
Int
)
{
if
(
TextUtils
.
isEmpty
(
url
))
return
val
shared
=
context
?.
getSharedPreferences
(
"COURSE_VIDEO_PROGRESS"
,
Context
.
MODE_PRIVATE
)
val
edit
=
shared
?.
edit
()
edit
?.
putInt
(
url
,
progress
)
edit
?.
apply
()
}
/**
* 获取进度
*/
fun
getProgress
(
context
:
Context
?,
url
:
String
?):
Int
{
if
(
TextUtils
.
isEmpty
(
url
))
return
0
val
shared
=
context
?.
getSharedPreferences
(
"COURSE_VIDEO_PROGRESS"
,
Context
.
MODE_PRIVATE
)
return
shared
?.
getInt
(
url
,
0
)
?:
0
}
}
\ No newline at end of file
m-course/src/main/java/com/yidianling/course/widget/CourseItemNewView.kt
View file @
866feac3
package
com.yidianling.course.widget
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.AlertDialog
import
android.content.Context
import
android.graphics.Paint
import
android.support.constraint.ConstraintLayout
...
...
@@ -8,6 +10,7 @@ import android.text.TextUtils
import
android.util.AttributeSet
import
android.view.View
import
com.alibaba.android.arouter.launcher.ARouter
import
com.lzf.easyfloat.permission.PermissionUtils
import
com.ydl.media.audio.AudioPlayer
import
com.ydl.media.audio.model.Music
import
com.ydl.media.view.PlayTypeEnum
...
...
@@ -19,6 +22,7 @@ import com.ydl.ydl_image.module.GlideApp
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.actionutil.BIConstants
import
com.yidianling.common.tools.RxImageTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.course.CourseConstants
import
com.yidianling.course.R
import
com.yidianling.course.bean.Course
...
...
@@ -228,14 +232,30 @@ class CourseItemNewView : ConstraintLayout {
PlayerFloatHelper
.
playingType
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
music
.
path
=
course
.
demoFile
val
hashMap
=
HashMap
<
String
,
String
>()
hashMap
[
"course_id"
]
=
course
.
id
.
toString
()
AudioPlayer
.
get
().
singlePlay
(
music
)
PlayerFloatHelper
.
show
(
mContext
,
playTypeEnum
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
,
playData
=
hashMap
)
VideoFloatHelper
.
dismissFloat
(
mContext
as
Activity
)
}
if
(
course
.
demoType
==
2
)
{
//todo 视屏播放
// YDLMusicHelper.playType = 1
// YDLMusicHelper.courseVideoUlr = course.demoFile
//
// PlayerFloatHelper.show(mContext)
VideoFloatHelper
.
setVideoInfo
(
course
.
id
.
toString
(),
course
.
demoFile
,
false
)
checkPermission
()
if
(
PlayerFloatHelper
.
isShow
(
mContext
))
{
PlayerFloatHelper
.
hide
()
PlayerFloatHelper
.
removeView
(
mContext
)
AudioPlayer
.
get
().
stopPlayer
()
}
}
...
...
@@ -269,4 +289,27 @@ class CourseItemNewView : ConstraintLayout {
fun
hideListenerButton
()
{
tv_view_course
.
visibility
=
View
.
GONE
}
/**
* 检测浮窗权限是否开启,若没有给与申请提示框(非必须,申请依旧是EasyFloat内部内保进行)
*/
private
fun
checkPermission
()
{
if
(
PermissionUtils
.
checkPermission
(
mContext
))
{
VideoFloatHelper
.
showVideoFloat
(
mContext
as
Activity
)
}
else
{
AlertDialog
.
Builder
(
mContext
)
.
setMessage
(
"使用浮窗功能,需要您授权悬浮窗权限。"
)
.
setPositiveButton
(
"去开启"
)
{
_
,
_
->
VideoFloatHelper
.
showVideoFloat
(
mContext
as
Activity
)
}
.
setNegativeButton
(
"取消"
)
{
_
,
_
->
ToastUtil
.
toastLong
(
mContext
,
"App正常工作需要内部存储使用权限,请开启"
)
}
.
show
()
}
}
}
\ No newline at end of file
m-course/src/main/java/com/yidianling/course/widget/HPlayView.kt
View file @
866feac3
package
com.yidianling.course.widget
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.os.Handler
import
android.view.View
...
...
@@ -36,8 +37,8 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
fun
init
()
{
if
(
mContext
==
null
)
return
View
.
inflate
(
context
,
R
.
layout
.
course_play_music_view
,
this
)
AudioPlayer
.
get
().
addOnPlayEventListener
(
this
)
play_icon
.
setOnClickListener
{
AudioPlayer
.
get
().
playPause
()
...
...
@@ -48,8 +49,6 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
}
AudioPlayer
.
get
().
addOnPlayEventListener
(
this
)
pro_progress
.
setOnSeekBarChangeListener
(
object
:
SeekBar
.
OnSeekBarChangeListener
{
override
fun
onProgressChanged
(
p0
:
SeekBar
?,
p1
:
Int
,
p2
:
Boolean
)
{
if
(
p2
)
{
...
...
@@ -114,9 +113,9 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
fun
play
(
index
:
Int
)
{
updateButton
()
PlayerFloatHelper
.
playingType
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
PlayerFloatHelper
.
playingType
=
PlayTypeEnum
.
PLAY_TYPE_COURSE
AudioPlayer
.
get
().
play
(
index
)
updateButton
()
}
fun
setImageBackground
(
url
:
String
?)
{
...
...
@@ -127,14 +126,23 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
* 设置自动播放下一曲
*/
fun
setAutoNext
(
auto
:
Boolean
)
{
if
(!
auto
){
AudioPlayer
.
get
().
playMode
=
PlayModeEnum
.
SINGLE
if
(!
auto
)
{
AudioPlayer
.
get
().
playMode
=
PlayModeEnum
.
SINGLE
}
else
{
AudioPlayer
.
get
().
playMode
=
PlayModeEnum
.
LIST_LOOP
}
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
onChange
(
music
:
Music
)
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_loading5
).
into
(
img_gif
)
}
play_icon
.
setImageResource
(
R
.
drawable
.
course_ico_course_play
)
pro_progress
.
progress
=
0
text_start_time
.
text
=
"00:00"
}
override
fun
onPlayerStart
()
{
...
...
@@ -142,21 +150,18 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
override
fun
onPlayerPause
()
{
if
(
AudioPlayer
.
get
().
isPlaying
){
if
(
AudioPlayer
.
get
().
isPlaying
)
{
setGifVisibity
(
true
)
}
else
{
}
else
{
setGifVisibity
(
false
)
}
}
override
fun
onPublish
(
percent
:
Int
,
currentPosition
:
Long
)
{
mHandler
?.
postDelayed
({
//拖动seekbar时不进行以下操作
if
(!
seekBarIsDown
)
{
pro_progress
.
progress
=
progress
text_start_time
.
text
=
getStringTime
(
progress
)
}
},
0
)
if
(!
seekBarIsDown
)
{
pro_progress
.
progress
=
currentPosition
.
toInt
()
text_start_time
.
text
=
getStringTime
(
currentPosition
.
toInt
())
}
}
override
fun
onBufferingUpdate
(
percent
:
Int
)
{
...
...
@@ -170,7 +175,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
mHandler
?.
postDelayed
({
pro_progress
.
max
=
duration
.
toInt
()
text_end_time
.
text
=
getStringTime
(
pro_progress
.
max
)
var
index
=
AudioPlayer
.
get
().
getMusicList
()
?.
indexOf
(
AudioPlayer
.
get
().
playMusic
)
?:
0
var
index
=
AudioPlayer
.
get
().
getMusicList
()
?.
indexOf
(
AudioPlayer
.
get
().
playMusic
)
?:
0
listener
?.
onPrepared
(
AudioPlayer
.
get
().
playMusic
,
index
)
...
...
@@ -186,11 +191,12 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
private
fun
showBufferLoading
(
show
:
Boolean
)
{
mHandler
?.
postDelayed
({
if
(
show
)
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_loading5
).
into
(
img_gif
)
if
(!
AudioPlayer
.
get
().
isPlaying
)
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_loading5
).
into
(
img_gif
)
}
play_icon
.
setImageResource
(
R
.
drawable
.
course_ico_course_play
)
}
play_icon
.
setImageResource
(
R
.
drawable
.
course_ico_course_play
)
}
else
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_audio_play
).
into
(
img_gif
)
...
...
@@ -202,17 +208,14 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
//显示或隐藏播放动画
private
fun
setGifVisibity
(
show
:
Boolean
)
{
if
(
c
ontext
==
null
)
return
if
(
mC
ontext
==
null
)
return
mHandler
?.
postDelayed
({
if
(
show
)
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_audio_play
).
into
(
img_gif
)
}
Glide
.
with
(
mContext
).
asGif
().
load
(
R
.
drawable
.
course_audio_play
).
into
(
img_gif
)
play_icon
.
setImageResource
(
R
.
drawable
.
course_ico_course_pause
)
}
else
{
if
(
mContext
!=
null
)
{
Glide
.
with
(
mContext
).
asBitmap
().
load
(
R
.
drawable
.
course_ico_course_bg_pause
).
into
(
img_gif
)
}
Glide
.
with
(
mContext
).
asBitmap
().
load
(
R
.
drawable
.
course_ico_course_bg_pause
)
.
into
(
img_gif
)
play_icon
.
setImageResource
(
R
.
drawable
.
course_ico_course_play
)
}
},
0
)
...
...
@@ -225,7 +228,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
if
(
AudioPlayer
.
get
().
isPlaying
)
{
setGifVisibity
(
true
)
}
},
0
)
},
30
0
)
}
...
...
m-course/src/main/java/com/yidianling/course/widget/VideoFloatHelper.kt
0 → 100644
View file @
866feac3
package
com.yidianling.course.widget
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.content.Intent
import
android.view.View
import
android.widget.ImageView
import
com.alibaba.android.arouter.launcher.ARouter
import
com.dou361.ijkplayer.widget.PlayStateParams
import
com.dou361.ijkplayer.widget.PlayerView
import
com.lzf.easyfloat.EasyFloat
import
com.lzf.easyfloat.enums.ShowPattern
import
com.lzf.easyfloat.interfaces.OnInvokeView
import
com.yidianling.common.tools.RxDeviceTool
import
com.yidianling.common.tools.RxImageTool
import
com.yidianling.course.R
import
com.yidianling.course.coursePlay.CoursePlayActivity
import
com.yidianling.course.flutterPlugin.CourseSendPlugin
import
com.yidianling.course.uitls.VideoProgressUtil
import
java.util.*
/**
* @author jiucheng
* @描述:视频悬浮窗
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/11/19
*/
object
VideoFloatHelper
{
private
const
val
courseTag
=
"course_video_play"
var
courseVideoUrl
=
""
var
courseId
=
""
var
isCanClick
=
true
var
isCurrentVideoPlaying
=
true
//视频播放器view
@SuppressLint
(
"StaticFieldLeak"
)
private
var
videoView
:
PlayerView
?
=
null
private
var
timer
:
Timer
?
=
null
var
defaultShowPattern
=
ShowPattern
.
CURRENT_ACTIVITY
fun
setVideoInfo
(
courseId
:
String
,
courseVideoUrl
:
String
,
isCanClick
:
Boolean
):
VideoFloatHelper
{
this
.
courseId
=
courseId
this
.
courseVideoUrl
=
courseVideoUrl
this
.
isCanClick
=
isCanClick
return
this
}
fun
showVideoFloat
(
activity
:
Activity
)
{
val
x
=
RxDeviceTool
.
getScreenWidth
(
activity
)
-
RxImageTool
.
dp2px
(
220f
)
val
y
=
RxDeviceTool
.
getScreenHeight
(
activity
)
*
3
/
4
EasyFloat
.
with
(
activity
)
.
setTag
(
courseTag
)
.
setShowPattern
(
defaultShowPattern
)
.
setLocation
(
x
,
y
)
.
setAppFloatAnimator
(
null
)
.
setFilter
(
CoursePlayActivity
::
class
.
java
)
.
setLayout
(
R
.
layout
.
course_float_video_view
,
OnInvokeView
{
it
.
findViewById
<
ImageView
>(
R
.
id
.
iv_video_close
).
setOnClickListener
{
dismissFloat
(
activity
)
}
val
videoFullScreen
=
it
.
findViewById
<
ImageView
>(
R
.
id
.
iv_video_full_screen
)
if
(
isCanClick
)
{
videoFullScreen
.
visibility
=
View
.
VISIBLE
}
else
{
videoFullScreen
.
visibility
=
View
.
INVISIBLE
}
videoFullScreen
.
setOnClickListener
{
if
(
isCanClick
)
{
startCoursePlayActivity
(
activity
,
1
,
1
,
courseVideoUrl
,
true
)
}
}
val
videoLayout
=
it
.
findViewById
<
ImageView
>(
R
.
id
.
app_video_box
)
try
{
initVideoPlayer
(
activity
,
videoLayout
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
})
.
show
()
}
private
fun
initVideoPlayer
(
activity
:
Activity
,
view
:
View
)
{
val
url
=
courseVideoUrl
.
replace
(
"https"
,
"http"
)
val
hisTime
=
VideoProgressUtil
.
getProgress
(
activity
,
url
)
videoView
=
PlayerView
(
activity
,
view
)
.
setScaleType
(
PlayStateParams
.
fitparent
)
.
hideAllUI
()
.
setNetWorkTypeTie
(
false
)
.
setAutoReConnect
(
true
,
3
)
.
forbidTouch
(
true
)
.
setOnInfoListener
{
_
,
what
,
_
->
if
(
what
==
PlayStateParams
.
STATE_COMPLETED
)
{
isCurrentVideoPlaying
=
false
VideoProgressUtil
.
saveProgress
(
activity
,
url
,
0
)
}
else
{
isCurrentVideoPlaying
=
true
}
true
}
.
setPlaySource
(
url
)
.
startPlay
()
.
seekTo
(
hisTime
)
view
.
setOnClickListener
{
if
(
isCanClick
)
{
startCoursePlayActivity
(
activity
,
1
,
0
,
courseVideoUrl
,
true
)
}
}
startTimer
(
url
,
activity
)
}
private
fun
startTimer
(
url
:
String
,
activity
:
Activity
)
{
if
(
timer
==
null
)
{
timer
=
Timer
()
}
timer
?.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
if
(
isCurrentVideoPlaying
)
{
var
time
=
videoView
?.
currentPosition
?:
0
if
(
time
<
3000
)
return
VideoProgressUtil
.
saveProgress
(
activity
,
url
,
time
)
}
}
},
1000
,
1000
)
}
private
fun
startCoursePlayActivity
(
context
:
Context
?,
from
:
Int
,
fullScreen
:
Int
,
coursePlayUrl
:
String
,
isFromFloatView
:
Boolean
)
{
ARouter
.
getInstance
()
.
build
(
"/course/play"
)
.
withInt
(
"course_id"
,
courseId
.
toInt
())
.
withInt
(
"course_type"
,
1
)
.
withString
(
"coursePlayUrl"
,
coursePlayUrl
)
.
withInt
(
"from"
,
from
)
.
withBoolean
(
"isFromFloatView"
,
isFromFloatView
)
.
withInt
(
"fullScreen"
,
fullScreen
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
navigation
()
}
fun
dismissFloat
(
activity
:
Activity
)
{
CourseSendPlugin
.
sendMsg
(
false
)
EasyFloat
.
dismissAppFloat
(
activity
,
courseTag
)
if
(
videoView
!=
null
)
{
videoView
!!
.
stopPlay
()
videoView
=
null
}
if
(
timer
!=
null
)
{
timer
!!
.
cancel
()
}
timer
=
null
}
}
\ No newline at end of file
m-course/src/main/res/layout/course_float_video_view.xml
0 → 100644
View file @
866feac3
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/rl_video_layout"
android:layout_width=
"200dp"
android:layout_height=
"124dp"
android:background=
"@drawable/play_float_background"
android:visibility=
"visible"
>
<include
layout=
"@layout/course_videoplay_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<ImageView
android:id=
"@+id/iv_video_close"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_alignParentRight=
"true"
android:padding=
"8dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/ico_play_float_pause"
android:visibility=
"visible"
/>
<ImageView
android:id=
"@+id/iv_video_full_screen"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:padding=
"8dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/course_ico_play_float_full"
android:visibility=
"visible"
/>
</RelativeLayout>
\ 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