Skip to content

Commit

Permalink
merge from kitkat
Browse files Browse the repository at this point in the history
  • Loading branch information
vrichv committed Jul 25, 2024
1 parent 06a05cf commit 950131c
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body:
id: checklist
attributes:
label: 检查清单
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者@lizhongying求助
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者求助
options:
- label: 明白上述声明
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body:
id: checklist
attributes:
label: 检查清单
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者@lizhongying求助
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者求助
options:
- label: 明白上述声明
required: true
Expand Down
7 changes: 5 additions & 2 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## 更新日志

### v1.2.8-kk
### v1.2.8-ijk

* support android kitkat
* Use ijkplayer to get better playback effect on low-end devices. Please test it yourself and decide which version to use based on the effect. Thanks @caixxxin .
* Support android kitkat
* Improve https access module compatibility with android 4.4
* Fixed a weird bug on Sharp TV: after the TV is started, this APP will start twice and stop playing after the second start.

### v1.2.8

Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ dependencies {
implementation(libs.recyclerview)

implementation(files("libs/ijkplayer-armv7a-release.aar","libs/ijkplayer-java-release.aar"))

implementation(libs.conscrypt)
implementation(libs.okhttp.logging)
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="landscape">
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
78 changes: 46 additions & 32 deletions app/src/main/java/com/lizongying/mytv0/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lizongying.mytv0

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -13,60 +14,71 @@ import com.lizongying.mytv0.models.TVModel

class ChannelFragment : Fragment() {
private var _binding: ChannelBinding? = null
private val binding get() = _binding!!
private val binding get() = _binding

private val handler = Handler()
private val handler = Handler(Looper.getMainLooper())
private val delay: Long = 3000
private var channel = 0

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
): View? {
_binding = ChannelBinding.inflate(inflater, container, false)
_binding!!.root.visibility = View.GONE
return _binding?.root?.apply {
visibility = View.GONE
}
}

val application = requireActivity().applicationContext as MyTVApplication
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupUI()
}

binding.channel.layoutParams.width = application.px2Px(binding.channel.layoutParams.width)
binding.channel.layoutParams.height = application.px2Px(binding.channel.layoutParams.height)
private fun setupUI() {
binding?.let { binding ->
val application = requireActivity().applicationContext as MyTVApplication

val layoutParams = binding.channel.layoutParams as ViewGroup.MarginLayoutParams
layoutParams.topMargin = application.px2Px(binding.channel.marginTop)
layoutParams.marginEnd = application.px2Px(binding.channel.marginEnd)
binding.channel.layoutParams = layoutParams
binding.channel.layoutParams.width = application.px2Px(binding.channel.layoutParams.width)
binding.channel.layoutParams.height = application.px2Px(binding.channel.layoutParams.height)

binding.content.textSize = application.px2PxFont(binding.content.textSize)
binding.time.textSize = application.px2PxFont(binding.time.textSize)
val layoutParams = binding.channel.layoutParams as ViewGroup.MarginLayoutParams
layoutParams.topMargin = application.px2Px(binding.channel.marginTop)
layoutParams.marginEnd = application.px2Px(binding.channel.marginEnd)
binding.channel.layoutParams = layoutParams

binding.main.layoutParams.width = application.shouldWidthPx()
binding.main.layoutParams.height = application.shouldHeightPx()
binding.content.textSize = application.px2PxFont(binding.content.textSize)
binding.time.textSize = application.px2PxFont(binding.time.textSize)

return binding.root
binding.main.layoutParams.width = application.shouldWidthPx()
binding.main.layoutParams.height = application.shouldHeightPx()
}
}

fun show(tvViewModel: TVModel) {
handler.removeCallbacks(hideRunnable)
handler.removeCallbacks(playRunnable)
binding.content.text = (tvViewModel.tv.id.plus(1)).toString()
binding?.content?.text = (tvViewModel.tv.id.plus(1)).toString()
view?.visibility = View.VISIBLE
handler.postDelayed(hideRunnable, delay)
}

fun show(channel: String) {
if (binding.content.text.length > 1) {
return
}
this.channel = "${binding.content.text}$channel".toInt()
handler.removeCallbacks(hideRunnable)
handler.removeCallbacks(playRunnable)
if (binding.content.text == "") {
binding.content.text = channel
view?.visibility = View.VISIBLE
handler.postDelayed(playRunnable, delay)
} else {
binding.content.text = "${binding.content.text}$channel"
handler.postDelayed(playRunnable, 0)
binding?.let { binding ->
if (binding.content.text.length > 1) {
return
}
this.channel = "${binding.content.text}$channel".toInt()
handler.removeCallbacks(hideRunnable)
handler.removeCallbacks(playRunnable)
if (binding.content.text.isEmpty()) {
binding.content.text = channel
view?.visibility = View.VISIBLE
handler.postDelayed(playRunnable, delay)
} else {
binding.content.text = "${binding.content.text}$channel"
handler.postDelayed(playRunnable, 0)
}
}
}

Expand All @@ -84,17 +96,19 @@ class ChannelFragment : Fragment() {
}

private val hideRunnable = Runnable {
binding.content.text = ""
binding?.content?.text = ""
view?.visibility = View.GONE
}

private val playRunnable = Runnable {
(activity as MainActivity).play(channel - 1)
(activity as? MainActivity)?.play(channel - 1)
handler.postDelayed(hideRunnable, delay)
}

override fun onDestroyView() {
super.onDestroyView()
handler.removeCallbacks(hideRunnable)
handler.removeCallbacks(playRunnable)
_binding = null
}

Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/lizongying/mytv0/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ class MainActivity : FragmentActivity() {

private val hideSetting = Runnable {
if (!settingFragment.isHidden) {
supportFragmentManager.beginTransaction().hide(settingFragment).commitNow()
if (!supportFragmentManager.isDestroyed) {
supportFragmentManager.beginTransaction().hide(settingFragment).commitNow()
} else {
Log.e(TAG, "SupportFragmentManager is destroyed!")
}
showTime()
}
}
Expand Down
19 changes: 5 additions & 14 deletions app/src/main/java/com/lizongying/mytv0/PlayerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,14 @@ import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.annotation.OptIn
import androidx.fragment.app.Fragment
import androidx.media3.common.MimeTypes
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.Player.DISCONTINUITY_REASON_AUTO_TRANSITION
import androidx.media3.common.Player.REPEAT_MODE_ALL
import androidx.media3.common.VideoSize
import androidx.media3.common.util.UnstableApi
import androidx.media3.datasource.DataSource
import androidx.media3.datasource.DataSpec
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.datasource.TransferListener
import androidx.media3.exoplayer.DefaultRenderersFactory
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil
import com.lizongying.mytv0.databinding.PlayerBinding
import com.lizongying.mytv0.models.SourceType
import com.lizongying.mytv0.models.TVModel
import tv.danmaku.ijk.media.player.IjkMediaPlayer

class PlayerFragment : Fragment(), SurfaceHolder.Callback {
private var _binding: PlayerBinding? = null
Expand Down Expand Up @@ -113,6 +99,11 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback {
override fun onStart() {
Log.i(TAG, "onStart")
super.onStart()
}

override fun onResume() {
Log.i(TAG, "play-onResume")
super.onResume()
if (ijkUtil?.isPlaying == false) {
Log.i(TAG, "replay")
ijkUtil?.start()
Expand Down
Loading

0 comments on commit 950131c

Please sign in to comment.