Commit 91a4261a by 王佳洋

1,音频播放功能查漏补缺

2,音视频悬浮窗代码优化
parent 69bc9942
...@@ -7,6 +7,8 @@ package com.yidianling.course.bean ...@@ -7,6 +7,8 @@ package com.yidianling.course.bean
* @Company 壹点灵 * @Company 壹点灵
* @date 2019/7/11 * @date 2019/7/11
*/ */
const val COURSE_AUDIO = 1
const val COURSE_VIDEO = 2
data class CourseMediaBean( data class CourseMediaBean(
/** /**
...@@ -19,6 +21,8 @@ data class CourseMediaBean( ...@@ -19,6 +21,8 @@ data class CourseMediaBean(
var doctorName: String, var doctorName: String,
/** /**
* 资料类型 1.音频 2.视频 , * 资料类型 1.音频 2.视频 ,
* @see COURSE_AUDIO
* @see COURSE_VIDEO
*/ */
var mediaType: Int, var mediaType: Int,
/** /**
......
...@@ -34,6 +34,7 @@ import com.yidianling.common.tools.ToastUtil ...@@ -34,6 +34,7 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.BuildConfig import com.yidianling.course.BuildConfig
import com.yidianling.course.CourseConstants import com.yidianling.course.CourseConstants
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.bean.COURSE_AUDIO
import com.yidianling.course.bean.CourseExtraBean import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.course.bean.CourseMediaBean import com.yidianling.course.bean.CourseMediaBean
import com.yidianling.course.bean.CourseMediaDetailBean import com.yidianling.course.bean.CourseMediaDetailBean
...@@ -195,7 +196,7 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon ...@@ -195,7 +196,7 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon
if (!it.isDemo && !isBuy) { if (!it.isDemo && !isBuy) {
if (AudioPlayer.get().isPlaying) AudioPlayer.get().pausePlayer() if (AudioPlayer.get().isPlaying) AudioPlayer.get().pausePlayer()
buyCourseTipDialog() buyCourseTipDialog()
} else if (it.mediaType == 1) { } else if (it.mediaType == COURSE_AUDIO) {
return true return true
} }
} }
...@@ -228,6 +229,7 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon ...@@ -228,6 +229,7 @@ class AudioPlayActivity : BaseMvpActivity<IAudioPlayContract.View, IAudioPlayCon
val hashMap = HashMap<String, String>() val hashMap = HashMap<String, String>()
hashMap["course_id"] = mCourseId.toString() hashMap["course_id"] = mCourseId.toString()
hashMap["media_type"] = COURSE_AUDIO.toString()
PlayerFloatHelper.playTempData.putAll(hashMap) PlayerFloatHelper.playTempData.putAll(hashMap)
} }
return true return true
......
...@@ -8,10 +8,12 @@ import com.alibaba.android.arouter.facade.annotation.Route ...@@ -8,10 +8,12 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.course.api.ICourseService import com.ydl.course.api.ICourseService
import com.ydl.media.audio.AudioPlayer import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper import com.ydl.media.view.PlayerFloatHelper
import com.yidianling.course.bean.COURSE_AUDIO
import com.yidianling.course.courseNew.CourseTopicActivity import com.yidianling.course.courseNew.CourseTopicActivity
import com.yidianling.course.courseNew.mine.MyCourseActivity import com.yidianling.course.courseNew.mine.MyCourseActivity
import com.yidianling.course.coursePlay.AudioPlayActivity import com.yidianling.course.coursePlay.AudioPlayActivity
import com.yidianling.course.coursePlay.CourseCommentActivity import com.yidianling.course.coursePlay.CourseCommentActivity
import com.yidianling.course.coursePlay.CoursePlayActivity
import com.yidianling.course.coursePlay.CourseReplyListActivity import com.yidianling.course.coursePlay.CourseReplyListActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.lifeCallback.CoursePlayLifecycle import com.yidianling.course.lifeCallback.CoursePlayLifecycle
...@@ -60,8 +62,11 @@ class CourseServiceImp : ICourseService { ...@@ -60,8 +62,11 @@ class CourseServiceImp : ICourseService {
} }
override fun startCoursePlayActivity(activity: Activity, courseId: Int, coursePlayUrl: String?, from: Int, mediaType: String?) { override fun startCoursePlayActivity(activity: Activity, courseId: Int, coursePlayUrl: String?, from: Int, mediaType: String?) {
// val intent = Intent(activity, CoursePlayActivity::class.java) val intent = if (COURSE_AUDIO.toString() == mediaType) {
val intent = Intent(activity, AudioPlayActivity::class.java) Intent(activity, AudioPlayActivity::class.java)
} else {
Intent(activity, CoursePlayActivity::class.java)
}
intent.putExtra("course_id", courseId) intent.putExtra("course_id", courseId)
intent.putExtra("coursePlayUrl", coursePlayUrl) intent.putExtra("coursePlayUrl", coursePlayUrl)
intent.putExtra("from", from) intent.putExtra("from", from)
......
...@@ -188,9 +188,20 @@ class PlayerFloatHelper { ...@@ -188,9 +188,20 @@ class PlayerFloatHelper {
} }
fun startCoursePlayActivity(context: Context?, from: Int, fullScreen: Int = 0, coursePlayUrl: String? = "", isFromFloatView: Boolean = false) { fun startCoursePlayActivity(context: Context?, from: Int, fullScreen: Int = 0, coursePlayUrl: String? = "", isFromFloatView: Boolean = false) {
val courseId = playTempData["course_id"]?.toInt() ?: 0
if ("1" == playTempData["media_type"]) { // 音频
ARouter.getInstance()
.build("/course/audioPlay")
.withInt("course_id", courseId)
.withString("coursePlayUrl", coursePlayUrl)
.withInt("from", from)
.withBoolean("isFromFloatView", isFromFloatView)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.navigation()
} else {
ARouter.getInstance() ARouter.getInstance()
.build("/course/play") .build("/course/play")
.withInt("course_id", playTempData["course_id"]?.toInt()?:0) .withInt("course_id", courseId)
.withInt("course_type", 0) .withInt("course_type", 0)
.withString("coursePlayUrl", coursePlayUrl) .withString("coursePlayUrl", coursePlayUrl)
.withInt("from", from) .withInt("from", from)
...@@ -199,6 +210,7 @@ class PlayerFloatHelper { ...@@ -199,6 +210,7 @@ class PlayerFloatHelper {
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.navigation() .navigation()
} }
}
fun startFMPlayActivity(context: Context?) { fun startFMPlayActivity(context: Context?) {
val bundle = Bundle() val bundle = Bundle()
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_audio_layout"
android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_marginLeft="15dp" android:layout_marginStart="15dp"
android:layout_marginRight="15dp" android:layout_marginEnd="15dp"
android:background="@drawable/play_float_background" android:background="@drawable/play_float_background">
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/play_close" android:id="@+id/play_close"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginEnd="10dp"
android:padding="15dp" android:padding="15dp"
android:src="@drawable/ico_play_float_pause" android:src="@drawable/ico_play_float_pause"
android:visibility="visible" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/play_head" android:id="@+id/play_head"
android:layout_width="36dp" android:layout_width="36dp"
android:layout_height="36dp" android:layout_height="36dp"
android:layout_marginLeft="12.5dp" android:layout_marginStart="12dp"
android:src="@drawable/ico_play_float_pic" /> android:layout_marginEnd="12dp"
android:src="@drawable/ico_play_float_pic"
<RelativeLayout app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/rl_info" app:layout_constraintEnd_toStartOf="@id/tv_title"
android:layout_width="0dp" app:layout_constraintStart_toEndOf="@id/play_close"
android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" />
android:layout_marginLeft="@dimen/platform_dp_18"
android:layout_marginRight="@dimen/platform_dp_18"
android:layout_weight="1">
<TextView <TextView
android:id="@+id/tv_title" android:id="@+id/tv_title"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="14sp" android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/tv_name"
app:layout_constraintEnd_toStartOf="@id/play_state"
app:layout_constraintStart_toEndOf="@id/play_head"
tools:text="丁sir说抑郁丁sir说抑郁:像心理学" /> tools:text="丁sir说抑郁丁sir说抑郁:像心理学" />
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/tv_title"
android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:textColor="#BFBFBF" android:textColor="#BFBFBF"
android:textSize="10sp" android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/tv_title"
app:layout_constraintStart_toStartOf="@id/tv_title"
app:layout_constraintTop_toTopOf="parent"
tools:text="丁sir" /> tools:text="丁sir" />
<TextView <TextView
android:id="@+id/tv_now_playing_time" android:id="@+id/tv_now_playing_time"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/tv_name" app:layout_constraintEnd_toEndOf="@id/tv_title"
app:layout_constraintStart_toStartOf="@id/tv_title"
android:ellipsize="end"
android:maxLines="1"
app:layout_constraintTop_toBottomOf="@id/tv_name"
android:textColor="#BFBFBF" android:textColor="#BFBFBF"
android:textSize="10sp" android:textSize="10sp"
tools:text="00:06" /> tools:text="00:06" />
<TextView
android:id="@+id/tv_line_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/tv_now_playing_time"
android:layout_toRightOf="@+id/tv_now_playing_time"
android:text=" / "
android:textColor="#BFBFBF"
android:textSize="10sp" />
<TextView
android:layout_alignBaseline="@id/tv_now_playing_time"
android:id="@+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_title"
android:layout_toRightOf="@+id/tv_line_two"
android:textColor="#BFBFBF"
android:textSize="10sp"
tools:text="30:28" />
</RelativeLayout>
<ImageView <ImageView
android:id="@+id/play_state" android:id="@+id/play_state"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center" android:layout_marginStart="15dp"
android:layout_marginLeft="8dp" android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/ico_yyfc_play" /> android:src="@drawable/ico_yyfc_play"
</LinearLayout> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tv_title"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
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