V1.0.3(4)处理崩溃问题
This commit is contained in:
parent
7ee19d8635
commit
164dbd9495
@ -24,8 +24,8 @@ android {
|
||||
applicationId = "com.various.funny.sounds.audio"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 3
|
||||
versionName = "1.0.2"
|
||||
versionCode = 4
|
||||
versionName = "1.0.3"
|
||||
setProperty("archivesBaseName", "Various Funny Sounds_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.audio.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.various.funny.sounds.audio.ui.activity
|
||||
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
@ -20,6 +21,8 @@ import com.various.funny.sounds.audio.max.MaxManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
||||
|
||||
@ -67,6 +70,7 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
||||
when (v) {
|
||||
playBinding.imPlay -> {
|
||||
showAd()
|
||||
|
||||
}
|
||||
|
||||
playBinding.iconBack -> {
|
||||
@ -99,9 +103,22 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
||||
mediaPlayer = MediaPlayer()
|
||||
mediaPlayer?.isLooping = true
|
||||
newBeanChild.downloadUrl?.let {
|
||||
mediaPlayer?.setDataSource(it)
|
||||
mediaPlayer?.prepare()
|
||||
isDownload = true
|
||||
val file = File(it)
|
||||
if (file.exists()) {
|
||||
mediaPlayer?.reset()
|
||||
try {
|
||||
mediaPlayer?.setDataSource(it)
|
||||
mediaPlayer?.prepare()
|
||||
isDownload = true
|
||||
} catch (ex: IOException) {
|
||||
isDownload = false
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
isDownload = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -119,6 +136,7 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
||||
} else {
|
||||
playBinding.progressbar.isVisible = false
|
||||
file.absolutePath.let { path ->
|
||||
mediaPlayer?.reset()
|
||||
mediaPlayer?.setDataSource(path)
|
||||
mediaPlayer?.prepare()
|
||||
isDownload = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user