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
f54aa0a0
Commit
f54aa0a0
authored
May 24, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace textureView with video view
parent
790e7057
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
24 deletions
+115
-24
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+3
-0
HomeMuseView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
+111
-22
home_muse_view.xml
m-home/src/ydl/res/layout/home_muse_view.xml
+1
-2
No files found.
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
f54aa0a0
...
...
@@ -99,6 +99,9 @@ class MeditationTypeAdapter(
//防止连击
return
@setOnClickListener
}
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
))
{
return
@setOnClickListener
}
val
moreLink
=
"${moreLink}mark=$mark&cateId=$cateId"
if
(!
moreLink
.
isNullOrBlank
())
{
NewH5Activity
.
start
(
context
,
H5Params
(
moreLink
,
null
))
...
...
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
View file @
f54aa0a0
...
...
@@ -3,11 +3,15 @@ package com.yidianling.home.ui.view
import
android.annotation.SuppressLint
import
android.content.Context
import
android.graphics.Color
import
android.graphics.SurfaceTexture
import
android.graphics.Typeface
import
android.media.MediaPlayer
import
android.os.Handler
import
android.text.SpannableString
import
android.text.Spanned
import
android.text.style.StyleSpan
import
android.view.Surface
import
android.view.TextureView
import
android.view.View
import
android.view.ViewGroup
import
android.widget.LinearLayout
...
...
@@ -27,6 +31,7 @@ import com.yidianling.home.event.IHomeEvent
import
com.yidianling.home.model.bean.MeditationModuleBean
import
com.yidianling.user.api.service.IUserService
import
kotlinx.android.synthetic.ydl.home_muse_view.view.*
import
java.util.concurrent.Executors
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
...
...
@@ -38,6 +43,11 @@ import kotlinx.android.synthetic.ydl.home_muse_view.view.*
class
HomeMuseView
(
private
val
mContext
:
Context
,
private
var
homeEvent
:
IHomeEvent
?)
:
LinearLayout
(
mContext
)
{
private
var
mSurface
:
Surface
?
=
null
private
var
mSurfaceTexture
:
SurfaceTexture
?
=
null
private
var
mMediaPlayer
:
MediaPlayer
?
=
null
private
val
meditationTitles
=
mutableListOf
<
String
>()
init
{
...
...
@@ -84,11 +94,11 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
if
(
bean
.
mditationIndexInfo
?.
desc
.
isNullOrBlank
()){
"无常的日子里,呼吸间拾起力量"
}
else
{
bean
?
.
mditationIndexInfo
?.
desc
bean
.
mditationIndexInfo
?.
desc
}
tv_meditation_slogan
.
text
=
slogan
val
videoUrl
=
bean
?
.
mditationIndexInfo
?.
videoLink
val
videoUrl
=
bean
.
mditationIndexInfo
?.
videoLink
if
(
videoUrl
.
isNullOrBlank
()){
Glide
.
with
(
this
)
...
...
@@ -99,31 +109,68 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
.
load
(
bean
.
mditationIndexInfo
?.
mditationIndexUrl
)
.
into
(
iv_video_background
)
video_view
?.
setVideoPath
(
videoUrl
)
video_view
?.
surfaceTextureListener
=
object
:
TextureView
.
SurfaceTextureListener
{
override
fun
onSurfaceTextureAvailable
(
surfaceTexture
:
SurfaceTexture
?,
width
:
Int
,
height
:
Int
)
{
mSurface
=
Surface
(
surfaceTexture
)
runnable
.
setParams
(
videoUrl
,
bean
.
mditationIndexInfo
?.
mditationIndexUrl
?:
""
)
Executors
.
newSingleThreadExecutor
().
execute
(
runnable
)
}
override
fun
onSurfaceTextureSizeChanged
(
surface
:
SurfaceTexture
?,
width
:
Int
,
height
:
Int
)
{
}
override
fun
onSurfaceTextureDestroyed
(
surface
:
SurfaceTexture
?):
Boolean
{
// mSurface = null
// mSurfaceTexture = null
try
{
mMediaPlayer
?.
stop
()
mMediaPlayer
?.
release
()
}
catch
(
e
:
Exception
){
video_view
?.
setOnErrorListener
{
mp
,
what
,
extra
->
Glide
.
with
(
this
)
.
load
(
bean
.
mditationIndexInfo
?.
mditationIndexUrl
)
.
into
(
iv_video_background
)
true
}
video_view
?.
setOnPreparedListener
{
it
?.
setVideoScalingMode
(
MediaPlayer
.
VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
)
video_view
?.
setOnInfoListener
{
mp
,
what
,
extra
->
if
(
what
==
MediaPlayer
.
MEDIA_INFO_VIDEO_RENDERING_START
){
iv_video_background
.
visibility
=
View
.
GONE
video_view
.
setBackgroundColor
(
Color
.
TRANSPARENT
)
}
true
return
true
}
override
fun
onSurfaceTextureUpdated
(
surface
:
SurfaceTexture
?)
{
}
it
?.
start
()
it
?.
setVolume
(
0.0F
,
0.0F
)
}
video_view
?.
setOnCompletionListener
{
video_view
?.
start
()
}
// video_view?.setVideoPath(videoUrl)
// video_view?.setOnErrorListener { mp, what, extra ->
// Glide.with(this)
// .load(bean.mditationIndexInfo?.mditationIndexUrl)
// .into(iv_video_background)
// true
// }
// video_view?.setOnPreparedListener {
// it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
// video_view?.setOnInfoListener { mp, what, extra ->
// if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START){
// iv_video_background.visibility = View.GONE
// video_view.setBackgroundColor(Color.TRANSPARENT)
// }
// true
// }
// it?.start()
// it?.setVolume(0.0F,0.0F)
// }
// video_view?.setOnCompletionListener { video_view?.start() }
}
bean
?
.
mditationListResponse
?.
forEach
{
bean
.
mditationListResponse
?.
forEach
{
meditationTitles
.
add
(
it
.
comment
)
}
...
...
@@ -131,7 +178,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
tab_layout
.
addOnTabSelectedListener
(
object
:
TabLayout
.
OnTabSelectedListener
{
override
fun
onTabSelected
(
tab
:
TabLayout
.
Tab
?)
{
var
text
:
String
?
=
tab
?.
text
.
toString
().
trim
()
?:
return
var
text
:
String
?
=
tab
?.
text
.
toString
().
trim
()
val
spStr
=
SpannableString
(
text
)
val
styleSpan
=
StyleSpan
(
Typeface
.
BOLD
)
spStr
.
setSpan
(
styleSpan
,
0
,
text
?.
length
?:
0
,
Spanned
.
SPAN_INCLUSIVE_EXCLUSIVE
)
...
...
@@ -139,7 +186,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
}
override
fun
onTabUnselected
(
tab
:
TabLayout
.
Tab
?)
{
var
text
:
String
?
=
tab
?.
text
.
toString
().
trim
()
?:
return
var
text
:
String
?
=
tab
?.
text
.
toString
().
trim
()
val
spStr
=
SpannableString
(
text
)
val
styleSpan
=
StyleSpan
(
Typeface
.
NORMAL
)
spStr
.
setSpan
(
styleSpan
,
0
,
text
?.
length
?:
0
,
Spanned
.
SPAN_INCLUSIVE_EXCLUSIVE
)
...
...
@@ -160,4 +207,45 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
}
}
private
var
runnable
=
object
:
RunnableWithParams
{
var
videoUrl
:
String
?
=
null
var
imageUrl
:
String
?
=
null
override
fun
setParams
(
videoUrl
:
String
,
imageUrl
:
String
)
{
this
.
videoUrl
=
videoUrl
this
.
imageUrl
=
imageUrl
}
override
fun
run
()
{
mMediaPlayer
=
MediaPlayer
()
mMediaPlayer
?.
setDataSource
(
videoUrl
)
mMediaPlayer
?.
setSurface
(
mSurface
)
mMediaPlayer
?.
prepareAsync
()
mMediaPlayer
?.
setVolume
(
0F
,
0F
)
mMediaPlayer
?.
setOnPreparedListener
{
iv_video_background
.
visibility
=
GONE
mMediaPlayer
?.
start
()
}
mMediaPlayer
?.
setOnErrorListener
{
mp
,
what
,
extra
->
Glide
.
with
(
this
@HomeMuseView
)
.
load
(
videoUrl
)
.
into
(
iv_video_background
)
true
}
mMediaPlayer
?.
setOnCompletionListener
{
mMediaPlayer
?.
start
()
}
}
}
interface
RunnableWithParams
:
Runnable
{
fun
setParams
(
videoUrl
:
String
,
imageUrl
:
String
){
}
}
}
\ No newline at end of file
m-home/src/ydl/res/layout/home_muse_view.xml
View file @
f54aa0a0
...
...
@@ -23,8 +23,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.yidianling.home.widget.AdaptiveVideoView
<TextureView
android:id=
"@+id/video_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
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