Commit 91a4261a by 王佳洋

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

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