Skip to content

Commit bcf9bab

Browse files
committed
add channel
1 parent f7eebb3 commit bcf9bab

File tree

11 files changed

+86
-42
lines changed

11 files changed

+86
-42
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@
1414

1515
## 更新日志
1616

17+
### v1.4.9(高版本专用)
18+
19+
* 同步v1.4.8
20+
21+
### v1.4.8(通用版)
22+
23+
* 频道号从1开始,CCTV5+为18
24+
* 提高CCTV6清晰度
25+
* 增加天津卫视、新疆卫视
26+
1727
### v1.4.7(高版本专用)
1828

19-
* 修复部分用户cctv13播放过程中卡住的问题
20-
* 调整cctv的频道顺序
29+
* 修复部分用户CCTV13播放过程中卡住的问题
30+
* 调整CCTV的频道顺序
31+
32+
### v1.4.6(通用版)
33+
34+
* 10以下频道不再需要先按0
2135

2236
### v1.4.5(高版本专用)
2337

app/src/main/java/com/lizongying/mytv/CardPresenter.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,31 @@ class CardPresenter(
3131
cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT)
3232
cardView.tag = tvViewModel.videoUrl.value
3333

34-
if (tvViewModel.logo.value != null) {
35-
if (tvViewModel.title.value == "CCTV8K 超高清") {
36-
Glide.with(viewHolder.view.context)
37-
.load(R.drawable.cctv8k)
38-
.centerInside()
39-
.into(cardView.mainImageView)
40-
} else {
41-
Glide.with(viewHolder.view.context)
42-
.load(tvViewModel.logo.value)
43-
.centerInside()
44-
.into(cardView.mainImageView)
45-
}
34+
when (tvViewModel.title.value) {
35+
"CCTV8K 超高清" -> Glide.with(viewHolder.view.context)
36+
.load(R.drawable.cctv8k)
37+
.centerInside()
38+
.into(cardView.mainImageView)
39+
40+
"天津卫视" -> Glide.with(viewHolder.view.context)
41+
.load(R.drawable.tianjin)
42+
.centerInside()
43+
.into(cardView.mainImageView)
4644

47-
cardView.setBackgroundColor(Color.WHITE)
48-
cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE)
45+
"新疆卫视" -> Glide.with(viewHolder.view.context)
46+
.load(R.drawable.xinjiang)
47+
.centerInside()
48+
.into(cardView.mainImageView)
49+
50+
else -> Glide.with(viewHolder.view.context)
51+
.load(tvViewModel.logo.value)
52+
.centerInside()
53+
.into(cardView.mainImageView)
4954
}
5055

