[Build] 修正M2变种编译错误
This commit is contained in:
@@ -6,18 +6,15 @@ import android.net.Uri
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.bean.ThreadBean
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.callback.IDownload
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.utils.DownloadUtils
|
||||
import com.mogo.eagle.core.utilcode.download.*
|
||||
import com.mogo.eagle.core.utilcode.download.callback.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.FileUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
||||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@@ -159,9 +156,13 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
//下载视频, 下载成功后再播放
|
||||
Logger.d(ImageAndVideoRotation.TAG, "startDownLoadVideo")
|
||||
FileUtils.createFileDir(mVideoDirPath)
|
||||
DownloadUtils.downLoad(
|
||||
context, fileNetPath, mVideoDirPath, downloadVideoName, 5, downListener
|
||||
)
|
||||
val downloadUrl = fileNetPath
|
||||
val downloadDir = mVideoDirPath
|
||||
if (downloadUrl != null && downloadDir != null) {
|
||||
DownloadUtils.downLoad(
|
||||
context, downloadUrl, downloadDir, downloadVideoName, downListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun startPlay(localVideoPath: String?) {
|
||||
@@ -202,40 +203,40 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private val downListener = object : IDownload {
|
||||
override fun onStart(url: String?) {
|
||||
private val downListener = object : IDownloadListener {
|
||||
override fun onStart(url: String) {
|
||||
setCacheImageViewVisible()
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onStart")
|
||||
}
|
||||
|
||||
override fun onPause(url: String?, threadBean: ThreadBean?) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onPause")
|
||||
// UiThreadHandler.postDelayed(Runnable {
|
||||
// startDownLoadVideo()
|
||||
// },DOWNLOAD_DELAY)
|
||||
// todo 测试下网络断掉是否会走onpause,且网络回复也不会继续下载
|
||||
// override fun onPause(url: String, threadBean: ThreadBean?) {
|
||||
// Logger.d(ImageAndVideoRotation.TAG, "download-onPause")
|
||||
//// UiThreadHandler.postDelayed(Runnable {
|
||||
//// startDownLoadVideo()
|
||||
//// },DOWNLOAD_DELAY)
|
||||
// // todo 测试下网络断掉是否会走onpause,且网络回复也不会继续下载
|
||||
// }
|
||||
|
||||
override fun onProgress(url: String, downloaded: Long, total: Long) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onProgress== ${ (downloaded * 1.0f * 100/total).toInt() }")
|
||||
}
|
||||
|
||||
override fun onProgress(url: String?, length: Int) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onProgress== $length")
|
||||
}
|
||||
|
||||
override fun onFinished(url: String?, threadBean: ThreadBean?, localPath: String?) {
|
||||
override fun onFinished(url: String, path: String) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = $url")
|
||||
if (url.equals(fileNetPath)) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题
|
||||
//下载完成
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString())
|
||||
startPlay(Uri.fromFile(File(path)).toString())
|
||||
}
|
||||
} else {//如果当前文件不存在再次去下载当前的
|
||||
Logger.d(
|
||||
ImageAndVideoRotation.TAG, "download-onFinished = not current" +
|
||||
",currentUrl = $fileNetPath "
|
||||
)
|
||||
if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) {
|
||||
if (FileUtils.isFileExists(path)) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "have download startPlay")
|
||||
ThreadUtils.runOnUiThread {
|
||||
startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString())
|
||||
startPlay(Uri.fromFile(File(path)).toString())
|
||||
}
|
||||
return
|
||||
} else {
|
||||
@@ -244,14 +245,10 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(url: String?, errorMsg: String?) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onError-$errorMsg")
|
||||
override fun onError(url: String, error: String?) {
|
||||
Logger.d(ImageAndVideoRotation.TAG, "download-onError-$error")
|
||||
//出错再次下载
|
||||
if (errorMsg != null) {
|
||||
if (errorMsg.startsWith("initFailed")) {
|
||||
startDownLoadVideo()
|
||||
}
|
||||
}
|
||||
startDownLoadVideo()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user