Commit caed21b3 by 严久程

音视频播放

parent 866feac3
...@@ -9,6 +9,7 @@ import com.ydl.devicesidlib.DeviceIDHelper; ...@@ -9,6 +9,7 @@ import com.ydl.devicesidlib.DeviceIDHelper;
import com.ydl.media.audio.PlayService; import com.ydl.media.audio.PlayService;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles; import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil; import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.yidianling.course.lifeCallback.CoursePlayLifecycle;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
...@@ -37,6 +38,8 @@ public class DemoAppLifecycles implements IAppLifecycles { ...@@ -37,6 +38,8 @@ public class DemoAppLifecycles implements IAppLifecycles {
Intent intent = new Intent(application, PlayService.class); Intent intent = new Intent(application, PlayService.class);
application.startService(intent); application.startService(intent);
application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
} }
@Override @Override
......
...@@ -20,7 +20,9 @@ import com.ydl.media.audio.model.Music; ...@@ -20,7 +20,9 @@ import com.ydl.media.audio.model.Music;
import com.ydl.media.audio.utils.CoverImageUtils; import com.ydl.media.audio.utils.CoverImageUtils;
import com.ydl.media.view.PlayTypeEnum; import com.ydl.media.view.PlayTypeEnum;
import com.ydl.media.view.PlayerFloatHelper; import com.ydl.media.view.PlayerFloatHelper;
import com.ydl.ydlcommon.utils.LogUtil;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.LoginUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
...@@ -291,6 +293,6 @@ public class PlayFragment extends Fragment implements View.OnClickListener, ...@@ -291,6 +293,6 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
@Override @Override
public void onComplete() { public void onComplete() {
LogUtil.e("onComplete");
} }
} }
...@@ -20,6 +20,7 @@ import com.alibaba.android.arouter.facade.annotation.Route ...@@ -20,6 +20,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.dou361.ijkplayer.widget.PlayStateParams import com.dou361.ijkplayer.widget.PlayStateParams
import com.dou361.ijkplayer.widget.PlayerView import com.dou361.ijkplayer.widget.PlayerView
import com.lzf.easyfloat.enums.ShowPattern
import com.lzf.easyfloat.permission.PermissionUtils import com.lzf.easyfloat.permission.PermissionUtils
import com.ydl.media.audio.AudioPlayer import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.utils.PlayProgressUtil import com.ydl.media.audio.utils.PlayProgressUtil
...@@ -495,12 +496,6 @@ class CoursePlayActivity : BaseActivity() { ...@@ -495,12 +496,6 @@ class CoursePlayActivity : BaseActivity() {
} }
} }
fun showPlayAnim(isShowAnim: Boolean) {
this.isShowAnim = isShowAnim
if (adapter != null) {
adapter?.notifyDataSetChanged()
}
}
fun showLoadingDialog() { fun showLoadingDialog() {
...@@ -643,11 +638,12 @@ class CoursePlayActivity : BaseActivity() { ...@@ -643,11 +638,12 @@ class CoursePlayActivity : BaseActivity() {
val hashMap = HashMap<String, String>() val hashMap = HashMap<String, String>()
hashMap["course_id"] = course_id.toString() hashMap["course_id"] = course_id.toString()
PlayerFloatHelper.show( PlayerFloatHelper.playTempData.putAll(hashMap)
this, // PlayerFloatHelper.show(
playTypeEnum = PlayTypeEnum.PLAY_TYPE_COURSE, // this,
playData = hashMap // playTypeEnum = PlayTypeEnum.PLAY_TYPE_COURSE,
) // playData = hashMap
// )
} }
...@@ -668,16 +664,13 @@ class CoursePlayActivity : BaseActivity() { ...@@ -668,16 +664,13 @@ class CoursePlayActivity : BaseActivity() {
// YDLMusicHelper.courseVideoUlr = (play_view as CoursePlayItemViewVideo).videoUrl // YDLMusicHelper.courseVideoUlr = (play_view as CoursePlayItemViewVideo).videoUrl
// YDLMusicHelper.course_id = courPlayBean?.courseExtra?.id!!.toInt() // YDLMusicHelper.course_id = courPlayBean?.courseExtra?.id!!.toInt()
VideoFloatHelper.setVideoInfo( VideoFloatHelper.setVideoInfo(
course_id.toString(), course_id.toString(),
(play_view as CoursePlayItemViewVideo).videoUrl!!, (play_view as CoursePlayItemViewVideo).videoUrl!!,
true true
) )
VideoFloatHelper.defaultShowPattern = ShowPattern.FOREGROUND
checkPermission() checkPermission()
} }
} }
} }
......
package com.yidianling.course.lifeCallback
import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayTypeEnum
import com.ydl.media.view.PlayerFloatHelper
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/11/19
*/
class CoursePlayLifecycle : Application.ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity?) {
}
override fun onActivityResumed(activity: Activity?) {
if (!PlayerFloatHelper.isCanClick) {
PlayerFloatHelper.hide()
PlayerFloatHelper.removeView(activity!!)
AudioPlayer.get().stopPlayer()
} else {
PlayerFloatHelper.showIfPlaying(activity!!)
PlayerFloatHelper.playingType = PlayTypeEnum.PLAY_TYPE_COURSE
}
}
override fun onActivityStarted(activity: Activity?) {
}
override fun onActivityDestroyed(activity: Activity?) {
}
override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {
}
override fun onActivityStopped(activity: Activity?) {
}
override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {
}
}
\ No newline at end of file
...@@ -12,6 +12,7 @@ import com.dou361.ijkplayer.widget.PlayerView ...@@ -12,6 +12,7 @@ import com.dou361.ijkplayer.widget.PlayerView
import com.lzf.easyfloat.EasyFloat import com.lzf.easyfloat.EasyFloat
import com.lzf.easyfloat.enums.ShowPattern import com.lzf.easyfloat.enums.ShowPattern
import com.lzf.easyfloat.interfaces.OnInvokeView import com.lzf.easyfloat.interfaces.OnInvokeView
import com.ydl.media.audio.utils.PlayProgressUtil
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.R import com.yidianling.course.R
...@@ -90,7 +91,7 @@ object VideoFloatHelper { ...@@ -90,7 +91,7 @@ object VideoFloatHelper {
private fun initVideoPlayer(activity: Activity, view: View) { private fun initVideoPlayer(activity: Activity, view: View) {
val url = courseVideoUrl.replace("https", "http") val url = courseVideoUrl.replace("https", "http")
val hisTime = VideoProgressUtil.getProgress(activity, url) val hisTime = PlayProgressUtil.getProgress(activity, url)
videoView = PlayerView(activity, view) videoView = PlayerView(activity, view)
.setScaleType(PlayStateParams.fitparent) .setScaleType(PlayStateParams.fitparent)
.hideAllUI() .hideAllUI()
...@@ -100,7 +101,7 @@ object VideoFloatHelper { ...@@ -100,7 +101,7 @@ object VideoFloatHelper {
.setOnInfoListener { _, what, _ -> .setOnInfoListener { _, what, _ ->
if (what == PlayStateParams.STATE_COMPLETED) { if (what == PlayStateParams.STATE_COMPLETED) {
isCurrentVideoPlaying = false isCurrentVideoPlaying = false
VideoProgressUtil.saveProgress(activity, url, 0) PlayProgressUtil.saveProgress(activity, url, 0)
} else { } else {
isCurrentVideoPlaying = true isCurrentVideoPlaying = true
} }
...@@ -130,7 +131,7 @@ object VideoFloatHelper { ...@@ -130,7 +131,7 @@ object VideoFloatHelper {
if (isCurrentVideoPlaying) { if (isCurrentVideoPlaying) {
var time = videoView?.currentPosition ?: 0 var time = videoView?.currentPosition ?: 0
if (time < 3000) return if (time < 3000) return
VideoProgressUtil.saveProgress(activity, url, time) PlayProgressUtil.saveProgress(activity, url, time)
} }
} }
}, 1000, 1000) }, 1000, 1000)
......
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