[M2] 兼容视频轮播只有一个item的情况
This commit is contained in:
@@ -51,83 +51,184 @@ class PM2VideoFragment :
|
||||
arrayListOf.clear()
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
0,
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1678946244305/dalim2.mp4",
|
||||
1,
|
||||
"",
|
||||
"1"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
0,
|
||||
"",
|
||||
"2"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
1,
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"3"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
0,
|
||||
"",
|
||||
"4"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
1,
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"5"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
1,
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"6"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
0,
|
||||
"",
|
||||
"7"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
0,
|
||||
"",
|
||||
"8"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
0,
|
||||
"",
|
||||
"9"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
1,
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"10"
|
||||
)
|
||||
)
|
||||
}
|
||||
// if (BuildConfig.FLAVOR.contains("dali")){ //大理 目前还都使用的mogo 的cos https://img.zhidaohulian.com/fileServer/online_car_hailing/1678932482045/1080%2A565%20.mp4
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1678932482045/1080%2A565%20.mp4",
|
||||
// 1,
|
||||
// "",
|
||||
// "1"
|
||||
// )
|
||||
// )
|
||||
// }else if (BuildConfig.FLAVOR.contains("yantai")){ //烟台
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "1"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
// 0,
|
||||
// "",
|
||||
// "2"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
// "3"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "4"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// "5"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// "6"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "7"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "8"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
// 0,
|
||||
// "",
|
||||
// "9"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
// "10"
|
||||
// )
|
||||
// )
|
||||
// }else{ // mogo
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "1"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
// 0,
|
||||
// "",
|
||||
// "2"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
// "3"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "4"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// "5"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
// "6"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "7"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
// 0,
|
||||
// "",
|
||||
// "8"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
// 0,
|
||||
// "",
|
||||
// "9"
|
||||
// )
|
||||
// )
|
||||
// arrayListOf.add(
|
||||
// RotationItem(
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
// 1,
|
||||
// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
// "10"
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -148,21 +148,18 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
|
||||
|
||||
override fun onPrepared(url: String?, vararg objects: Any?) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "onPrepared--$url")
|
||||
// if (viewList[mViewPager.currentItem] is AdvanceVideoView){
|
||||
// val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
|
||||
// UiThreadHandler.postDelayed(Runnable {
|
||||
// videoView.setCacheImageViewGone()
|
||||
// },1000)
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onAutoComplete(url: String?, vararg objects: Any?) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "onAutoComplete()-$url")
|
||||
if (viewList[mViewPager.currentItem] is AdvanceVideoView){
|
||||
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
|
||||
videoView.onVideoReset()
|
||||
// videoView.setCacheImageViewVisible()
|
||||
goNextItemView()
|
||||
if (viewList.size == 1){
|
||||
videoView.startPlay(url)
|
||||
}else{
|
||||
videoView.onVideoReset()
|
||||
goNextItemView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
)
|
||||
if (FileUtils.isFileExists(mVideoDirPath+downloadVideoName)){
|
||||
Logger.d(ImageAndVideoRotation.TAG, "have cache startPlay")
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString())
|
||||
return
|
||||
}
|
||||
startDownLoadVideo()
|
||||
@@ -157,13 +157,14 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
,downloadVideoName,5,downListener)
|
||||
}
|
||||
|
||||
private fun startPlay(){
|
||||
fun startPlay(localVideoPath: String?){
|
||||
if (localVideoPath === "") return
|
||||
try {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "startPlay")
|
||||
gsyVideoOptionBuilder = GSYVideoOptionBuilder()
|
||||
gsyVideoOptionBuilder
|
||||
// ?.setUrl("file:///mnt/sdcard/downloads/$downloadVideoName")
|
||||
?.setUrl(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString()) // "/data/user/0/com.mogo.launcher.f/files/video/"
|
||||
?.setUrl(localVideoPath) // "/data/user/0/com.mogo.launcher.f/files/video/"
|
||||
?.setPlayTag(downloadVideoName)
|
||||
?.setCacheWithPlay(false)
|
||||
?.setThumbPlay(false)
|
||||
@@ -217,7 +218,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
if (url.equals(fileNetPath)){ //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题
|
||||
//下载完成
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString())
|
||||
}
|
||||
}else{//如果当前文件不存在再次去下载当前的
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = not current" +
|
||||
@@ -225,7 +226,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
if (FileUtils.isFileExists(mVideoDirPath+downloadVideoName)){
|
||||
Logger.d(ImageAndVideoRotation.TAG, "have download startPlay")
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString())
|
||||
}
|
||||
return
|
||||
}else{
|
||||
|
||||
@@ -141,7 +141,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
)
|
||||
if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) {
|
||||
Logger.d(ImageVideoRotationView.TAG, "have cache startPlay")
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString())
|
||||
return
|
||||
}
|
||||
startDownLoadVideo()
|
||||
@@ -157,13 +157,13 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun startPlay() {
|
||||
fun startPlay(localVideoPath: String?) {
|
||||
try {
|
||||
Logger.d(ImageVideoRotationView.TAG, "startPlay")
|
||||
gsyVideoOptionBuilder = GSYVideoOptionBuilder()
|
||||
gsyVideoOptionBuilder
|
||||
?.setUrl(
|
||||
Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()
|
||||
localVideoPath
|
||||
) // "/data/user/0/com.mogo.launcher.f/files/video/"
|
||||
?.setPlayTag(downloadVideoName)
|
||||
?.setCacheWithPlay(false)
|
||||
@@ -218,7 +218,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
if (url.equals(fileNetPath)) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题
|
||||
//下载完成
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString())
|
||||
}
|
||||
} else {//如果当前文件不存在再次去下载当前的
|
||||
Logger.d(
|
||||
@@ -228,7 +228,7 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) {
|
||||
Logger.d(ImageVideoRotationView.TAG, "have download startPlay")
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay()
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString())
|
||||
}
|
||||
return
|
||||
} else {
|
||||
@@ -398,8 +398,12 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
|
||||
if (viewList[mViewPager.currentItem] is AdvanceVideoView) {
|
||||
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
|
||||
videoView.onVideoReset()
|
||||
// videoView.setCacheImageViewVisible()
|
||||
goNextItemView()
|
||||
if (viewList.size == 1){
|
||||
videoView.startPlay(url)
|
||||
}else{
|
||||
goNextItemView()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user