Skip to content

Commit

Permalink
Fixed some formats
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Jul 7, 2024
1 parent 3cb45ce commit 25d4e88
Show file tree
Hide file tree
Showing 18 changed files with 308 additions and 301 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 更新日志

### v1.2.8

* 修復部分視頻源無法播放的問題
* 修復一些閃退問題

### v1.2.7

* 簡單支持EPG
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ adb install my-tv-0.apk

## TODO

* 节目增加预告
* 兼容4.0
* 插件商城
* UI
* 视频解码
* 視頻解碼
* 支持回看
* 詳細EPG
* 淺色菜單

## 赞赏
## 讚賞

![image](./screenshots/appreciate.jpeg)

## 感谢
## 感謝

[live](https://github.com/fanmingming/live)
64 changes: 25 additions & 39 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import java.io.BufferedReader

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

android {
Expand Down Expand Up @@ -63,7 +63,8 @@ fun getVersionName(): String {
return try {
val process = Runtime.getRuntime().exec("git describe --tags --always")
process.waitFor()
val versionName = process.inputStream.bufferedReader().use(BufferedReader::readText).trim().removePrefix("v")
val versionName = process.inputStream.bufferedReader().use(BufferedReader::readText).trim()
.removePrefix("v")
versionName.ifEmpty {
"1.0.0"
}
Expand All @@ -74,47 +75,32 @@ fun getVersionName(): String {

dependencies {
// For AGP 7.4+
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
coreLibraryDesugaring(libs.desugar.jdk.libs)

// 19 java8
val media3Version = "1.3.1"
implementation("androidx.media3:media3-ui:$media3Version")
implementation(libs.media3.ui)
implementation(libs.media3.exoplayer)
implementation(libs.media3.exoplayer.hls)
implementation(libs.media3.exoplayer.dash)
implementation(libs.media3.exoplayer.rtsp)
implementation(libs.media3.datasource.okhttp)

// For media playback using ExoPlayer
implementation("androidx.media3:media3-exoplayer:$media3Version")
implementation(libs.nanohttpd)
implementation(libs.gua64)
implementation(libs.zxing)
implementation(libs.glide)

implementation("androidx.media3:media3-exoplayer-hls:$media3Version")
implementation("androidx.media3:media3-exoplayer-dash:$media3Version")
implementation("androidx.media3:media3-exoplayer-rtsp:$media3Version")
implementation(libs.gson)
implementation(libs.okhttp)
implementation(libs.converter.gson)
implementation(libs.retrofit)

implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.multidex:multidex:2.0.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation(libs.core.ktx)
implementation(libs.coroutines)
implementation(libs.leanback)

//java7
implementation("com.github.bumptech.glide:glide:4.16.0")

// 21:2.11.0 17:2.6.4
val retrofit2Version = "2.11.0"
implementation("com.squareup.retrofit2:converter-gson:$retrofit2Version")
implementation ("com.squareup.retrofit2:retrofit:$retrofit2Version")

// For yunos
val exoplayerVersion = "2.13.3"
implementation("com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion")
implementation("com.google.android.exoplayer:exoplayer-core:$exoplayerVersion")
implementation("com.google.android.exoplayer:exoplayer-hls:$exoplayerVersion")

implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
implementation(libs.multidex)
implementation(libs.constraintlayout)
implementation(libs.recyclerview)

implementation(files("libs/lib-decoder-ffmpeg-release.aar"))

implementation("io.github.lizongying:gua64:1.4.5")

implementation("org.nanohttpd:nanohttpd:2.3.1")

implementation("com.google.zxing:core:3.5.3")

implementation("androidx.leanback:leanback:1.0.0")
}
13 changes: 10 additions & 3 deletions app/src/main/java/com/lizongying/mytv0/ErrorFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ class ErrorFragment : Fragment() {

binding.msg.textSize = application.px2PxFont(binding.msg.textSize)

(activity as MainActivity).ready(TAG)
_binding = ErrorBinding.inflate(inflater, container, false)
return binding.root
}

fun show(msg: String) {
binding.msg.text = msg
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as MainActivity).ready(TAG)
}

fun setMsg(msg: String) {
if (_binding != null) {
binding.msg.text = msg
}
}

override fun onDestroyView() {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.graphics.Paint
import android.graphics.drawable.BitmapDrawable
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -108,7 +107,6 @@ class InfoFragment : Fragment() {
}

val epg = tvViewModel.epg.value?.filter { it.beginTime < Utils.getDateTimestamp() }
Log.i(TAG, "info epg $epg")
if (!epg.isNullOrEmpty()) {
binding.desc.text = epg.last().title
} else {
Expand Down
29 changes: 4 additions & 25 deletions app/src/main/java/com/lizongying/mytv0/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ class MainActivity : FragmentActivity() {
hideFragment(loadingFragment)
if (tvModel.errInfo.value == "") {
Log.i(TAG, "${tvModel.tv.title} 播放中")
hideErrorFragment()
hideFragment(errorFragment)
showFragment(playerFragment)
} else {
Log.i(TAG, "${tvModel.tv.title} ${tvModel.errInfo.value.toString()}")
hideFragment(playerFragment)
showErrorFragment(tvModel.errInfo.value.toString())
errorFragment.setMsg(tvModel.errInfo.value.toString())
showFragment(errorFragment)
}
}
}
Expand All @@ -193,7 +194,7 @@ class MainActivity : FragmentActivity() {
&& tvModel.tv.id == TVList.position.value
) {
Log.i(TAG, "loading ${tvModel.tv.title}")
hideErrorFragment()
hideFragment(errorFragment)
showFragment(loadingFragment)
playerFragment.play(tvModel)
infoFragment.show(tvModel)
Expand Down Expand Up @@ -509,28 +510,6 @@ class MainActivity : FragmentActivity() {
showTime()
}

private fun showErrorFragment(msg: String) {
errorFragment.show(msg)
if (!errorFragment.isHidden) {
return
}

supportFragmentManager.beginTransaction()
.show(errorFragment)
.commitNow()
}

private fun hideErrorFragment() {
errorFragment.show("hide")
if (errorFragment.isHidden) {
return
}

supportFragmentManager.beginTransaction()
.hide(errorFragment)
.commitNow()
}

fun onKey(keyCode: Int): Boolean {
Log.d(TAG, "keyCode $keyCode")
when (keyCode) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ class MenuFragment : Fragment(), GroupAdapter.ItemListener, ListAdapter.ItemList
// listAdapter.focusable(true)
// }

if (TVList.size() == 0) {
"沒有頻道".showToast()
return
}
val groupIndex = TVList.getTVModel().groupIndex
Log.i(
TAG,
Expand Down
Loading

0 comments on commit 25d4e88

Please sign in to comment.