Commit a31b3dac by 徐健

Merge branch 'feature/v3' of…

Merge branch 'feature/v3' of ssh://gitlab.yidianling.com:2224/app_android_lib/YDL-Component into feature/v3
parents 8399861a ecbf2972
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = false dev_mode = true
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -53,7 +53,7 @@ ext { ...@@ -53,7 +53,7 @@ ext {
"m-muse" : "0.0.20.8", "m-muse" : "0.0.20.8",
"m-tests" : "0.0.15.8", "m-tests" : "0.0.15.8",
"m-course" : "0.0.34.10", "m-course" : "0.0.34.12",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.5", "m-audioim-api" : "0.0.5",
...@@ -100,7 +100,7 @@ ext { ...@@ -100,7 +100,7 @@ ext {
"m-muse" : "0.0.20.7", "m-muse" : "0.0.20.7",
"m-tests" : "0.0.15.7", "m-tests" : "0.0.15.7",
"m-course" : "0.0.34.7", "m-course" : "0.0.34.10",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.5", "m-audioim-api" : "0.0.5",
"m-confide-api" : "0.0.1.1", "m-confide-api" : "0.0.1.1",
...@@ -225,7 +225,7 @@ ext { ...@@ -225,7 +225,7 @@ ext {
"systembartint" : "com.readystatesoftware.systembartint:systembartint:1.0.3", "systembartint" : "com.readystatesoftware.systembartint:systembartint:1.0.3",
"cube" : "in.srain.cube:cube-sdk:1.0.44@aar", "cube" : "in.srain.cube:cube-sdk:1.0.44@aar",
"support-multidex" : "com.android.support:multidex:1.0.2", "support-multidex" : "com.android.support:multidex:1.0.2",
"ydl-ijkplayer-jjdxm" : "com.ydl:jjdxm-ijkplayer:0.0.3", "ydl-ijkplayer-jjdxm" : "com.ydl:jjdxm-ijkplayer:0.0.4",
"robust" : "com.meituan.robust:robust:0.4.87", "robust" : "com.meituan.robust:robust:0.4.87",
"walle" : "com.meituan.android.walle:library:1.1.5", "walle" : "com.meituan.android.walle:library:1.1.5",
"jpush" : "cn.jiguang.sdk:jpush:3.3.6", "jpush" : "cn.jiguang.sdk:jpush:3.3.6",
......
...@@ -42,7 +42,6 @@ import com.ydl.ydlcommon.view.BaseViewHolder ...@@ -42,7 +42,6 @@ import com.ydl.ydlcommon.view.BaseViewHolder
import com.ydl.ydlcommon.view.dialog.CommonDialog import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.ydl.ydlcommon.view.dialog.YDLShareDialog import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.common.tools.RxImageTool import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.RxNetTool
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.BuildConfig import com.yidianling.course.BuildConfig
import com.yidianling.course.R import com.yidianling.course.R
...@@ -67,7 +66,8 @@ class CoursePlayActivity : BaseActivity() { ...@@ -67,7 +66,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,32 +241,33 @@ class CoursePlayActivity : BaseActivity() { ...@@ -241,32 +241,33 @@ class CoursePlayActivity : BaseActivity() {
0 0
) )
if (play_type == 1) { updatePlayingListStatus(position)
//暂停状态 开始播放 // if (playList[index].mediaType == 2) {
(play_view as CoursePlayItemViewVideo)?.play(position) // play_type = 1
} // (playVideoView as CoursePlayItemViewVideo)?.play(position)
if (play_type == 0) { // }
if (RxNetTool.isWifi(this@CoursePlayActivity)) { // if (playList[index].mediaType == 1) {
(play_view as CoursePlayItemViewAudio).playView!!.play( // play_type = 0
position // if (RxNetTool.isWifi(this@CoursePlayActivity)) {
) // (playAudioView as CoursePlayItemViewAudio).playView!!.play(
} else { // position
if ((play_view as CoursePlayItemViewAudio).hasEnsureNetStatus) { // )
(play_view as CoursePlayItemViewAudio).playView!!.play( // } else {
position // if ((playAudioView as CoursePlayItemViewAudio).hasEnsureNetStatus) {
) // (playAudioView as CoursePlayItemViewAudio).playView!!.play(
} else { // position
(play_view as CoursePlayItemViewAudio).setData( // )
position, // } else {
playList, // (playAudioView as CoursePlayItemViewAudio).setData(
courPlayBean!!.courseExtra, // position,
from // playList,
) // courPlayBean!!.courseExtra,
} // from
} // )
} // }
index = position // }
adapter?.notifyDataSetChanged() // }
// adapter?.notifyDataSetChanged()
} }
} }
} }
...@@ -337,10 +338,6 @@ class CoursePlayActivity : BaseActivity() { ...@@ -337,10 +338,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,33 +423,49 @@ class CoursePlayActivity : BaseActivity() { ...@@ -426,33 +423,49 @@ 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)
} // }
//专家简介部分
headview?.setData(bean.courseExtra)
//视频
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 CoursePlayItemViewAudio)
if (play_type == 0) { if (play_type == 0) {
play_view?.setData(index, playList, bean.courseExtra, from) frame_audio_play.visibility = View.VISIBLE
frame_video_play.visibility = View.GONE
} else { } else {
play_view?.setData(index, playList, bean.courseExtra, from) frame_video_play.visibility = View.VISIBLE
frame_audio_play.visibility = View.GONE
} }
playAudioView?.setData(index, playList, bean.courseExtra, from, play_type == 0)
playVideoView?.setData(index, playList, bean.courseExtra, from, play_type == 1)
if (videoView != null && play_type == 1 && fullScreen == 1) { if (videoView != null && play_type == 1 && fullScreen == 1) {
videoView!!.toggleFullScreen() videoView!!.toggleFullScreen()
videoView!!.setNetWorkTypeTie(false) videoView!!.setNetWorkTypeTie(false)
videoView!!.startPlay() videoView!!.startPlay()
} }
//专家简介部分
headview?.setData(bean.courseExtra)
tv_title_full.text = bean.courseExtra.title tv_title_full.text = bean.courseExtra.title
text_price.text = "立即购买 ¥" + bean.courseExtra.applyFee text_price.text = "立即购买 ¥" + bean.courseExtra.applyFee
...@@ -474,13 +487,13 @@ class CoursePlayActivity : BaseActivity() { ...@@ -474,13 +487,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 +504,51 @@ class CoursePlayActivity : BaseActivity() { ...@@ -491,6 +504,51 @@ 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].isDemo && !courPlayBean!!.courseExtra.isBuy) {
if (AudioPlayer.get().isPlaying) {
AudioPlayer.get().playPause()
}
if (videoView != null) {
videoView?.pausePlay()
}
CommonDialog(this@CoursePlayActivity)
.setMessage("\n购买课程,获取完整课程内容\n")
.setLeftOnclick("放弃") {
}
.setRightClick("购买") {
//跳转支付页
addCourseOrder()
}
.setCancelAble(false)
.show()
return
}
if (playList[index].mediaType == 1) {
play_type = 0
frame_video_play.visibility = View.GONE
frame_audio_play.visibility = View.VISIBLE
(playAudioView as CoursePlayItemViewAudio).playView?.play(
index
)
if (videoView != null) {
videoView?.pausePlay()
}
}
if (playList[index].mediaType == 2) {
play_type = 1
frame_video_play.visibility = View.VISIBLE
frame_audio_play.visibility = View.GONE
(playVideoView as CoursePlayItemViewVideo)?.play(index)
if (AudioPlayer.get().isPlaying) {
AudioPlayer.get().playPause()
}
}
this.index = index this.index = index
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} }
...@@ -573,18 +631,21 @@ class CoursePlayActivity : BaseActivity() { ...@@ -573,18 +631,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 +714,7 @@ class CoursePlayActivity : BaseActivity() { ...@@ -653,7 +714,7 @@ class CoursePlayActivity : BaseActivity() {
VideoFloatHelper.setVideoInfo( VideoFloatHelper.setVideoInfo(
course_id.toString(), course_id.toString(),
(play_view as CoursePlayItemViewVideo).videoUrl!!, (playVideoView as CoursePlayItemViewVideo).videoUrl!!,
true true
) )
VideoFloatHelper.defaultShowPattern = ShowPattern.FOREGROUND VideoFloatHelper.defaultShowPattern = ShowPattern.FOREGROUND
...@@ -691,7 +752,9 @@ class CoursePlayActivity : BaseActivity() { ...@@ -691,7 +752,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
} }
} }
...@@ -106,7 +106,8 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -106,7 +106,8 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
index: Int, index: Int,
list: ArrayList<CourseMediaBean>, list: ArrayList<CourseMediaBean>,
courseExtra: CourseExtraBean, courseExtra: CourseExtraBean,
from: Int from: Int,
isAutoPlay: Boolean
) { ) {
if (list.isEmpty()) return if (list.isEmpty()) return
...@@ -135,10 +136,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -135,10 +136,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
playView?.play(currentIndex) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} else { } else {
playView?.play(index) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} else { } else {
if (hasEnsureNetStatus) { if (hasEnsureNetStatus) {
...@@ -146,10 +151,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -146,10 +151,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
playView?.play(currentIndex) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} else { } else {
playView?.play(currentIndex) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} else { } else {
playView?.showNetNotice { playView?.showNetNotice {
...@@ -158,10 +167,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -158,10 +167,14 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
playView?.play(currentIndex) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} else { } else {
playView?.play(currentIndex) if (isAutoPlay){
playView?.play(currentIndex)
}
} }
} }
} }
......
...@@ -61,7 +61,10 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -61,7 +61,10 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
initView() initView()
wakeLock = (activity!!.getSystemService(Context.POWER_SERVICE) as PowerManager) wakeLock = (activity!!.getSystemService(Context.POWER_SERVICE) as PowerManager)
.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE, "CoursePlayItemViewVideo") .newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE,
"CoursePlayItemViewVideo"
)
} }
override fun onNewIntent() { override fun onNewIntent() {
...@@ -140,87 +143,130 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -140,87 +143,130 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
//未购买,判断是否是试听课程 //未购买,判断是否是试听课程
//即未购买,也不是试听,弹窗提示 //即未购买,也不是试听,弹窗提示
CommonDialog(activity) CommonDialog(activity)
.setMessage("\n购买课程,获取完整课程内容\n") .setMessage("\n购买课程,获取完整课程内容\n")
.setLeftOnclick("放弃") { .setLeftOnclick("放弃") {
} }
.setRightClick("购买") { .setRightClick("购买") {
//跳转支付页 //跳转支付页
activity?.addCourseOrder() activity?.addCourseOrder()
} }
.setCancelAble(false) .setCancelAble(false)
.show() .show()
} }
} }
if (canPlay) { if (canPlay) {
PlayerFloatHelper.playingType=PlayTypeEnum.PLAY_TYPE_COURSE PlayerFloatHelper.playingType = PlayTypeEnum.PLAY_TYPE_COURSE
var url = playList[index].url var url = playList[index].url
url = url.replace("https", "http") // url = url.replace("https", "http")
videoUrl = url videoUrl = url
var hisTime = PlayProgressUtil.getProgress(context, url) var hisTime = PlayProgressUtil.getProgress(context, url)
try { try {
activity?.videoView = PlayerView(activity) activity?.videoView = PlayerView(activity)
.setScaleType(PlayStateParams.fitparent) .setScaleType(PlayStateParams.fitparent)
.hideMenu(true) .hideMenu(true)
.hideRotation(true) .hideRotation(true)
.setNetWorkTypeTie(!hasEnsureNetStatus) .setNetWorkTypeTie(!hasEnsureNetStatus)
.hideBack(true) .hideBack(true)
.hideSteam(true) .hideSteam(true)
.setAutoReConnect(true, 3) .setAutoReConnect(true, 3)
.forbidTouch(false) .forbidTouch(false)
.setOnInfoListener(object : IMediaPlayer.OnInfoListener { .setOnInfoListener(object : IMediaPlayer.OnInfoListener {
override fun onInfo(mp: IMediaPlayer, what: Int, extra: Int): Boolean { override fun onInfo(mp: IMediaPlayer, what: Int, extra: Int): Boolean {
LogUtil.e("课程播放--状态-$what") LogUtil.e("课程播放--状态-$what")
if (what == PlayStateParams.STATE_PAUSED) { if (what == PlayStateParams.MEDIA_INFO_VIDEO_INTERRUPT) {
this@CoursePlayItemViewVideo.findViewById<View>(R.id.rl_play_pause_layout).visibility = View.VISIBLE activity?.videoView?.startPlay()
} else { }
this@CoursePlayItemViewVideo.findViewById<View>(R.id.rl_play_pause_layout).visibility = View.GONE
}
if (what == PlayStateParams.STATE_PLAYING) { if (what == PlayStateParams.STATE_PAUSED) {
this@CoursePlayItemViewVideo.findViewById<View>(R.id.app_video_loading).visibility = View.GONE this@CoursePlayItemViewVideo.findViewById<View>(R.id.rl_play_pause_layout)
} .visibility = View.VISIBLE
if (what == PlayStateParams.MEDIA_INFO_BUFFERING_END } else {
|| what == PlayStateParams.MEDIA_INFO_AUDIO_RENDERING_START this@CoursePlayItemViewVideo.findViewById<View>(R.id.rl_play_pause_layout)
|| what == PlayStateParams.MEDIA_INFO_VIDEO_RENDERING_START .visibility = View.GONE
|| what == PlayStateParams.STATE_PLAYING }
|| what == IMediaPlayer.MEDIA_INFO_VIDEO_SEEK_RENDERING_START
) {
activity?.isVideoPlay = true
this@CoursePlayItemViewVideo.findViewById<View>(R.id.ll_bg).visibility = View.GONE
this@CoursePlayItemViewVideo.findViewById<View>(R.id.ll_loading).visibility = View.GONE
this@CoursePlayItemViewVideo.findViewById<View>(R.id.app_video_loading).visibility = View.GONE
}
if (what == PlayStateParams.STATE_COMPLETED) { if (what == PlayStateParams.STATE_PLAYING) {
isVideoPlaying = false this@CoursePlayItemViewVideo.findViewById<View>(R.id.app_video_loading)
PlayProgressUtil.saveProgress(this@CoursePlayItemViewVideo.activity, videoUrl, 0) .visibility = View.GONE
if (playList.size - 1 > this@CoursePlayItemViewVideo.index) {
//播放下一曲
play(this@CoursePlayItemViewVideo.index + 1)
activity!!.updatePlayingListStatus(this@CoursePlayItemViewVideo.index)
}
} else {
isVideoPlaying = true
}
return true
} }
}) if (what == PlayStateParams.MEDIA_INFO_BUFFERING_END
.showThumbnail { ivThumbnail -> || what == PlayStateParams.MEDIA_INFO_AUDIO_RENDERING_START
run { || what == PlayStateParams.MEDIA_INFO_VIDEO_RENDERING_START
ivThumbnail.alpha = 0.5f || what == PlayStateParams.STATE_PLAYING
GlideApp.with(context) || what == IMediaPlayer.MEDIA_INFO_VIDEO_SEEK_RENDERING_START
.load(courseExtra!!.pic) ) {
.into(ivThumbnail) activity?.isVideoPlay = true
this@CoursePlayItemViewVideo.findViewById<View>(R.id.ll_bg)
.visibility = View.GONE
this@CoursePlayItemViewVideo.findViewById<View>(R.id.ll_loading)
.visibility = View.GONE
this@CoursePlayItemViewVideo.findViewById<View>(R.id.app_video_loading)
.visibility = View.GONE
}
if (what == PlayStateParams.STATE_COMPLETED) {
isVideoPlaying = false
PlayProgressUtil.saveProgress(
this@CoursePlayItemViewVideo.activity,
videoUrl,
0
)
if (playList.size - 1 > this@CoursePlayItemViewVideo.index) {
//播放下一曲
// play(this@CoursePlayItemViewVideo.index + 1)
this@CoursePlayItemViewVideo.index =
this@CoursePlayItemViewVideo.index + 1
activity!!.updatePlayingListStatus(this@CoursePlayItemViewVideo.index)
this@CoursePlayItemViewVideo.findViewById<View>(R.id.ll_loading)
.visibility = View.VISIBLE
this@CoursePlayItemViewVideo.findViewById<View>(R.id.app_video_loading)
.visibility = View.VISIBLE
}
} else {
isVideoPlaying = true
} }
return true
}
})
.showThumbnail { ivThumbnail ->
run {
ivThumbnail.alpha = 0.5f
GlideApp.with(context)
.load(courseExtra!!.pic)
.into(ivThumbnail)
} }
.setPlaySource(url) }
.startPlay() .setPlaySource(url)
.seekTo(hisTime) .startPlay()
.seekTo(hisTime)
// try {
// var videoViewField =
// activity?.videoView.run { javaClass.getDeclaredField("videoView") }
// videoViewField.isAccessible = true
//
// var ijkVideoView = videoViewField.get(activity?.videoView) as IjkVideoView
// var mMediaPlayerField = ijkVideoView.javaClass.getDeclaredField("mMediaPlayer")
//
// var mMediaPlayerObject = mMediaPlayerField.get(ijkVideoView)
// if (mMediaPlayerObject is IjkMediaPlayer) {
// mMediaPlayerObject.setOption(
// IjkMediaPlayer.OPT_CATEGORY_FORMAT,
// "dns_cache_clear",
// 1
// )
// }
// } catch (e: java.lang.Exception) {
//
// }
//
// activity?.videoView?.startPlay()?.seekTo(hisTime)
val layout = activity?.window?.attributes val layout = activity?.window?.attributes
layout?.screenBrightness = -1f layout?.screenBrightness = -1f
activity?.window?.attributes = layout activity?.window?.attributes = layout
...@@ -234,13 +280,21 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -234,13 +280,21 @@ class CoursePlayItemViewVideo : 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,
isAutoPlay: Boolean
) {
if (list.isEmpty()) return if (list.isEmpty()) return
playList.clear() playList.clear()
playList.addAll(list) playList.addAll(list)
this.courseExtra = courseExtra this.courseExtra = courseExtra
play(index) if (isAutoPlay) {
play(index)
}
} }
override fun onDestroy() { override fun onDestroy() {
......
...@@ -18,7 +18,13 @@ interface PlayViewInterface { ...@@ -18,7 +18,13 @@ interface PlayViewInterface {
fun onDestroy() fun onDestroy()
//from 1表示通知栏进来,2表示悬浮按钮进来 index:播放下标 //from 1表示通知栏进来,2表示悬浮按钮进来 index:播放下标
fun setData(index: Int, list: ArrayList<CourseMediaBean>, courseExtra: CourseExtraBean, from: Int) fun setData(
index: Int,
list: ArrayList<CourseMediaBean>,
courseExtra: CourseExtraBean,
from: Int,
isAutoPlay: Boolean = true
)
fun onNewIntent() fun onNewIntent()
......
...@@ -40,7 +40,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener { ...@@ -40,7 +40,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
View.inflate(context, R.layout.course_play_music_view, this) View.inflate(context, R.layout.course_play_music_view, this)
AudioPlayer.get().addOnPlayEventListener(this) AudioPlayer.get().addOnPlayEventListener(this)
play_icon.setOnClickListener { course_audio_play_icon.setOnClickListener {
AudioPlayer.get().playPause() AudioPlayer.get().playPause()
} }
img_gif.setOnClickListener { img_gif.setOnClickListener {
...@@ -91,9 +91,6 @@ class HPlayView : RelativeLayout, OnPlayerEventListener { ...@@ -91,9 +91,6 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
return this return this
} }
/**
* 后台进入前台view
*/
fun updateView(index: Int) { fun updateView(index: Int) {
if (AudioPlayer.get().isPlaying) { if (AudioPlayer.get().isPlaying) {
mHandler?.postDelayed({ mHandler?.postDelayed({
...@@ -139,7 +136,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener { ...@@ -139,7 +136,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
if (mContext != null) { if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif) Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif)
} }
play_icon.setImageResource(R.drawable.course_ico_course_play) course_audio_play_icon.setImageResource(R.drawable.course_ico_course_play)
pro_progress.progress = 0 pro_progress.progress = 0
text_start_time.text = "00:00" text_start_time.text = "00:00"
...@@ -195,13 +192,13 @@ class HPlayView : RelativeLayout, OnPlayerEventListener { ...@@ -195,13 +192,13 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
if (mContext != null) { if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif) Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif)
} }
play_icon.setImageResource(R.drawable.course_ico_course_play) course_audio_play_icon.setImageResource(R.drawable.course_ico_course_play)
} }
} else { } else {
if (mContext != null) { 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) course_audio_play_icon.setImageResource(R.drawable.course_ico_course_pause)
} }
}, 0) }, 0)
} }
...@@ -212,11 +209,11 @@ class HPlayView : RelativeLayout, OnPlayerEventListener { ...@@ -212,11 +209,11 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
mHandler?.postDelayed({ mHandler?.postDelayed({
if (show) { if (show) {
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) course_audio_play_icon.setImageResource(R.drawable.course_ico_course_pause)
} else { } else {
Glide.with(mContext).asBitmap().load(R.drawable.course_ico_course_bg_pause) Glide.with(mContext).asBitmap().load(R.drawable.course_ico_course_bg_pause)
.into(img_gif) .into(img_gif)
play_icon.setImageResource(R.drawable.course_ico_course_play) course_audio_play_icon.setImageResource(R.drawable.course_ico_course_play)
} }
}, 0) }, 0)
} }
......
...@@ -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="visible" />
<FrameLayout
android:id="@+id/frame_video_play"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:visibility="visible" />
</FrameLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/title_bar_layout" android:id="@+id/title_bar_layout"
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
android:layout_marginBottom="15dp"> android:layout_marginBottom="15dp">
<ImageView <ImageView
android:id="@+id/play_icon" android:id="@+id/course_audio_play_icon"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="-3dp" android:layout_marginLeft="-3dp"
android:layout_toLeftOf="@+id/text_start_time" android:layout_toLeftOf="@+id/text_start_time"
android:layout_toRightOf="@+id/play_icon" android:layout_toRightOf="@+id/course_audio_play_icon"
android:maxHeight="2dp" android:maxHeight="2dp"
android:minHeight="2dp" android:minHeight="2dp"
android:progressDrawable="@drawable/course_layer_progress" android:progressDrawable="@drawable/course_layer_progress"
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
android:layout_height="40dp" android:layout_height="40dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="3dp" android:layout_marginLeft="3dp"
android:padding="1dp" android:padding="3dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/course_ico_course_play" /> android:src="@drawable/course_ico_course_play" />
......
...@@ -13,6 +13,7 @@ import com.ydl.media.audio.manager.NotifyManager ...@@ -13,6 +13,7 @@ import com.ydl.media.audio.manager.NotifyManager
import com.ydl.media.audio.model.Music import com.ydl.media.audio.model.Music
import com.ydl.media.audio.receiver.NoisyAudioStreamReceiver import com.ydl.media.audio.receiver.NoisyAudioStreamReceiver
import com.ydl.media.audio.utils.PlayProgressUtil import com.ydl.media.audio.utils.PlayProgressUtil
import com.ydl.ydlcommon.utils.LogUtil
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import tv.danmaku.ijk.media.player.IMediaPlayer import tv.danmaku.ijk.media.player.IMediaPlayer
import tv.danmaku.ijk.media.player.IjkMediaPlayer import tv.danmaku.ijk.media.player.IjkMediaPlayer
...@@ -45,7 +46,11 @@ class AudioPlayer private constructor() { ...@@ -45,7 +46,11 @@ class AudioPlayer private constructor() {
var percent = (current * 100 / du).toInt() var percent = (current * 100 / du).toInt()
//保存进度 //保存进度
if (autoSaveProgress) { if (autoSaveProgress) {
PlayProgressUtil.saveProgress(context, playMusic!!.path, (if (percent == 99 || percent == 100) 0 else current.toInt())) PlayProgressUtil.saveProgress(
context,
playMusic!!.path,
(if (percent == 99 || percent == 100) 0 else current.toInt())
)
} }
for (listener in listeners) { for (listener in listeners) {
listener.onPublish(percent, current.toLong()) listener.onPublish(percent, current.toLong())
...@@ -115,6 +120,16 @@ class AudioPlayer private constructor() { ...@@ -115,6 +120,16 @@ class AudioPlayer private constructor() {
this.context = context.applicationContext this.context = context.applicationContext
audioFocusManager = AudioFocusManager(context) audioFocusManager = AudioFocusManager(context)
mediaPlayer = IjkMediaPlayer() mediaPlayer = IjkMediaPlayer()
try {
(mediaPlayer as IjkMediaPlayer).setOption(
IjkMediaPlayer.OPT_CATEGORY_FORMAT,
"dns_cache_clear",
1
)
} catch (e: Exception) {
LogUtil.e(e.message)
}
mediaPlayer!!.setOnPreparedListener { mp -> mediaPlayer!!.setOnPreparedListener { mp ->
if (isPreparing) { if (isPreparing) {
if (autoSaveProgress) { if (autoSaveProgress) {
...@@ -340,7 +355,7 @@ class AudioPlayer private constructor() { ...@@ -340,7 +355,7 @@ class AudioPlayer private constructor() {
mediaPlayer!!.pause() mediaPlayer!!.pause()
state = STATE_PAUSE state = STATE_PAUSE
handler!!.removeCallbacks(mPublishRunnable) handler!!.removeCallbacks(mPublishRunnable)
if(isShowNotify){ if (isShowNotify) {
NotifyManager.get().showPause(playMusic) NotifyManager.get().showPause(playMusic)
MediaSessionManager.get().updatePlaybackState() MediaSessionManager.get().updatePlaybackState()
} }
...@@ -425,7 +440,11 @@ class AudioPlayer private constructor() { ...@@ -425,7 +440,11 @@ class AudioPlayer private constructor() {
mediaPlayer!!.seekTo(currentPosition) mediaPlayer!!.seekTo(currentPosition)
MediaSessionManager.get().updatePlaybackState() MediaSessionManager.get().updatePlaybackState()
if (autoSaveProgress) { if (autoSaveProgress) {
PlayProgressUtil.saveProgress(context, musicList[playPosition].coverPath, currentPosition.toInt()) PlayProgressUtil.saveProgress(
context,
musicList[playPosition].coverPath,
currentPosition.toInt()
)
} }
for (listener in listeners) { for (listener in listeners) {
listener.onPublish(currentPercent, currentPosition) listener.onPublish(currentPercent, currentPosition)
......
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