mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 01:29:02 +03:00
we are getting there
This commit is contained in:
parent
5e1fb417c9
commit
ddd0cfd226
5 changed files with 81 additions and 21 deletions
|
@ -106,6 +106,16 @@ android {
|
|||
"META-INF/*.kotlin_module",
|
||||
"META-INF/*.version",
|
||||
))
|
||||
|
||||
jniLibs.pickFirsts.addAll(listOf(
|
||||
"**/libavcodec.so",
|
||||
"**/libavdevice.so",
|
||||
"**/libavfilter.so",
|
||||
"**/libavformat.so",
|
||||
"**/libavutil.so",
|
||||
"**/libswresample.so",
|
||||
"**/libswscale.so",
|
||||
))
|
||||
}
|
||||
|
||||
dependenciesInfo {
|
||||
|
@ -299,10 +309,10 @@ dependencies {
|
|||
implementation("com.github.vkay94:DoubleTapPlayerView:1.0.2")
|
||||
|
||||
// FFmpeg
|
||||
// implementation("com.arthenica:ffmpeg-kit-https:4.5.LTS")
|
||||
implementation("com.arthenica:ffmpeg-kit-https:4.5.LTS")
|
||||
|
||||
// mpv-android
|
||||
implementation("com.github.jmir1:mpv-android:v0.1")
|
||||
implementation("com.github.jmir1:aniyomi-mpv-lib:0.1")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
|
|
@ -6,12 +6,12 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import android.webkit.MimeTypeMap
|
||||
import android.widget.Toast
|
||||
// import com.arthenica.ffmpegkit.ExecuteCallback
|
||||
// import com.arthenica.ffmpegkit.FFmpegKitConfig
|
||||
// import com.arthenica.ffmpegkit.FFmpegSession
|
||||
// import com.arthenica.ffmpegkit.LogCallback
|
||||
// import com.arthenica.ffmpegkit.SessionState
|
||||
// import com.arthenica.ffmpegkit.StatisticsCallback
|
||||
import com.arthenica.ffmpegkit.ExecuteCallback
|
||||
import com.arthenica.ffmpegkit.FFmpegKitConfig
|
||||
import com.arthenica.ffmpegkit.FFmpegSession
|
||||
import com.arthenica.ffmpegkit.LogCallback
|
||||
import com.arthenica.ffmpegkit.SessionState
|
||||
import com.arthenica.ffmpegkit.StatisticsCallback
|
||||
import com.hippo.unifile.UniFile
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import com.jakewharton.rxrelay.PublishRelay
|
||||
|
@ -38,7 +38,7 @@ import eu.kanade.tachiyomi.util.system.logcat
|
|||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.async
|
||||
import logcat.LogPriority
|
||||
// import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
|
@ -254,10 +254,10 @@ class AnimeDownloader(
|
|||
runningRelay.call(false)
|
||||
|
||||
isFFmpegRunning = false
|
||||
/*FFmpegKitConfig.getSessions().forEach {
|
||||
FFmpegKitConfig.getSessions().forEach {
|
||||
it.executeCallback.apply(it)
|
||||
it.cancel()
|
||||
}*/
|
||||
}
|
||||
|
||||
subscriptions.clear()
|
||||
}
|
||||
|
@ -480,10 +480,10 @@ class AnimeDownloader(
|
|||
}
|
||||
|
||||
private fun isHls(video: Video): Boolean {
|
||||
return false // video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".m3u8") ?: false
|
||||
return video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".m3u8") ?: false
|
||||
}
|
||||
|
||||
/*private fun hlsObservable(video: Video, source: AnimeHttpSource, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
private fun hlsObservable(video: Video, source: AnimeHttpSource, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
isFFmpegRunning = true
|
||||
val headers = video.headers ?: source.headers
|
||||
val headerOptions = headers.joinToString("-headers ", "-headers ", " ") { "\"${it.first}: ${it.second}\"" }
|
||||
|
@ -513,7 +513,7 @@ class AnimeDownloader(
|
|||
.map {
|
||||
tmpDir.findFile("$filename.mp4") ?: throw Exception("Downloaded file not found")
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed duration in milliseconds
|
||||
|
@ -533,7 +533,7 @@ class AnimeDownloader(
|
|||
}
|
||||
|
||||
private fun newObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
return if (isHls(video)) Observable.just(tmpDir) // hlsObservable(video, download.source, tmpDir, filename)
|
||||
return if (isHls(video)) hlsObservable(video, download.source, tmpDir, filename)
|
||||
else download.source.fetchVideo(video)
|
||||
.map { response ->
|
||||
val file = tmpDir.findFile("$filename.tmp") ?: tmpDir.createFile("$filename.tmp")
|
||||
|
|
|
@ -925,7 +925,7 @@ class MPVActivity : BaseRxActivity<MpvActivityBinding, MPVPresenter>(), MPVLib.E
|
|||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun playPause(view: View) = player.cyclePause()
|
||||
fun playPauser(view: View) = player.cyclePause()
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun playlistPrev(view: View) = MPVLib.command(arrayOf("playlist-prev"))
|
||||
|
@ -1787,7 +1787,7 @@ class MPVActivity : BaseRxActivity<MpvActivityBinding, MPVPresenter>(), MPVLib.E
|
|||
|
||||
fun setVideoList(videos: List<Video>) {
|
||||
logcat(LogPriority.INFO) { "loaded!!" }
|
||||
videos.first().videoUrl?.let { player.playFile(it) }
|
||||
videos.first().videoUrl?.let { MPVLib.command(arrayOf("loadfile", it)) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
|||
import android.content.res.ColorStateList
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.SeekBar
|
||||
|
@ -133,6 +132,50 @@ class NewPlayerActivity : BaseRxActivity<NewPlayerActivityBinding, NewPlayerPres
|
|||
binding.cycleSpeedBtn.text = getString(R.string.ui_speed, player.playbackSpeed)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun playPause(view: View) = player.cyclePause()
|
||||
|
||||
data class TrackData(val track_id: Int, val track_type: String)
|
||||
private fun trackSwitchNotification(f: () -> TrackData) {
|
||||
val (track_id, track_type) = f()
|
||||
val trackPrefix = when (track_type) {
|
||||
"audio" -> getString(R.string.track_audio)
|
||||
"sub" -> getString(R.string.track_subs)
|
||||
"video" -> "Video"
|
||||
else -> "???"
|
||||
}
|
||||
|
||||
if (track_id == -1) {
|
||||
toast("$trackPrefix ${getString(R.string.track_off)}")
|
||||
return
|
||||
}
|
||||
|
||||
val trackName = player.tracks[track_type]?.firstOrNull { it.mpvId == track_id }?.name ?: "???"
|
||||
toast("$trackPrefix $trackName")
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun cycleAudio(view: View) = trackSwitchNotification {
|
||||
player.cycleAudio(); TrackData(player.aid, "audio")
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun cycleSub(view: View) = trackSwitchNotification {
|
||||
player.cycleSub(); TrackData(player.sid, "sub")
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun switchDecoder(view: View) {
|
||||
player.cycleHwdec()
|
||||
updateDecoderButton()
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun cycleSpeed(view: View) {
|
||||
player.cycleSpeed()
|
||||
updateSpeedButton()
|
||||
}
|
||||
|
||||
private fun refreshUi() {
|
||||
// forces update of entire UI, used when resuming the activity
|
||||
val paused = player.paused ?: return
|
||||
|
@ -193,7 +236,7 @@ class NewPlayerActivity : BaseRxActivity<NewPlayerActivityBinding, NewPlayerPres
|
|||
currentVideoList = videos
|
||||
currentVideoList?.first()?.videoUrl.let {
|
||||
MPVLib.command(arrayOf("loadfile", it))
|
||||
presenter.currentEpisode?.last_second_seen?.let { pos -> player.timePos = (pos / 1000L).toInt() }
|
||||
// presenter.currentEpisode?.last_second_seen?.let { pos -> player.timePos = (pos / 1000L).toInt() }
|
||||
}
|
||||
refreshUi()
|
||||
}
|
||||
|
@ -221,9 +264,17 @@ class NewPlayerActivity : BaseRxActivity<NewPlayerActivityBinding, NewPlayerPres
|
|||
}
|
||||
}
|
||||
|
||||
private fun eventPropertyUi(property: String, value: Boolean) {
|
||||
when (property) {
|
||||
"pause" -> updatePlaybackStatus(value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun eventProperty(property: String) {}
|
||||
|
||||
override fun eventProperty(property: String, value: Boolean) {}
|
||||
override fun eventProperty(property: String, value: Boolean) {
|
||||
runOnUiThread { eventPropertyUi(property, value) }
|
||||
}
|
||||
|
||||
override fun eventProperty(property: String, value: Long) {
|
||||
runOnUiThread { eventPropertyUi(property, value) }
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:onClick="playlistPrev"
|
||||
android:src="@drawable/ic_skip_previous_black_24dp"
|
||||
app:tint="@color/tint_normal" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue