Skip to content

Commit 950131c

Browse files
committed
merge from kitkat
1 parent 06a05cf commit 950131c

File tree

17 files changed

+320
-389
lines changed

17 files changed

+320
-389
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body:
77
id: checklist
88
attributes:
99
label: 检查清单
10-
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者@lizhongying求助
10+
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者求助
1111
options:
1212
- label: 明白上述声明
1313
required: true

.github/ISSUE_TEMPLATE/fr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body:
77
id: checklist
88
attributes:
99
label: 检查清单
10-
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者@lizhongying求助
10+
description: 声明:本项目仅为自用修改,仅在android4.4的夏普电视测试,作者没有任何义务为任何人解决问题或添加功能,如果你遇到了问题,建议 1)自行修改源代码解决; 2)使用AI如claude.ai协助解决; 3)向本项目原作者求助
1111
options:
1212
- label: 明白上述声明
1313
required: true

HISTORY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
## 更新日志
22

3-
### v1.2.8-kk
3+
### v1.2.8-ijk
44

5-
* support android kitkat
5+
* 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 .
6+
* Support android kitkat
7+
* Improve https access module compatibility with android 4.4
8+
* Fixed a weird bug on Sharp TV: after the TV is started, this APP will start twice and stop playing after the second start.
69

710
### v1.2.8
811

