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
87eb5150
Commit
87eb5150
authored
Dec 23, 2019
by
严久程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程切换音视频播放问题修复
parent
db858acd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
100 deletions
+164
-100
CoursePlayActivity.kt
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayActivity.kt
+63
-34
CoursePlayItemViewVideo.kt
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayItemViewVideo.kt
+85
-65
activity_course_play.xml
m-course/src/main/res/layout/activity_course_play.xml
+16
-1
No files found.
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayActivity.kt
View file @
87eb5150
...
@@ -67,7 +67,8 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -67,7 +67,8 @@ class CoursePlayActivity : BaseActivity() {
/*******************播放器模块*******************/
/*******************播放器模块*******************/
//音视频模块
//音视频模块
var
play_view
:
PlayViewInterface
?
=
null
var
playAudioView
:
PlayViewInterface
?
=
null
var
playVideoView
:
PlayViewInterface
?
=
null
//当前播放模式 0音频播放 1视频播放
//当前播放模式 0音频播放 1视频播放
var
play_type
=
0
var
play_type
=
0
...
@@ -241,22 +242,25 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -241,22 +242,25 @@ class CoursePlayActivity : BaseActivity() {
0
0
)
)
if
(
play_type
==
1
)
{
index
=
position
//暂停状态 开始播放
(
play_view
as
CoursePlayItemViewVideo
)
?.
play
(
position
)
if
(
playList
[
index
].
mediaType
==
2
)
{
play_type
=
1
(
playVideoView
as
CoursePlayItemViewVideo
)
?.
play
(
position
)
}
}
if
(
play_type
==
0
)
{
if
(
playList
[
index
].
mediaType
==
1
)
{
play_type
=
0
if
(
RxNetTool
.
isWifi
(
this
@CoursePlayActivity
))
{
if
(
RxNetTool
.
isWifi
(
this
@CoursePlayActivity
))
{
(
play
_v
iew
as
CoursePlayItemViewAudio
).
playView
!!
.
play
(
(
play
AudioV
iew
as
CoursePlayItemViewAudio
).
playView
!!
.
play
(
position
position
)
)
}
else
{
}
else
{
if
((
play
_v
iew
as
CoursePlayItemViewAudio
).
hasEnsureNetStatus
)
{
if
((
play
AudioV
iew
as
CoursePlayItemViewAudio
).
hasEnsureNetStatus
)
{
(
play
_v
iew
as
CoursePlayItemViewAudio
).
playView
!!
.
play
(
(
play
AudioV
iew
as
CoursePlayItemViewAudio
).
playView
!!
.
play
(
position
position
)
)
}
else
{
}
else
{
(
play
_v
iew
as
CoursePlayItemViewAudio
).
setData
(
(
play
AudioV
iew
as
CoursePlayItemViewAudio
).
setData
(
position
,
position
,
playList
,
playList
,
courPlayBean
!!
.
courseExtra
,
courPlayBean
!!
.
courseExtra
,
...
@@ -265,7 +269,6 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -265,7 +269,6 @@ class CoursePlayActivity : BaseActivity() {
}
}
}
}
}
}
index
=
position
adapter
?.
notifyDataSetChanged
()
adapter
?.
notifyDataSetChanged
()
}
}
}
}
...
@@ -337,10 +340,6 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -337,10 +340,6 @@ class CoursePlayActivity : BaseActivity() {
)
{
)
{
receiverPlayUrl
=
AudioPlayer
.
get
().
playMusic
?.
path
receiverPlayUrl
=
AudioPlayer
.
get
().
playMusic
?.
path
}
}
// if (YDLMusicHelper.isCoursePlaying() && TextUtils.isEmpty(receiverPlayUrl)) {
// receiverPlayUrl = YDLMusicHelper.getCurrentData()?.url
// }
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
}
}
...
@@ -426,24 +425,35 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -426,24 +425,35 @@ class CoursePlayActivity : BaseActivity() {
}
}
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
}
}
if
(
play_type
==
1
)
{
//视频
// if (play_type == 1) {//视频
play_view
=
CoursePlayItemViewVideo
.
create
(
this
,
play_type
)
// playVideoView = CoursePlayItemViewVideo.create(this, play_type)
(
play_view
as
CoursePlayItemViewVideo
).
hasEnsureNetStatus
=
isCancelNetCheck
// (playVideoView as CoursePlayItemViewVideo).hasEnsureNetStatus = isCancelNetCheck
frame_play
.
addView
(
play_view
as
CoursePlayItemViewVideo
)
// frame_video_play.addView(playVideoView as CoursePlayItemViewVideo)
}
else
{
//音频
// } else {//音频
play_view
=
CoursePlayItemViewAudio
.
create
(
this
,
play_type
)
// playAudioView = CoursePlayItemViewAudio.create(this, play_type)
(
play_view
as
CoursePlayItemViewAudio
).
hasEnsureNetStatus
=
isCancelNetCheck
// (playAudioView as CoursePlayItemViewAudio).hasEnsureNetStatus = isCancelNetCheck
frame_play
.
addView
(
play_view
as
CoursePlayItemViewAudio
)
// frame_audio_play.addView(playAudioView as CoursePlayItemViewVideo)
}
// }
//视频
playVideoView
=
CoursePlayItemViewVideo
.
create
(
this
,
play_type
)
(
playVideoView
as
CoursePlayItemViewVideo
).
hasEnsureNetStatus
=
isCancelNetCheck
frame_video_play
.
addView
(
playVideoView
as
CoursePlayItemViewVideo
)
//音频
playAudioView
=
CoursePlayItemViewAudio
.
create
(
this
,
play_type
)
(
playAudioView
as
CoursePlayItemViewAudio
).
hasEnsureNetStatus
=
isCancelNetCheck
frame_audio_play
.
addView
(
playAudioView
as
CoursePlayItemViewVideo
)
if
(
play_type
==
0
)
{
if
(
play_type
==
0
)
{
play_view
?.
setData
(
index
,
playList
,
bean
.
courseExtra
,
from
)
playAudioView
?.
setData
(
index
,
playList
,
bean
.
courseExtra
,
from
)
frame_audio_play
.
visibility
=
View
.
VISIBLE
}
else
{
}
else
{
play_view
?.
setData
(
index
,
playList
,
bean
.
courseExtra
,
from
)
playVideoView
?.
setData
(
index
,
playList
,
bean
.
courseExtra
,
from
)
frame_audio_play
.
visibility
=
View
.
GONE
}
}
if
(
videoView
!=
null
&&
play_type
==
1
&&
fullScreen
==
1
)
{
if
(
videoView
!=
null
&&
play_type
==
1
&&
fullScreen
==
1
)
{
...
@@ -474,13 +484,13 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -474,13 +484,13 @@ class CoursePlayActivity : BaseActivity() {
//设置播放列表数据
//设置播放列表数据
private
fun
setPlayList
(
bean
:
CourseMediaDetailBean
)
{
private
fun
setPlayList
(
bean
:
CourseMediaDetailBean
)
{
if
(
bean
.
voiceSample
.
courseMedia
!=
null
&&
bean
.
voiceSample
.
courseMedia
.
isNotEmpty
())
{
if
(
bean
.
voiceSample
.
courseMedia
.
isNotEmpty
())
{
for
(
voiceSampleData
in
bean
.
voiceSample
.
courseMedia
)
{
for
(
voiceSampleData
in
bean
.
voiceSample
.
courseMedia
)
{
voiceSampleData
.
isDemo
=
true
voiceSampleData
.
isDemo
=
true
playList
.
add
(
voiceSampleData
)
playList
.
add
(
voiceSampleData
)
}
}
}
}
if
(
bean
.
voiceWhole
.
courseMedia
!=
null
&&
bean
.
voiceWhole
.
courseMedia
.
isNotEmpty
())
{
if
(
bean
.
voiceWhole
.
courseMedia
.
isNotEmpty
())
{
for
(
voiceCourseData
in
bean
.
voiceWhole
.
courseMedia
)
{
for
(
voiceCourseData
in
bean
.
voiceWhole
.
courseMedia
)
{
playList
.
add
(
voiceCourseData
)
playList
.
add
(
voiceCourseData
)
}
}
...
@@ -491,6 +501,20 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -491,6 +501,20 @@ class CoursePlayActivity : BaseActivity() {
fun
updatePlayingListStatus
(
index
:
Int
)
{
fun
updatePlayingListStatus
(
index
:
Int
)
{
if
(
index
<
playList
.
size
&&
this
.
index
!=
index
)
{
if
(
index
<
playList
.
size
&&
this
.
index
!=
index
)
{
if
(
playList
[
index
].
mediaType
==
1
)
{
frame_video_play
.
visibility
=
View
.
GONE
frame_audio_play
.
visibility
=
View
.
VISIBLE
(
playAudioView
as
CoursePlayItemViewAudio
).
playView
?.
play
(
index
)
}
if
(
playList
[
index
].
mediaType
==
2
)
{
frame_video_play
.
visibility
=
View
.
VISIBLE
frame_audio_play
.
visibility
=
View
.
GONE
(
playVideoView
as
CoursePlayItemViewVideo
)
?.
play
(
index
)
}
this
.
index
=
index
this
.
index
=
index
adapter
?.
notifyDataSetChanged
()
adapter
?.
notifyDataSetChanged
()
}
}
...
@@ -573,18 +597,21 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -573,18 +597,21 @@ class CoursePlayActivity : BaseActivity() {
private
fun
toTrend
(
share
:
ShareData
)
{
private
fun
toTrend
(
share
:
ShareData
)
{
var
url
=
if
(
TextUtils
.
isEmpty
(
share
.
url
))
share
.
share_url
else
share
.
url
var
url
=
if
(
TextUtils
.
isEmpty
(
share
.
url
))
share
.
share_url
else
share
.
url
CourseIn
.
getDynamicService
().
publishArticleToTrend
(
this
@CoursePlayActivity
,
url
!!
,
share
.
cover
!!
,
share
.
title
!!
)
CourseIn
.
getDynamicService
()
.
publishArticleToTrend
(
this
@CoursePlayActivity
,
url
!!
,
share
.
cover
!!
,
share
.
title
!!
)
}
}
override
fun
onPause
()
{
override
fun
onPause
()
{
super
.
onPause
()
super
.
onPause
()
videoView
?.
onPause
()
videoView
?.
onPause
()
play_view
?.
onPause
()
playVideoView
?.
onPause
()
playAudioView
?.
onPause
()
}
}
override
fun
onResume
()
{
override
fun
onResume
()
{
super
.
onResume
()
super
.
onResume
()
play_view
?.
onResume
()
playVideoView
?.
onResume
()
playAudioView
?.
onResume
()
if
(
PlayerFloatHelper
.
isShow
(
this
))
{
if
(
PlayerFloatHelper
.
isShow
(
this
))
{
PlayerFloatHelper
.
removeView
(
this
)
PlayerFloatHelper
.
removeView
(
this
)
...
@@ -653,7 +680,7 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -653,7 +680,7 @@ class CoursePlayActivity : BaseActivity() {
VideoFloatHelper
.
setVideoInfo
(
VideoFloatHelper
.
setVideoInfo
(
course_id
.
toString
(),
course_id
.
toString
(),
(
play
_v
iew
as
CoursePlayItemViewVideo
).
videoUrl
!!
,
(
play
VideoV
iew
as
CoursePlayItemViewVideo
).
videoUrl
!!
,
true
true
)
)
VideoFloatHelper
.
defaultShowPattern
=
ShowPattern
.
FOREGROUND
VideoFloatHelper
.
defaultShowPattern
=
ShowPattern
.
FOREGROUND
...
@@ -691,7 +718,9 @@ class CoursePlayActivity : BaseActivity() {
...
@@ -691,7 +718,9 @@ class CoursePlayActivity : BaseActivity() {
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
videoView
?.
onDestroy
()
videoView
?.
onDestroy
()
play_view
?.
onDestroy
()
playAudioView
?.
onDestroy
()
play_view
=
null
playVideoView
?.
onDestroy
()
playAudioView
=
null
playVideoView
=
null
}
}
}
}
m-course/src/main/java/com/yidianling/course/coursePlay/CoursePlayItemViewVideo.kt
View file @
87eb5150
This diff is collapsed.
Click to expand it.
m-course/src/main/res/layout/activity_course_play.xml
View file @
87eb5150
...
@@ -37,7 +37,22 @@
...
@@ -37,7 +37,22 @@
android:id=
"@+id/frame_play"
android:id=
"@+id/frame_play"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@color/transparent"
/>
android:background=
"@color/transparent"
>
<FrameLayout
android:id=
"@+id/frame_audio_play"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/transparent"
android:visibility=
"gone"
/>
<FrameLayout
android:id=
"@+id/frame_video_play"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/transparent"
android:visibility=
"gone"
/>
</FrameLayout>
<RelativeLayout
<RelativeLayout
android:id=
"@+id/title_bar_layout"
android:id=
"@+id/title_bar_layout"
...
...
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