56+
cardView.setBackgroundColor(Color.WHITE)
57+
cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE)
58+
5159
tvViewModel.program.observe(owner) { _ ->
5260
val program = tvViewModel.getProgramOne()
5361
if (program != null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ChannelFragment : Fragment() {
3030
fun show(tvViewModel: TVViewModel) {
3131
handler.removeCallbacks(hideRunnable)
3232
handler.removeCallbacks(playRunnable)
33-
binding.channelContent.text = tvViewModel.id.value.toString()
33+
binding.channelContent.text = (tvViewModel.id.value?.plus(1)).toString()
3434
view?.visibility = View.VISIBLE
3535
handler.postDelayed(hideRunnable, delay)
3636
}
@@ -60,7 +60,7 @@ class ChannelFragment : Fragment() {
6060
}
6161

6262
private val playRunnable = Runnable {
63-
(activity as MainActivity).play(channel)
63+
(activity as MainActivity).play(channel - 1)
6464
binding.channelContent.text = ""
6565
view?.visibility = View.GONE
6666
}

app/src/main/java/com/lizongying/mytv/InfoFragment.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.lizongying.mytv
22

33
import android.os.Bundle
44
import android.os.Handler
5-
import android.util.Log
65
import android.view.LayoutInflater
76
import android.view.View
87
import android.view.ViewGroup
@@ -30,12 +29,21 @@ class InfoFragment : Fragment() {
3029

3130
fun show(tvViewModel: TVViewModel) {
3231
binding.textView.text = tvViewModel.title.value
33-
if (tvViewModel.title.value == "CCTV8K 超高清") {
34-
Glide.with(this)
32+
33+
when (tvViewModel.title.value) {
34+
"CCTV8K 超高清" -> Glide.with(this)
3535
.load(R.drawable.cctv8k)
3636
.into(binding.infoLogo)
37-
} else {
38-
Glide.with(this)
37+
38+
"天津卫视" -> Glide.with(this)
39+
.load(R.drawable.tianjin)
40+
.into(binding.infoLogo)
41+
42+
"新疆卫视" -> Glide.with(this)
43+
.load(R.drawable.xinjiang)
44+
.into(binding.infoLogo)
45+
46+
else -> Glide.with(this)
3947
.load(tvViewModel.logo.value)
4048
.into(binding.infoLogo)
4149
}

app/src/main/java/com/lizongying/mytv/MainFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class MainFragment : BrowseSupportFragment() {
6262
mUpdateProgramRunnable = UpdateProgramRunnable()
6363
handler.post(mUpdateProgramRunnable)
6464

65-
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
65+
tvListViewModel.tvListViewModel.value?.forEach { tvViewModel ->
6666
tvViewModel.errInfo.observe(viewLifecycleOwner) { _ ->
6767
if (tvViewModel.errInfo.value != null
6868
&& tvViewModel.id.value == itemPosition
@@ -251,7 +251,7 @@ class MainFragment : BrowseSupportFragment() {
251251

252252
fun play(itemPosition: Int) {
253253
view?.post {
254-
if (itemPosition < tvListViewModel.size()) {
254+
if (itemPosition > -1 && itemPosition < tvListViewModel.size()) {
255255
this.itemPosition = itemPosition
256256
tvListViewModel.setItemPosition(itemPosition)
257257
tvListViewModel.getTVViewModel(itemPosition)?.changed()
@@ -290,7 +290,7 @@ class MainFragment : BrowseSupportFragment() {
290290
tvViewModel.programUpdateTime = timestamp
291291
request.fetchProgram(tvViewModel)
292292
} else {
293-
if (timestamp - tvViewModel.program.value!!.last().et < 600) {
293+
if (tvViewModel.program.value!!.last().et - timestamp < 600) {
294294
tvViewModel.programUpdateTime = timestamp
295295
request.fetchProgram(tvViewModel)
296296
}
@@ -300,7 +300,7 @@ class MainFragment : BrowseSupportFragment() {
300300

301301
inner class UpdateProgramRunnable : Runnable {
302302
override fun run() {
303-
tvListViewModel.getTVListViewModel().value?.filter { it.programId.value != null }
303+
tvListViewModel.tvListViewModel.value?.filter { it.programId.value != null }
304304
?.forEach { tvViewModel ->
305305
updateProgram(
306306
tvViewModel

app/src/main/java/com/lizongying/mytv/Request.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Request {
8181
"四川卫视" to "四川卫视",
8282
"福建东南卫视" to "东南卫视",
8383
"海南卫视" to "海南卫视",
84+
"天津卫视" to "天津卫视",
85+
"新疆卫视" to "新疆卫视",
8486
)
8587

8688
fun initYSP(context: Context) {
@@ -123,7 +125,7 @@ class Request {
123125
keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
124126
ivBytes
125127
).uppercase()
126-
Log.i(TAG, "$title url $url")
128+
Log.d(TAG, "$title url $url")
127129
tvModel.addVideoUrl(url)
128130
tvModel.allReady()
129131
tvModel.retryTimes = 0

app/src/main/java/com/lizongying/mytv/TVList.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object TVList {
77

88
private var mappingLogo = mapOf(
99
"CCTV4K 超高清" to "https://resources.yangshipin.cn/assets/oms/image/202306/3e9d06fd7244d950df5838750f1c6ac3456e172b51caca2c16d2282125b111e8.png?imageMogr2/format/webp",
10-
"CCTV8K 超高清" to "https://static.wikia.nocookie.net/logos/images/6/69/CCTV8K.png/revision/latest/scale-to-width-down/120?cb=20230104110835&path-prefix=vi",
10+
"CCTV8K 超高清" to "",
1111
"CCTV1 综合" to "https://resources.yangshipin.cn/assets/oms/image/202306/d57905b93540bd15f0c48230dbbbff7ee0d645ff539e38866e2d15c8b9f7dfcd.png?imageMogr2/format/webp",
1212
"CCTV2 财经" to "https://resources.yangshipin.cn/assets/oms/image/202306/20115388de0207131af17eac86c33049b95d69eaff064e55653a1b941810a006.png?imageMogr2/format/webp",
1313
"CCTV3 综艺" to "https://resources.yangshipin.cn/assets/oms/image/202306/7b7a65c712450da3deb6ca66fbacf4f9aee00d3f20bd80eafb5ada01ec63eb3a.png?imageMogr2/format/webp",
@@ -66,6 +66,8 @@ object TVList {
6666
"四川卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp",
6767
"东南卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp",
6868
"海南卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp",
69+
"天津卫视" to "",
70+
"新疆卫视" to "",
6971
)
7072
private var mappingEPG = mapOf(
7173
"CCTV4K 超高清" to "600002264",
@@ -128,6 +130,8 @@ object TVList {
128130
"四川卫视" to "600002516",
129131
"东南卫视" to "600002484",
130132
"海南卫视" to "600002506",
133+
"天津卫视" to "600152137",
134+
"新疆卫视" to "600152138",
131135
)
132136
private var mappingVideo = mapOf(
133137
"CCTV4K 超高清" to arrayOf("600002264", "2000266303"),
@@ -138,7 +142,7 @@ object TVList {
138142
"CCTV4 中文国际" to arrayOf("600001814", "2000204803"),
139143
"CCTV5 体育" to arrayOf("600001818", "2000205103"),
140144
"CCTV5+ 体育赛事" to arrayOf("600001817", "2000204503"),
141-
"CCTV6 电影" to arrayOf("600001802", "2000203303"),
145+
"CCTV6 电影" to arrayOf("600001802", "2013693901"),
142146
"CCTV7 国防军事" to arrayOf("600004092", "2000510003"),
143147
"CCTV8 电视剧" to arrayOf("600001803", "2000203903"),
144148
"CCTV9 记录" to arrayOf("600004078", "2000499403"),
@@ -190,6 +194,8 @@ object TVList {
190194
"四川卫视" to arrayOf("600002516", "2000295003"),
191195
"东南卫视" to arrayOf("600002484", "2000292503"),
192196
"海南卫视" to arrayOf("600002506", "2000291503"),
197+
"天津卫视" to arrayOf("600152137", "2019927003"),
198+
"新疆卫视" to arrayOf("600152138", "2019927403"),
193199
)
194200
private var count: Int = 0
195201

@@ -201,7 +207,6 @@ CCTV2 财经,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226195/index
201207
CCTV3 综艺,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226397/index.m3u8
202208
CCTV4 中文国际,http://39.134.24.161/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226191/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226191/index.m3u8
203209
CCTV5 体育,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226395/index.m3u8
204-
CCTV5+ 体育赛事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226221/index.m3u8
205210
CCTV6 电影,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226393/index.m3u8
206211
CCTV7 国防军事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226192/index.m3u8
207212
CCTV8 电视剧,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226391/index.m3u8
@@ -214,6 +219,7 @@ CCTV14 少儿,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226193/inde
214219
CCTV15 音乐,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225785/index.m3u8
215220
CCTV16 奥林匹克,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226921/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226921/index.m3u8
216221
CCTV17 农业农村,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226198/index.m3u8
222+
CCTV5+ 体育赛事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226221/index.m3u8
217223
CCTV4K 超高清,
218224
CCTV8K 超高清,
219225
风云剧场,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226950/index.m3u8
@@ -251,6 +257,8 @@ CCTV8K 超高清,
251257
四川卫视,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8
252258
东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8
253259
海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8
260+
天津卫视,
261+
新疆卫视,
254262
国际频道
255263
CGTN,http://live.cgtn.com/1000/prog_index.m3u8
256264
CGTN 法语频道,https://livefr.cgtn.com/1000f/prog_index.m3u8

app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ class TVListViewModel : ViewModel() {
88

99
var maxNum = mutableListOf<Int>()
1010

11-
private val tvListViewModel = MutableLiveData<MutableList<TVViewModel>>()
11+
private val _tvListViewModel = MutableLiveData<MutableList<TVViewModel>>()
12+
val tvListViewModel: LiveData<MutableList<TVViewModel>>
13+
get() = _tvListViewModel
1214

1315
private val _itemPosition = MutableLiveData<Int>()
1416
val itemPosition: LiveData<Int>
@@ -18,22 +20,20 @@ class TVListViewModel : ViewModel() {
1820
val itemPositionCurrent: LiveData<Int>
1921
get() = _itemPositionCurrent
2022

21-
fun getTVListViewModel(): MutableLiveData<MutableList<TVViewModel>> {
22-
return tvListViewModel
23-
}
24-
2523
fun addTVViewModel(tvViewModel: TVViewModel) {
26-
val currentTVModelList = tvListViewModel.value ?: mutableListOf()
27-
currentTVModelList.add(tvViewModel)
28-
tvListViewModel.value = currentTVModelList
24+
if (_tvListViewModel.value == null) {
25+
_tvListViewModel.value = mutableListOf(tvViewModel)
26+
} else {
27+
_tvListViewModel.value?.add(tvViewModel)
28+
}
2929
}
3030

3131
fun getTVViewModel(id: Int): TVViewModel? {
32-
return tvListViewModel.value?.get(id)
32+
return _tvListViewModel.value?.get(id)
3333
}
3434

3535
fun getTVViewModelCurrent(): TVViewModel? {
36-
return _itemPositionCurrent.value?.let { tvListViewModel.value?.get(it) }
36+
return _itemPositionCurrent.value?.let { _tvListViewModel.value?.get(it) }
3737
}
3838

3939
fun setItemPosition(position: Int) {
@@ -46,6 +46,9 @@ class TVListViewModel : ViewModel() {
4646
}
4747

4848
fun size(): Int {
49-
return tvListViewModel.value!!.size
49+
if (_tvListViewModel.value == null) {
50+
return 0
51+
}
52+
return _tvListViewModel.value!!.size
5053
}
5154
}

app/src/main/java/com/lizongying/mytv/models/TVViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
7878
var needToken = false
7979

8080
private val channelsNeedToken = arrayOf(
81+
// "CCTV4K 超高清",
8182
"CCTV3 综艺",
8283
"CCTV6 电影",
8384
"CCTV8 电视剧",
14.3 KB
Loading

0 commit comments

Comments
 (0)