app/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,7 @@ dependencies {
103103
implementation(libs.recyclerview)
104104

105105
implementation(files("libs/ijkplayer-armv7a-release.aar","libs/ijkplayer-java-release.aar"))
106+
107+
implementation(libs.conscrypt)
108+
implementation(libs.okhttp.logging)
106109
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<activity
1717
android:name=".MainActivity"
1818
android:exported="true"
19-
android:screenOrientation="landscape">
19+
android:screenOrientation="landscape"
20+
android:launchMode="singleTask">
2021
<intent-filter>
2122
<action android:name="android.intent.action.MAIN" />
2223

app/src/main/java/com/lizongying/mytv0/ChannelFragment.kt

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.lizongying.mytv0
22

33
import android.os.Bundle
44
import android.os.Handler
5+
import android.os.Looper
56
import android.view.LayoutInflater
67
import android.view.View
78
import android.view.ViewGroup
@@ -13,60 +14,71 @@ import com.lizongying.mytv0.models.TVModel
1314

1415
class ChannelFragment : Fragment() {
1516
private var _binding: ChannelBinding? = null
16-
private val binding get() = _binding!!
17+
private val binding get() = _binding
1718

18-
private val handler = Handler()
19+
private val handler = Handler(Looper.getMainLooper())
1920
private val delay: Long = 3000
2021
private var channel = 0
2122

2223
override fun onCreateView(
2324
inflater: LayoutInflater, container: ViewGroup?,
2425
savedInstanceState: Bundle?
25-
): View {
26+
): View? {
2627
_binding = ChannelBinding.inflate(inflater, container, false)
27-
_binding!!.root.visibility = View.GONE
28+
return _binding?.root?.apply {
29+
visibility = View.GONE
30+
}
31+
}
2832

29-
val application = requireActivity().applicationContext as MyTVApplication
33+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
34+
super.onViewCreated(view, savedInstanceState)
35+
setupUI()
36+
}
3037

31-
binding.channel.layoutParams.width = application.px2Px(binding.channel.layoutParams.width)
32-
binding.channel.layoutParams.height = application.px2Px(binding.channel.layoutParams.height)
38+
private fun setupUI() {
39+
binding?.let { binding ->
40+
val application = requireActivity().applicationContext as MyTVApplication
3341

34-
val layoutParams = binding.channel.layoutParams as ViewGroup.MarginLayoutParams
35-
layoutParams.topMargin = application.px2Px(binding.channel.marginTop)
36-
layoutParams.marginEnd = application.px2Px(binding.channel.marginEnd)
37-
binding.channel.layoutParams = layoutParams
42+
binding.channel.layoutParams.width = application.px2Px(binding.channel.layoutParams.width)
43+
binding.channel.layoutParams.height = application.px2Px(binding.channel.layoutParams.height)
3844

39-
binding.content.textSize = application.px2PxFont(binding.content.textSize)
40-
binding.time.textSize = application.px2PxFont(binding.time.textSize)
45+
val layoutParams = binding.channel.layoutParams as ViewGroup.MarginLayoutParams
46+
layoutParams.topMargin = application.px2Px(binding.channel.marginTop)
47+
layoutParams.marginEnd = application.px2Px(binding.channel.marginEnd)
48+
binding.channel.layoutParams = layoutParams
4149

42-
binding.main.layoutParams.width = application.shouldWidthPx()
43-
binding.main.layoutParams.height = application.shouldHeightPx()
50+
binding.content.textSize = application.px2PxFont(binding.content.textSize)
51+
binding.time.textSize = application.px2PxFont(binding.time.textSize)
4452

45-
return binding.root
53+
binding.main.layoutParams.width = application.shouldWidthPx()
54+
binding.main.layoutParams.height = application.shouldHeightPx()
55+
}
4656
}
4757

4858
fun show(tvViewModel: TVModel) {
4959
handler.removeCallbacks(hideRunnable)
5060
handler.removeCallbacks(playRunnable)
51-
binding.content.text = (tvViewModel.tv.id.plus(1)).toString()
61+
binding?.content?.text = (tvViewModel.tv.id.plus(1)).toString()
5262
view?.visibility = View.VISIBLE
5363
handler.postDelayed(hideRunnable, delay)
5464
}
5565

5666
fun show(channel: String) {
57-
if (binding.content.text.length > 1) {
58-
return
59-
}
60-
this.channel = "${binding.content.text}$channel".toInt()
61-
handler.removeCallbacks(hideRunnable)
62-
handler.removeCallbacks(playRunnable)
63-
if (binding.content.text == "") {
64-
binding.content.text = channel
65-
view?.visibility = View.VISIBLE
66-
handler.postDelayed(playRunnable, delay)
67-
} else {
68-
binding.content.text = "${binding.content.text}$channel"
69-
handler.postDelayed(playRunnable, 0)
67+
binding?.let { binding ->
68+
if (binding.content.text.length > 1) {
69+
return
70+
}
71+
this.channel = "${binding.content.text}$channel".toInt()
72+
handler.removeCallbacks(hideRunnable)
73+
handler.removeCallbacks(playRunnable)
74+
if (binding.content.text.isEmpty()) {
75+
binding.content.text = channel
76+
view?.visibility = View.VISIBLE
77+
handler.postDelayed(playRunnable, delay)
78+
} else {
79+
binding.content.text = "${binding.content.text}$channel"
80+
handler.postDelayed(playRunnable, 0)
81+
}
7082
}
7183
}
7284

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

8698
private val hideRunnable = Runnable {
87-
binding.content.text = ""
99+
binding?.content?.text = ""
88100
view?.visibility = View.GONE
89101
}
90102

91103
private val playRunnable = Runnable {
92-
(activity as MainActivity).play(channel - 1)
104+
(activity as? MainActivity)?.play(channel - 1)
93105
handler.postDelayed(hideRunnable, delay)
94106
}
95107

96108
override fun onDestroyView() {
97109
super.onDestroyView()
110+
handler.removeCallbacks(hideRunnable)
111+
handler.removeCallbacks(playRunnable)
98112
_binding = null
99113
}
100114

app/src/main/java/com/lizongying/mytv0/MainActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,11 @@ class MainActivity : FragmentActivity() {
421421

422422
private val hideSetting = Runnable {
423423
if (!settingFragment.isHidden) {
424-
supportFragmentManager.beginTransaction().hide(settingFragment).commitNow()
424+
if (!supportFragmentManager.isDestroyed) {
425+
supportFragmentManager.beginTransaction().hide(settingFragment).commitNow()
426+
} else {
427+
Log.e(TAG, "SupportFragmentManager is destroyed!")
428+
}
425429
showTime()
426430
}
427431
}

app/src/main/java/com/lizongying/mytv0/PlayerFragment.kt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,14 @@ import android.view.SurfaceHolder
77
import android.view.SurfaceView
88
import android.view.View
99
import android.view.ViewGroup
10-
import android.view.ViewTreeObserver
1110
import androidx.annotation.OptIn
1211
import androidx.fragment.app.Fragment
1312
import androidx.media3.common.MimeTypes
14-
import androidx.media3.common.PlaybackException
15-
import androidx.media3.common.Player
16-
import androidx.media3.common.Player.DISCONTINUITY_REASON_AUTO_TRANSITION
17-
import androidx.media3.common.Player.REPEAT_MODE_ALL
18-
import androidx.media3.common.VideoSize
1913
import androidx.media3.common.util.UnstableApi
20-
import androidx.media3.datasource.DataSource
21-
import androidx.media3.datasource.DataSpec
22-
import androidx.media3.datasource.DefaultHttpDataSource
23-
import androidx.media3.datasource.TransferListener
24-
import androidx.media3.exoplayer.DefaultRenderersFactory
25-
import androidx.media3.exoplayer.ExoPlayer
2614
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
2715
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil
2816
import com.lizongying.mytv0.databinding.PlayerBinding
29-
import com.lizongying.mytv0.models.SourceType
3017
import com.lizongying.mytv0.models.TVModel
31-
import tv.danmaku.ijk.media.player.IjkMediaPlayer
3218

3319
class PlayerFragment : Fragment(), SurfaceHolder.Callback {
3420
private var _binding: PlayerBinding? = null
@@ -113,6 +99,11 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback {
11399
override fun onStart() {
114100
Log.i(TAG, "onStart")
115101
super.onStart()
102+
}
103+
104+
override fun onResume() {
105+
Log.i(TAG, "play-onResume")
106+
super.onResume()
116107
if (ijkUtil?.isPlaying == false) {
117108
Log.i(TAG, "replay")
118109
ijkUtil?.start()

0 commit comments

Comments
 (0)