|
|
@ -20,7 +20,9 @@ import com.frank.ffmpeg.util.FFmpegUtil |
|
|
|
import com.frank.ffmpeg.util.TimeUtil |
|
|
|
import com.frank.ffmpeg.util.TimeUtil |
|
|
|
import com.frank.ffmpeg.model.LrcLine |
|
|
|
import com.frank.ffmpeg.model.LrcLine |
|
|
|
import com.frank.ffmpeg.tool.LrcLineTool |
|
|
|
import com.frank.ffmpeg.tool.LrcLineTool |
|
|
|
|
|
|
|
import com.frank.ffmpeg.tool.LrcParser |
|
|
|
import com.frank.ffmpeg.view.LrcView |
|
|
|
import com.frank.ffmpeg.view.LrcView |
|
|
|
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
class AudioPlayActivity : AppCompatActivity() { |
|
|
|
class AudioPlayActivity : AppCompatActivity() { |
|
|
|
|
|
|
|
|
|
|
@ -147,9 +149,26 @@ class AudioPlayActivity : AppCompatActivity() { |
|
|
|
|
|
|
|
|
|
|
|
private fun initLrc() { |
|
|
|
private fun initLrc() { |
|
|
|
if (path.isNullOrEmpty()) return |
|
|
|
if (path.isNullOrEmpty()) return |
|
|
|
val ffmpegHandler = FFmpegHandler(mHandler) |
|
|
|
var lrcPath: String? = null |
|
|
|
val commandLine = FFmpegUtil.probeFormat(path) |
|
|
|
if (path!!.contains(".")) { |
|
|
|
ffmpegHandler.executeFFprobeCmd(commandLine) |
|
|
|
lrcPath = path!!.substring(0, path!!.lastIndexOf(".")) + ".lrc" |
|
|
|
|
|
|
|
Log.e(TAG, "lrcPath=$lrcPath") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!lrcPath.isNullOrEmpty() && File(lrcPath).exists()) { |
|
|
|
|
|
|
|
// should parsing in work thread |
|
|
|
|
|
|
|
val lrcParser = LrcParser() |
|
|
|
|
|
|
|
val lrcInfo = lrcParser.readLrc(lrcPath) |
|
|
|
|
|
|
|
Log.e(TAG, "title=${lrcInfo?.title},album=${lrcInfo?.album},artist=${lrcInfo?.artist}") |
|
|
|
|
|
|
|
if (lrcInfo?.lrcLineList != null) { |
|
|
|
|
|
|
|
lrcView?.setLrc(lrcInfo.lrcLineList!!) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
txtTitle?.text = lrcInfo?.title |
|
|
|
|
|
|
|
txtArtist?.text = lrcInfo?.artist |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val ffmpegHandler = FFmpegHandler(mHandler) |
|
|
|
|
|
|
|
val commandLine = FFmpegUtil.probeFormat(path) |
|
|
|
|
|
|
|
ffmpegHandler.executeFFprobeCmd(commandLine) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun isPlaying() :Boolean { |
|
|
|
private fun isPlaying() :Boolean { |
|
|
@ -159,6 +178,7 @@ class AudioPlayActivity : AppCompatActivity() { |
|
|
|
override fun onStop() { |
|
|
|
override fun onStop() { |
|
|
|
super.onStop() |
|
|
|
super.onStop() |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
mHandler.removeCallbacksAndMessages(null) |
|
|
|
audioPlayer.stop() |
|
|
|
audioPlayer.stop() |
|
|
|
audioPlayer.release() |
|
|
|
audioPlayer.release() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|