mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-27 14:46:30 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eb6757543 | ||
|
|
72e893b73a | ||
|
|
e6530b4e9e | ||
|
|
c759ada907 | ||
|
|
bb4fd56845 | ||
|
|
657b8714a0 |
@@ -4,13 +4,27 @@
|
|||||||
|
|
||||||
## 使用
|
## 使用
|
||||||
|
|
||||||
下载安装[releases](https://github.com/lizongying/my-tv/releases)
|
下载安装 [releases](https://github.com/lizongying/my-tv/releases/)
|
||||||
|
|
||||||
[my-tv](https://lyrics.run/my-tv.html)
|
其他地址 [my-tv](https://lyrics.run/my-tv.html)
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
## 更新日志
|
||||||
|
|
||||||
|
### v1.2.5
|
||||||
|
|
||||||
|
* 美化频道信息显示
|
||||||
|
* 优化节目单获取
|
||||||
|
|
||||||
|
### v1.2.4
|
||||||
|
|
||||||
|
* 改变换台滑动方向,上一个频道下滑,下一个频道上滑
|
||||||
|
* 软件退出时,退出播放器
|
||||||
|
* 播放相同的频道,不再重复加载
|
||||||
|
* 暂时移除部分频道
|
||||||
|
|
||||||
## 其他
|
## 其他
|
||||||
|
|
||||||
小米电视可以使用小米电视助手进行安装
|
小米电视可以使用小米电视助手进行安装
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ static def VersionName() {
|
|||||||
dependencies {
|
dependencies {
|
||||||
def media3_version = "1.1.1"
|
def media3_version = "1.1.1"
|
||||||
|
|
||||||
|
implementation "androidx.media3:media3-ui:$media3_version"
|
||||||
|
|
||||||
// For media playback using ExoPlayer
|
// For media playback using ExoPlayer
|
||||||
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
<activity
|
<activity
|
||||||
android:keepScreenOn="true"
|
android:keepScreenOn="true"
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:banner="@drawable/tv"
|
android:banner="@drawable/logo"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@drawable/tv"
|
android:icon="@drawable/logo"
|
||||||
android:logo="@drawable/tv"
|
android:logo="@drawable/logo"
|
||||||
android:screenOrientation="landscape">
|
android:screenOrientation="landscape">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
Binary file not shown.
@@ -1,23 +0,0 @@
|
|||||||
package com.lizongying.mytv
|
|
||||||
|
|
||||||
import androidx.media3.common.C
|
|
||||||
import androidx.media3.common.util.UnstableApi
|
|
||||||
import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy
|
|
||||||
|
|
||||||
|
|
||||||
@UnstableApi
|
|
||||||
class CustomLoadErrorHandlingPolicy(private val minimumLoadableRetryCount: Int) :
|
|
||||||
DefaultLoadErrorHandlingPolicy(minimumLoadableRetryCount) {
|
|
||||||
|
|
||||||
override fun getMinimumLoadableRetryCount(dataType: Int): Int {
|
|
||||||
return if (minimumLoadableRetryCount == -1) {
|
|
||||||
if (dataType == C.DATA_TYPE_MEDIA_PROGRESSIVE_LIVE) {
|
|
||||||
DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE
|
|
||||||
} else {
|
|
||||||
DEFAULT_MIN_LOADABLE_RETRY_COUNT
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
minimumLoadableRetryCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,290 +0,0 @@
|
|||||||
package com.lizongying.mytv
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.media.MediaPlayer
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Handler
|
|
||||||
import android.view.SurfaceHolder
|
|
||||||
import androidx.annotation.OptIn
|
|
||||||
import androidx.leanback.media.PlaybackGlueHost
|
|
||||||
import androidx.leanback.media.PlayerAdapter
|
|
||||||
import androidx.leanback.media.SurfaceHolderGlueHost
|
|
||||||
import androidx.media3.common.MediaItem
|
|
||||||
import androidx.media3.common.PlaybackException
|
|
||||||
import androidx.media3.common.Player
|
|
||||||
import androidx.media3.common.util.UnstableApi
|
|
||||||
import androidx.media3.datasource.DefaultHttpDataSource
|
|
||||||
import androidx.media3.exoplayer.ExoPlayer
|
|
||||||
import androidx.media3.exoplayer.hls.HlsMediaSource
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
|
|
||||||
open class ExoPlayerAdapter(private var mContext: Context?) : PlayerAdapter() {
|
|
||||||
|
|
||||||
val mPlayer = mContext?.let { ExoPlayer.Builder(it).build() }
|
|
||||||
var mSurfaceHolderGlueHost: SurfaceHolderGlueHost? = null
|
|
||||||
val mRunnable: Runnable = object : Runnable {
|
|
||||||
override fun run() {
|
|
||||||
callback.onCurrentPositionChanged(this@ExoPlayerAdapter)
|
|
||||||
mHandler.postDelayed(this, getProgressUpdatingInterval().toLong())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
val mHandler = Handler()
|
|
||||||
var mInitialized = false // true when the MediaPlayer is prepared/initialized
|
|
||||||
|
|
||||||
var mMediaSourceUri: Uri? = null
|
|
||||||
var mHasDisplay = false
|
|
||||||
var mBufferedProgress: Long = 0
|
|
||||||
|
|
||||||
var mBufferingStart = false
|
|
||||||
|
|
||||||
|
|
||||||
private var mMinimumLoadableRetryCount = 3
|
|
||||||
|
|
||||||
|
|
||||||
private var mPlayerErrorListener: PlayerErrorListener? = null
|
|
||||||
|
|
||||||
init {
|
|
||||||
mPlayer?.playWhenReady = true
|
|
||||||
|
|
||||||
if (mPlayerErrorListener == null) {
|
|
||||||
mPlayerErrorListener = PlayerErrorListener()
|
|
||||||
mPlayer?.addListener(mPlayerErrorListener!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
open fun notifyBufferingStartEnd() {
|
|
||||||
callback.onBufferingStateChanged(
|
|
||||||
this@ExoPlayerAdapter,
|
|
||||||
mBufferingStart || !mInitialized
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToHost(host: PlaybackGlueHost?) {
|
|
||||||
if (host is SurfaceHolderGlueHost) {
|
|
||||||
mSurfaceHolderGlueHost = host
|
|
||||||
mSurfaceHolderGlueHost!!.setSurfaceHolderCallback(VideoPlayerSurfaceHolderCallback(this))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will reset the [MediaPlayer] and the glue such that a new file can be played. You are
|
|
||||||
* not required to call this method before playing the first file. However you have to call it
|
|
||||||
* before playing a second one.
|
|
||||||
*/
|
|
||||||
open fun reset() {
|
|
||||||
changeToUnitialized()
|
|
||||||
// mPlayer.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun changeToUnitialized() {
|
|
||||||
if (mInitialized) {
|
|
||||||
mInitialized = false
|
|
||||||
notifyBufferingStartEnd()
|
|
||||||
if (mHasDisplay) {
|
|
||||||
callback.onPreparedStateChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release internal MediaPlayer. Should not use the object after call release().
|
|
||||||
*/
|
|
||||||
open fun release() {
|
|
||||||
changeToUnitialized()
|
|
||||||
mHasDisplay = false
|
|
||||||
mPlayer?.release()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromHost() {
|
|
||||||
if (mSurfaceHolderGlueHost != null) {
|
|
||||||
mSurfaceHolderGlueHost!!.setSurfaceHolderCallback(null)
|
|
||||||
mSurfaceHolderGlueHost = null
|
|
||||||
}
|
|
||||||
reset()
|
|
||||||
release()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see MediaPlayer.setDisplay
|
|
||||||
*/
|
|
||||||
fun setDisplay(surfaceHolder: SurfaceHolder?) {
|
|
||||||
val hadDisplay = mHasDisplay
|
|
||||||
mHasDisplay = surfaceHolder != null
|
|
||||||
if (hadDisplay == mHasDisplay) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mPlayer?.setVideoSurfaceHolder(surfaceHolder)
|
|
||||||
if (mHasDisplay) {
|
|
||||||
if (mInitialized) {
|
|
||||||
callback.onPreparedStateChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mInitialized) {
|
|
||||||
callback.onPreparedStateChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setProgressUpdatingEnabled(enabled: Boolean) {
|
|
||||||
mHandler.removeCallbacks(mRunnable)
|
|
||||||
if (!enabled) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mHandler.postDelayed(mRunnable, getProgressUpdatingInterval().toLong())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return updating interval of progress UI in milliseconds. Subclass may override.
|
|
||||||
* @return Update interval of progress UI in milliseconds.
|
|
||||||
*/
|
|
||||||
open fun getProgressUpdatingInterval(): Int {
|
|
||||||
return 16
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isPlaying(): Boolean {
|
|
||||||
return mInitialized && mPlayer?.isPlaying ?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDuration(): Long {
|
|
||||||
if (mInitialized) {
|
|
||||||
val duration = mPlayer?.duration
|
|
||||||
if (duration != null) {
|
|
||||||
return duration.toLong()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCurrentPosition(): Long {
|
|
||||||
if (mInitialized) {
|
|
||||||
val currentPosition = mPlayer?.currentPosition
|
|
||||||
if (currentPosition != null) {
|
|
||||||
return currentPosition.toLong()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun play() {
|
|
||||||
if (!mInitialized || mPlayer?.isPlaying == true) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mPlayer?.play()
|
|
||||||
callback.onPlayStateChanged(this@ExoPlayerAdapter)
|
|
||||||
callback.onCurrentPositionChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun pause() {
|
|
||||||
if (isPlaying) {
|
|
||||||
mPlayer?.pause()
|
|
||||||
callback.onPlayStateChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun seekTo(newPosition: Long) {
|
|
||||||
if (!mInitialized) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mPlayer?.seekTo(newPosition.toInt().toLong())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getBufferedPosition(): Long {
|
|
||||||
return mBufferedProgress
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class PlayerErrorListener : Player.Listener {
|
|
||||||
override fun onPlayerError(error: PlaybackException) {
|
|
||||||
callback.onError(this@ExoPlayerAdapter, error.errorCode, error.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private var mHeaders: Map<String, String>? = mapOf()
|
|
||||||
|
|
||||||
fun setHeaders(headers: Map<String, String>) {
|
|
||||||
mHeaders = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the media source of the player witha given URI.
|
|
||||||
*
|
|
||||||
* @return Returns `true` if uri represents a new media; `false`
|
|
||||||
* otherwise.
|
|
||||||
* @see MediaPlayer.setDataSource
|
|
||||||
*/
|
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
|
||||||
open fun setDataSource(uri: Uri?): Boolean {
|
|
||||||
if (if (mMediaSourceUri != null) mMediaSourceUri == uri else uri == null) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
mMediaSourceUri = uri
|
|
||||||
|
|
||||||
val httpDataSource = DefaultHttpDataSource.Factory()
|
|
||||||
mHeaders?.let { httpDataSource.setDefaultRequestProperties(it) }
|
|
||||||
|
|
||||||
val hlsMediaSource =
|
|
||||||
HlsMediaSource.Factory(httpDataSource).setLoadErrorHandlingPolicy(
|
|
||||||
CustomLoadErrorHandlingPolicy(mMinimumLoadableRetryCount)
|
|
||||||
).createMediaSource(
|
|
||||||
MediaItem.fromUri(
|
|
||||||
mMediaSourceUri!!
|
|
||||||
)
|
|
||||||
)
|
|
||||||
prepareMediaForPlaying(hlsMediaSource)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
|
||||||
open fun setDataSource(hlsMediaSource: HlsMediaSource): Boolean {
|
|
||||||
prepareMediaForPlaying(hlsMediaSource)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setMinimumLoadableRetryCount(minimumLoadableRetryCount: Int) {
|
|
||||||
mMinimumLoadableRetryCount = minimumLoadableRetryCount
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
|
||||||
private fun prepareMediaForPlaying(hlsMediaSource: HlsMediaSource) {
|
|
||||||
try {
|
|
||||||
mPlayer?.setMediaSource(hlsMediaSource)
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
mPlayer?.prepare()
|
|
||||||
|
|
||||||
callback.onPlayStateChanged(this@ExoPlayerAdapter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return True if MediaPlayer OnPreparedListener is invoked and got a SurfaceHolder if
|
|
||||||
* [PlaybackGlueHost] provides SurfaceHolder.
|
|
||||||
*/
|
|
||||||
override fun isPrepared(): Boolean {
|
|
||||||
return mInitialized && (mSurfaceHolderGlueHost == null || mHasDisplay)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "ExoPlayerAdapter"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class VideoPlayerSurfaceHolderCallback(private val playerAdapter: ExoPlayerAdapter) :
|
|
||||||
SurfaceHolder.Callback {
|
|
||||||
|
|
||||||
override fun surfaceCreated(surfaceHolder: SurfaceHolder) {
|
|
||||||
playerAdapter.setDisplay(surfaceHolder)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun surfaceChanged(surfaceHolder: SurfaceHolder, i: Int, i1: Int, i2: Int) {
|
|
||||||
// Handle surface changes if needed
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun surfaceDestroyed(surfaceHolder: SurfaceHolder) {
|
|
||||||
playerAdapter.setDisplay(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,23 @@
|
|||||||
package com.lizongying.mytv
|
package com.lizongying.mytv
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import com.lizongying.mytv.databinding.InfoBinding
|
import com.lizongying.mytv.databinding.InfoBinding
|
||||||
|
import com.lizongying.mytv.models.TVViewModel
|
||||||
|
|
||||||
class InfoFragment : Fragment() {
|
class InfoFragment : Fragment() {
|
||||||
private var _binding: InfoBinding? = null
|
private var _binding: InfoBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
private val handler = Handler()
|
||||||
|
private val delay: Long = 3000
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
@@ -19,8 +26,39 @@ class InfoFragment : Fragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setInfo(info: TV) {
|
override fun onResume() {
|
||||||
binding.textView.text = info.title
|
super.onResume()
|
||||||
|
|
||||||
|
// Use a Handler to delay the fragment transaction
|
||||||
|
handler.postDelayed(removeRunnable, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun show(tvViewModel: TVViewModel) {
|
||||||
|
Log.i("", "show")
|
||||||
|
binding.textView.text = tvViewModel.title.value
|
||||||
|
Glide.with(this)
|
||||||
|
.load(tvViewModel.logo.value)
|
||||||
|
.into(binding.infoLogo)
|
||||||
|
val program = tvViewModel.getProgramOne()
|
||||||
|
if (program != null) {
|
||||||
|
binding.infoDesc.text = program.name
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.removeCallbacks(removeRunnable)
|
||||||
|
view?.visibility = View.VISIBLE
|
||||||
|
handler.postDelayed(removeRunnable, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
Log.i("", "onPause")
|
||||||
|
// Cancel the delayed task when the fragment is paused
|
||||||
|
handler.removeCallbacks(removeRunnable)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val removeRunnable = Runnable {
|
||||||
|
Log.i("", "hide")
|
||||||
|
view?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import android.util.Log
|
|||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
@@ -26,7 +27,7 @@ import java.security.MessageDigest
|
|||||||
|
|
||||||
class MainActivity : FragmentActivity() {
|
class MainActivity : FragmentActivity() {
|
||||||
|
|
||||||
private val playbackFragment = PlaybackFragment()
|
var playerFragment = PlayerFragment()
|
||||||
private val mainFragment = MainFragment()
|
private val mainFragment = MainFragment()
|
||||||
private val infoFragment = InfoFragment()
|
private val infoFragment = InfoFragment()
|
||||||
|
|
||||||
@@ -40,42 +41,28 @@ class MainActivity : FragmentActivity() {
|
|||||||
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||||
|
window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.add(R.id.main_browse_fragment, playbackFragment)
|
.add(R.id.main_browse_fragment, playerFragment)
|
||||||
.add(R.id.main_browse_fragment, mainFragment)
|
|
||||||
.add(R.id.main_browse_fragment, infoFragment)
|
.add(R.id.main_browse_fragment, infoFragment)
|
||||||
|
.add(R.id.main_browse_fragment, mainFragment)
|
||||||
.hide(infoFragment)
|
.hide(infoFragment)
|
||||||
.commit()
|
.commit()
|
||||||
|
mainFragment.view?.requestFocus()
|
||||||
}
|
}
|
||||||
gestureDetector = GestureDetector(this, GestureListener())
|
gestureDetector = GestureDetector(this, GestureListener())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun switchInfoFragment(tv: TV) {
|
fun showInfoFragment(tvViewModel: TVViewModel) {
|
||||||
infoFragment.setInfo(tv)
|
infoFragment.show(tvViewModel)
|
||||||
|
|
||||||
if (infoFragment.isHidden) {
|
|
||||||
supportFragmentManager.beginTransaction().show(infoFragment).commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showInfoFragment(tv: TV) {
|
|
||||||
infoFragment.setInfo(tv)
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.show(infoFragment)
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hideInfoFragment() {
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.hide(infoFragment)
|
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun play(tvViewModel: TVViewModel) {
|
fun play(tvViewModel: TVViewModel) {
|
||||||
Log.i(TAG, "play: ${tvViewModel.getTV()}")
|
Log.i(TAG, "play: ${tvViewModel.getTV()}")
|
||||||
playbackFragment.play(tvViewModel)
|
playerFragment.play(tvViewModel)
|
||||||
|
mainFragment.view?.requestFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prev() {
|
fun prev() {
|
||||||
@@ -86,11 +73,11 @@ class MainActivity : FragmentActivity() {
|
|||||||
mainFragment.next()
|
mainFragment.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prevSource() {
|
private fun prevSource() {
|
||||||
mainFragment.prevSource()
|
mainFragment.prevSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextSource() {
|
private fun nextSource() {
|
||||||
mainFragment.nextSource()
|
mainFragment.nextSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +98,7 @@ class MainActivity : FragmentActivity() {
|
|||||||
mainFragment.focus()
|
mainFragment.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mainFragmentIsHidden(): Boolean {
|
private fun mainFragmentIsHidden(): Boolean {
|
||||||
return mainFragment.isHidden
|
return mainFragment.isHidden
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +111,6 @@ class MainActivity : FragmentActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
||||||
// 在触摸事件中将事件传递给 GestureDetector 处理手势
|
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
gestureDetector.onTouchEvent(event)
|
gestureDetector.onTouchEvent(event)
|
||||||
}
|
}
|
||||||
@@ -134,35 +120,8 @@ class MainActivity : FragmentActivity() {
|
|||||||
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
|
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||||
// 处理单击事件
|
Log.i(TAG, "onSingleTapConfirmed")
|
||||||
val versionName = getPackageInfo().versionName
|
switchMainFragment()
|
||||||
|
|
||||||
val textView = TextView(this@MainActivity)
|
|
||||||
textView.text =
|
|
||||||
"当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/"
|
|
||||||
|
|
||||||
val imageView = ImageView(this@MainActivity)
|
|
||||||
val drawable = ContextCompat.getDrawable(this@MainActivity, R.drawable.appreciate)
|
|
||||||
imageView.setImageDrawable(drawable)
|
|
||||||
|
|
||||||
val linearLayout = LinearLayout(this@MainActivity)
|
|
||||||
linearLayout.orientation = LinearLayout.VERTICAL
|
|
||||||
linearLayout.addView(textView)
|
|
||||||
linearLayout.addView(imageView)
|
|
||||||
|
|
||||||
val layoutParams = LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
imageView.layoutParams = layoutParams
|
|
||||||
textView.layoutParams = layoutParams
|
|
||||||
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this@MainActivity)
|
|
||||||
builder
|
|
||||||
.setView(linearLayout)
|
|
||||||
|
|
||||||
val dialog: AlertDialog = builder.create()
|
|
||||||
dialog.show()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,30 +131,27 @@ class MainActivity : FragmentActivity() {
|
|||||||
velocityX: Float,
|
velocityX: Float,
|
||||||
velocityY: Float
|
velocityY: Float
|
||||||
): Boolean {
|
): Boolean {
|
||||||
// 如果 Y 方向的速度为负值,表示向上滑动
|
if (velocityY > 0) {
|
||||||
if (velocityY < 0) {
|
|
||||||
// 在这里执行上滑时的操作
|
|
||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
prev()
|
prev()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.selectedPosition == 0) {
|
// if (mainFragment.selectedPosition == 0) {
|
||||||
mainFragment.setSelectedPosition(
|
// mainFragment.setSelectedPosition(
|
||||||
mainFragment.tvListViewModel.maxNum.size - 1,
|
// mainFragment.tvListViewModel.maxNum.size - 1,
|
||||||
false
|
// false
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (velocityY > 0) {
|
if (velocityY < 0) {
|
||||||
// 在这里执行上滑时的操作
|
|
||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
// if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
||||||
// mainFragment.setSelectedPosition(0, false)
|
//// mainFragment.setSelectedPosition(0, false)
|
||||||
hideMainFragment()
|
// hideMainFragment()
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onFling(e1, e2, velocityX, velocityY)
|
return super.onFling(e1, e2, velocityX, velocityY)
|
||||||
@@ -268,12 +224,12 @@ class MainActivity : FragmentActivity() {
|
|||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
prev()
|
prev()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.selectedPosition == 0) {
|
// if (mainFragment.selectedPosition == 0) {
|
||||||
mainFragment.setSelectedPosition(
|
// mainFragment.setSelectedPosition(
|
||||||
mainFragment.tvListViewModel.maxNum.size - 1,
|
// mainFragment.tvListViewModel.maxNum.size - 1,
|
||||||
false
|
// false
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,11 +237,11 @@ class MainActivity : FragmentActivity() {
|
|||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
// if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
||||||
// mainFragment.setSelectedPosition(0, false)
|
//// mainFragment.setSelectedPosition(0, false)
|
||||||
hideMainFragment()
|
// hideMainFragment()
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,12 +249,12 @@ class MainActivity : FragmentActivity() {
|
|||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
prevSource()
|
prevSource()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.tvListViewModel.getTVViewModelCurrent()
|
// if (mainFragment.tvListViewModel.getTVViewModelCurrent()
|
||||||
?.getItemPosition() == 0
|
// ?.getItemPosition() == 0
|
||||||
) {
|
// ) {
|
||||||
// mainFragment.toLastPosition()
|
//// mainFragment.toLastPosition()
|
||||||
hideMainFragment()
|
// hideMainFragment()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,11 +262,11 @@ class MainActivity : FragmentActivity() {
|
|||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
nextSource()
|
nextSource()
|
||||||
} else {
|
} else {
|
||||||
if (mainFragment.tvListViewModel.getTVViewModelCurrent()
|
// if (mainFragment.tvListViewModel.getTVViewModelCurrent()
|
||||||
?.getItemPosition() == mainFragment.tvListViewModel.maxNum[mainFragment.selectedPosition] - 1
|
// ?.getItemPosition() == mainFragment.tvListViewModel.maxNum[mainFragment.selectedPosition] - 1
|
||||||
) {
|
// ) {
|
||||||
mainFragment.toFirstPosition()
|
// mainFragment.toFirstPosition()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package com.lizongying.mytv
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.leanback.app.BrowseSupportFragment
|
import androidx.leanback.app.BrowseSupportFragment
|
||||||
import androidx.leanback.widget.ArrayObjectAdapter
|
import androidx.leanback.widget.ArrayObjectAdapter
|
||||||
import androidx.leanback.widget.HeaderItem
|
import androidx.leanback.widget.HeaderItem
|
||||||
@@ -17,6 +18,7 @@ import androidx.leanback.widget.Presenter
|
|||||||
import androidx.leanback.widget.Row
|
import androidx.leanback.widget.Row
|
||||||
import androidx.leanback.widget.RowPresenter
|
import androidx.leanback.widget.RowPresenter
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import com.lizongying.mytv.Utils.getDateTimestamp
|
||||||
import com.lizongying.mytv.models.TVListViewModel
|
import com.lizongying.mytv.models.TVListViewModel
|
||||||
import com.lizongying.mytv.models.TVViewModel
|
import com.lizongying.mytv.models.TVViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -33,6 +35,12 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
var tvListViewModel = TVListViewModel()
|
var tvListViewModel = TVListViewModel()
|
||||||
|
|
||||||
private var sharedPref: SharedPreferences? = null
|
private var sharedPref: SharedPreferences? = null
|
||||||
|
|
||||||
|
private var lastVideoUrl: String = ""
|
||||||
|
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private lateinit var mUpdateProgramRunnable: UpdateProgramRunnable
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
headersState = HEADERS_DISABLED
|
headersState = HEADERS_DISABLED
|
||||||
@@ -45,68 +53,105 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
|
|
||||||
request = activity?.let { Request(it) }
|
request = activity?.let { Request(it) }
|
||||||
loadRows()
|
loadRows()
|
||||||
|
mUpdateProgramRunnable = UpdateProgramRunnable()
|
||||||
|
handler.post(mUpdateProgramRunnable)
|
||||||
|
|
||||||
setupEventListeners()
|
setupEventListeners()
|
||||||
|
|
||||||
view?.post {
|
view?.post {
|
||||||
// request?.fetchPage()
|
// request?.fetchPage()
|
||||||
// tvListViewModel.getTVViewModel(0)?.let { request?.fetchProgram(it) }
|
// tvListViewModel.getTVViewModel(0)?.let { request?.fetchProgram(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
|
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
|
||||||
tvViewModel.ready.observe(viewLifecycleOwner) { _ ->
|
tvViewModel.ready.observe(viewLifecycleOwner) { _ ->
|
||||||
if (tvViewModel.ready.value != null) {
|
|
||||||
|
// not first time && channel not change
|
||||||
|
if (tvViewModel.ready.value != null
|
||||||
|
&& tvViewModel.id.value == itemPosition
|
||||||
|
&& check(tvViewModel)
|
||||||
|
) {
|
||||||
Log.i(TAG, "ready ${tvViewModel.title.value}")
|
Log.i(TAG, "ready ${tvViewModel.title.value}")
|
||||||
if (tvViewModel.id.value == itemPosition) {
|
(activity as? MainActivity)?.play(tvViewModel)
|
||||||
(activity as? MainActivity)?.play(tvViewModel)
|
|
||||||
// (activity as? MainActivity)?.switchInfoFragment(tv)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tvViewModel.change.observe(viewLifecycleOwner) { _ ->
|
tvViewModel.change.observe(viewLifecycleOwner) { _ ->
|
||||||
if (tvViewModel.change.value != null) {
|
if (tvViewModel.change.value != null) {
|
||||||
Log.i(TAG, "switch to ${tvViewModel.title.value}")
|
val title = tvViewModel.title.value
|
||||||
|
Log.i(TAG, "switch $title")
|
||||||
if (tvViewModel.ysp() != null) {
|
if (tvViewModel.ysp() != null) {
|
||||||
Log.i(TAG, "${tvViewModel.title.value} to get ysp")
|
Log.i(TAG, "request $title")
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
tvViewModel.let { request?.fetchData(it) }
|
tvViewModel.let { request?.fetchData(it) }
|
||||||
}
|
}
|
||||||
|
(activity as? MainActivity)?.showInfoFragment(tvViewModel)
|
||||||
|
setSelectedPosition(
|
||||||
|
tvViewModel.getRowPosition(), true,
|
||||||
|
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(activity as? MainActivity)?.play(tvViewModel)
|
if (check(tvViewModel)) {
|
||||||
// (activity as? MainActivity)?.switchInfoFragment(item)
|
(activity as? MainActivity)?.play(tvViewModel)
|
||||||
}
|
(activity as? MainActivity)?.showInfoFragment(tvViewModel)
|
||||||
setSelectedPosition(
|
|
||||||
tvViewModel.getRowPosition(), true,
|
setSelectedPosition(
|
||||||
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
tvViewModel.getRowPosition(), true,
|
||||||
)
|
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
||||||
Toast.makeText(
|
)
|
||||||
activity,
|
}
|
||||||
tvViewModel.title.value,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tvViewModel.program.observe(viewLifecycleOwner) { _ ->
|
|
||||||
if (tvViewModel.program.value!!.isEmpty()) {
|
|
||||||
if (tvViewModel.programId.value != null) {
|
|
||||||
Log.i(TAG, "get program ${tvViewModel.title.value}")
|
|
||||||
request?.fetchProgram(tvViewModel)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkProgram() {
|
override fun onDestroy() {
|
||||||
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
|
super.onDestroy()
|
||||||
|
handler.removeCallbacks(mUpdateProgramRunnable)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateProgram(tvViewModel: TVViewModel) {
|
||||||
|
val timestamp = getDateTimestamp()
|
||||||
|
if (timestamp - tvViewModel.programUpdateTime > 60) {
|
||||||
if (tvViewModel.program.value!!.isEmpty()) {
|
if (tvViewModel.program.value!!.isEmpty()) {
|
||||||
if (tvViewModel.programId.value != null) {
|
tvViewModel.programUpdateTime = timestamp
|
||||||
Log.i(TAG, "get program ${tvViewModel.title.value}")
|
request?.fetchProgram(tvViewModel)
|
||||||
|
} else {
|
||||||
|
if (timestamp - tvViewModel.program.value!!.last().et < 600) {
|
||||||
|
tvViewModel.programUpdateTime = timestamp
|
||||||
request?.fetchProgram(tvViewModel)
|
request?.fetchProgram(tvViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inner class UpdateProgramRunnable : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
tvListViewModel.getTVListViewModel().value?.filter { it.programId.value != null }
|
||||||
|
?.forEach { tvViewModel ->
|
||||||
|
updateProgram(
|
||||||
|
tvViewModel
|
||||||
|
)
|
||||||
|
}
|
||||||
|
handler.postDelayed(this, 60000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun check(tvViewModel: TVViewModel): Boolean {
|
||||||
|
val title = tvViewModel.title.value
|
||||||
|
val videoUrl = tvViewModel.videoIndex.value?.let { tvViewModel.videoUrl.value?.get(it) }
|
||||||
|
if (videoUrl == null || videoUrl == "") {
|
||||||
|
Log.e(TAG, "$title videoUrl is empty")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoUrl == lastVideoUrl) {
|
||||||
|
Log.e(TAG, "$title videoUrl is duplication")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
fun toLastPosition() {
|
fun toLastPosition() {
|
||||||
setSelectedPosition(
|
setSelectedPosition(
|
||||||
selectedPosition, false,
|
selectedPosition, false,
|
||||||
@@ -246,12 +291,13 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
row: Row
|
row: Row
|
||||||
) {
|
) {
|
||||||
if (item is TVViewModel) {
|
if (item is TVViewModel) {
|
||||||
itemPosition = item.id.value!!
|
if (itemPosition != item.id.value!!) {
|
||||||
savePosition(itemPosition)
|
itemPosition = item.id.value!!
|
||||||
|
savePosition(itemPosition)
|
||||||
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
|
||||||
tvViewModel?.changed()
|
|
||||||
|
|
||||||
|
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
||||||
|
tvViewModel?.changed()
|
||||||
|
}
|
||||||
(activity as? MainActivity)?.switchMainFragment()
|
(activity as? MainActivity)?.switchMainFragment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,23 +308,17 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
itemViewHolder: Presenter.ViewHolder?, item: Any?,
|
itemViewHolder: Presenter.ViewHolder?, item: Any?,
|
||||||
rowViewHolder: RowPresenter.ViewHolder, row: Row
|
rowViewHolder: RowPresenter.ViewHolder, row: Row
|
||||||
) {
|
) {
|
||||||
if (itemViewHolder == null) {
|
|
||||||
view?.post {
|
|
||||||
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
|
||||||
if (tvViewModel != null) {
|
|
||||||
setSelectedPosition(
|
|
||||||
tvViewModel.getRowPosition(), false,
|
|
||||||
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item is TVViewModel) {
|
if (item is TVViewModel) {
|
||||||
tvListViewModel.setItemPositionCurrent(item.id.value!!)
|
tvListViewModel.setItemPositionCurrent(item.id.value!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
view!!.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "MainFragment"
|
private const val TAG = "MainFragment"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.lizongying.mytv
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.KeyEvent
|
|
||||||
import android.view.View
|
|
||||||
import androidx.leanback.media.MediaPlayerAdapter
|
|
||||||
import androidx.leanback.media.PlaybackTransportControlGlue
|
|
||||||
import androidx.leanback.media.PlayerAdapter
|
|
||||||
|
|
||||||
class PlaybackControlGlue(
|
|
||||||
context: Context?,
|
|
||||||
playerAdapter: PlayerAdapter?,
|
|
||||||
) :
|
|
||||||
PlaybackTransportControlGlue<PlayerAdapter>(context, playerAdapter) {
|
|
||||||
|
|
||||||
override fun onKey(v: View?, keyCode: Int, event: KeyEvent?): Boolean {
|
|
||||||
if (event!!.action == KeyEvent.ACTION_DOWN) {
|
|
||||||
when (keyCode) {
|
|
||||||
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
|
||||||
Log.i(TAG, "KEYCODE_DPAD_CENTER")
|
|
||||||
(context as? MainActivity)?.switchMainFragment()
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_UP -> {
|
|
||||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
|
||||||
(context as? MainActivity)?.prev()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
|
||||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
|
||||||
(context as? MainActivity)?.next()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
|
||||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
|
||||||
(context as? MainActivity)?.prevSource()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
|
||||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
|
||||||
(context as? MainActivity)?.nextSource()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onKey(v, keyCode, event)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "PlaybackControlGlue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.lizongying.mytv
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.leanback.app.VideoSupportFragment
|
|
||||||
import androidx.leanback.app.VideoSupportFragmentGlueHost
|
|
||||||
import androidx.leanback.media.PlaybackTransportControlGlue
|
|
||||||
import androidx.leanback.media.PlayerAdapter
|
|
||||||
import androidx.leanback.widget.PlaybackControlsRow
|
|
||||||
import com.lizongying.mytv.models.TVViewModel
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class PlaybackFragment : VideoSupportFragment() {
|
|
||||||
|
|
||||||
private lateinit var mTransportControlGlue: PlaybackTransportControlGlue<PlayerAdapter>
|
|
||||||
private var playerAdapter: ExoPlayerAdapter? = null
|
|
||||||
private var lastVideoUrl: String = ""
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
playerAdapter = ExoPlayerAdapter(context)
|
|
||||||
playerAdapter?.setRepeatAction(PlaybackControlsRow.RepeatAction.INDEX_NONE)
|
|
||||||
|
|
||||||
view?.isFocusable = false
|
|
||||||
view?.isFocusableInTouchMode = false
|
|
||||||
|
|
||||||
val glueHost = VideoSupportFragmentGlueHost(this@PlaybackFragment)
|
|
||||||
mTransportControlGlue = PlaybackControlGlue(activity, playerAdapter)
|
|
||||||
mTransportControlGlue.host = glueHost
|
|
||||||
mTransportControlGlue.playWhenPrepared()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showControlsOverlay(runAnimation: Boolean) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fun play(tvModel: TVViewModel) {
|
|
||||||
val videoUrl = tvModel.videoIndex.value?.let { tvModel.videoUrl.value?.get(it) }
|
|
||||||
if (videoUrl == null || videoUrl == "") {
|
|
||||||
Log.e(TAG, "${tvModel.title.value} videoUrl is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (videoUrl == lastVideoUrl) {
|
|
||||||
Log.e(TAG, "videoUrl is duplication")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
lastVideoUrl = videoUrl
|
|
||||||
|
|
||||||
playerAdapter?.callback = PlayerCallback(tvModel)
|
|
||||||
if (tvModel.ysp() != null) {
|
|
||||||
playerAdapter?.setMinimumLoadableRetryCount(0)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
playerAdapter?.setDataSource(Uri.parse(videoUrl))
|
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.e(TAG, "error $e")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
hideControlsOverlay(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class PlayerCallback(private var tvModel: TVViewModel) :
|
|
||||||
PlayerAdapter.Callback() {
|
|
||||||
override fun onError(adapter: PlayerAdapter?, errorCode: Int, errorMessage: String?) {
|
|
||||||
Log.e(TAG, "on error: $errorMessage")
|
|
||||||
if (tvModel.ysp() != null && tvModel.videoIndex.value!! > 0 && errorMessage == "Source error") {
|
|
||||||
tvModel.changed()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "PlaybackVideoFragment"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package com.lizongying.mytv
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
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.MediaItem
|
||||||
|
import androidx.media3.common.PlaybackException
|
||||||
|
import androidx.media3.common.Player
|
||||||
|
import androidx.media3.common.VideoSize
|
||||||
|
import androidx.media3.common.util.UnstableApi
|
||||||
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
|
import androidx.media3.ui.PlayerView
|
||||||
|
import com.lizongying.mytv.databinding.PlayerBinding
|
||||||
|
import com.lizongying.mytv.models.TVViewModel
|
||||||
|
|
||||||
|
|
||||||
|
class PlayerFragment : Fragment() {
|
||||||
|
|
||||||
|
private var _binding: PlayerBinding? = null
|
||||||
|
private var playerView: PlayerView? = null
|
||||||
|
private var videoUrl: String? = null
|
||||||
|
private var tvViewModel: TVViewModel? = null
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
_binding = PlayerBinding.inflate(inflater, container, false)
|
||||||
|
playerView = _binding!!.playerView
|
||||||
|
(activity as MainActivity).playerFragment = this
|
||||||
|
playerView?.viewTreeObserver?.addOnGlobalLayoutListener(object :
|
||||||
|
ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
playerView!!.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
playerView!!.player = activity?.let {
|
||||||
|
ExoPlayer.Builder(it)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
playerView!!.player?.playWhenReady = true
|
||||||
|
playerView!!.player?.addListener(object : Player.Listener {
|
||||||
|
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
||||||
|
val aspectRatio = 16f / 9f
|
||||||
|
val layoutParams = playerView?.layoutParams
|
||||||
|
layoutParams?.width =
|
||||||
|
(playerView?.measuredHeight?.times(aspectRatio))?.toInt()
|
||||||
|
playerView?.layoutParams = layoutParams
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// override fun onPlayerError(error: PlaybackException) {
|
||||||
|
// super.onPlayerError(error)
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
if (videoUrl !== null) {
|
||||||
|
playerView!!.player?.run {
|
||||||
|
videoUrl?.let { MediaItem.fromUri(it) }?.let { setMediaItem(it) }
|
||||||
|
prepare()
|
||||||
|
}
|
||||||
|
videoUrl = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Log.i(TAG, "PlayerFragment onCreateView")
|
||||||
|
return _binding!!.root
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
|
fun play(tvViewModel: TVViewModel) {
|
||||||
|
this.tvViewModel = tvViewModel
|
||||||
|
val videoUrlCurrent =
|
||||||
|
tvViewModel.videoIndex.value?.let { tvViewModel.videoUrl.value?.get(it) }
|
||||||
|
if (playerView == null || playerView?.player == null) {
|
||||||
|
Log.i(TAG, "playerView not ready $view}")
|
||||||
|
videoUrl = videoUrlCurrent
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "playerView ok")
|
||||||
|
playerView?.player?.run {
|
||||||
|
val mediaItem = MediaItem.Builder()
|
||||||
|
tvViewModel.id.value?.let { mediaItem.setMediaId(it.toString()) }
|
||||||
|
videoUrlCurrent?.let { mediaItem.setUri(it) }
|
||||||
|
setMediaItem(mediaItem.build())
|
||||||
|
prepare()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
if (playerView != null) {
|
||||||
|
playerView!!.player?.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
if (playerView != null) {
|
||||||
|
playerView!!.player?.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
if (playerView != null) {
|
||||||
|
playerView!!.player?.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "PlaybackVideoFragment"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import android.os.Handler
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.lizongying.mytv.Utils.getDateFormat
|
||||||
import com.lizongying.mytv.api.ApiClient
|
import com.lizongying.mytv.api.ApiClient
|
||||||
import com.lizongying.mytv.api.BtraceClient
|
import com.lizongying.mytv.api.BtraceClient
|
||||||
import com.lizongying.mytv.api.LiveInfo
|
import com.lizongying.mytv.api.LiveInfo
|
||||||
@@ -20,9 +21,6 @@ import com.lizongying.mytv.proto.Ysp.cn.yangshipin.omstv.common.proto.epgProgram
|
|||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
import javax.crypto.spec.IvParameterSpec
|
import javax.crypto.spec.IvParameterSpec
|
||||||
import javax.crypto.spec.SecretKeySpec
|
import javax.crypto.spec.SecretKeySpec
|
||||||
@@ -34,6 +32,7 @@ class Request(var context: Context) {
|
|||||||
private var yspBtraceService: YSPBtraceService? = null
|
private var yspBtraceService: YSPBtraceService? = null
|
||||||
private var yspProtoService: YSPProtoService? = null
|
private var yspProtoService: YSPProtoService? = null
|
||||||
|
|
||||||
|
// TODO onDestroy
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
private lateinit var myRunnable: MyRunnable
|
private lateinit var myRunnable: MyRunnable
|
||||||
|
|
||||||
@@ -175,13 +174,13 @@ class Request(var context: Context) {
|
|||||||
livepid = pid,
|
livepid = pid,
|
||||||
sUrl = "https://www.yangshipin.cn/#/tv/home?pid=$pid",
|
sUrl = "https://www.yangshipin.cn/#/tv/home?pid=$pid",
|
||||||
playno = ysp?.getRand()!!,
|
playno = ysp?.getRand()!!,
|
||||||
ftime = getCurrentDate2(),
|
ftime = getDateFormat("yyyy-MM-dd HH:mm:ss"),
|
||||||
seq = tvModel.seq.toString(),
|
seq = tvModel.seq.toString(),
|
||||||
)
|
)
|
||||||
?.enqueue(object : Callback<Void> {
|
?.enqueue(object : Callback<Void> {
|
||||||
override fun onResponse(call: Call<Void>, response: Response<Void>) {
|
override fun onResponse(call: Call<Void>, response: Response<Void>) {
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
// Log.i(TAG, "$title kvcollect success")
|
Log.d(TAG, "$title kvcollect success")
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "$title kvcollect status error")
|
Log.e(TAG, "$title kvcollect status error")
|
||||||
tvModel.firstSource()
|
tvModel.firstSource()
|
||||||
@@ -238,20 +237,9 @@ class Request(var context: Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentDate(): String {
|
fun fetchProgram(tvViewModel: TVViewModel) {
|
||||||
val currentDate = Date()
|
val title = tvViewModel.title.value
|
||||||
val formatter = SimpleDateFormat("yyyyMMdd", Locale.CHINA)
|
yspProtoService?.getProgram(tvViewModel.programId.value!!, getDateFormat("yyyyMMdd"))
|
||||||
return formatter.format(currentDate)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCurrentDate2(): String {
|
|
||||||
val currentDate = Date()
|
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
|
|
||||||
return formatter.format(currentDate)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fetchProgram(tvModel: TVViewModel) {
|
|
||||||
yspProtoService?.getProgram(tvModel.programId.value!!, getCurrentDate())
|
|
||||||
?.enqueue(object : Callback<epgProgramModel.Response> {
|
?.enqueue(object : Callback<epgProgramModel.Response> {
|
||||||
override fun onResponse(
|
override fun onResponse(
|
||||||
call: Call<epgProgramModel.Response>,
|
call: Call<epgProgramModel.Response>,
|
||||||
@@ -260,13 +248,14 @@ class Request(var context: Context) {
|
|||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
val program = response.body()
|
val program = response.body()
|
||||||
if (program != null) {
|
if (program != null) {
|
||||||
tvModel.addProgram(program.dataListList)
|
tvViewModel.addProgram(program.dataListList)
|
||||||
|
Log.i(TAG, "$title program ${program.dataListList.size}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(call: Call<epgProgramModel.Response>, t: Throwable) {
|
override fun onFailure(call: Call<epgProgramModel.Response>, t: Throwable) {
|
||||||
Log.e(TAG, "Program request failed", t)
|
Log.e(TAG, "$title program request failed $t")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ CCTV14 少儿,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226193/inde
|
|||||||
CCTV15 音乐,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225785/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/2ceee92188ef684efe0d8b90839c4f3ad450d179dc64d59beff417059453af47.png?imageMogr2/format/webp,600001815,2000205003
|
CCTV15 音乐,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225785/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/2ceee92188ef684efe0d8b90839c4f3ad450d179dc64d59beff417059453af47.png?imageMogr2/format/webp,600001815,2000205003
|
||||||
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,https://resources.yangshipin.cn/assets/oms/image/202306/53793fa7bacd3a93ff6dc5d2758418985e1f952a316c335d663b572d8bdcd74d.png?imageMogr2/format/webp,600098637,2012375003
|
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,https://resources.yangshipin.cn/assets/oms/image/202306/53793fa7bacd3a93ff6dc5d2758418985e1f952a316c335d663b572d8bdcd74d.png?imageMogr2/format/webp,600098637,2012375003
|
||||||
CCTV17 农业农村,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226198/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/ddef563072f8bad2bea5b9e52674cb7b4ed50efb20c26e61994dfbdf05c1e3c0.png?imageMogr2/format/webp,600001810,2000204203
|
CCTV17 农业农村,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226198/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/ddef563072f8bad2bea5b9e52674cb7b4ed50efb20c26e61994dfbdf05c1e3c0.png?imageMogr2/format/webp,600001810,2000204203
|
||||||
|
CGTN,http://live.cgtn.com/1000/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/a72dff758ca1c17cd0ecc8cedc11b893d208f409d5e6302faa0e9d298848abc3.png?imageMogr2/format/webp,600014550,2001656803
|
||||||
|
CGTN 法语频道,https://livefr.cgtn.com/1000f/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/a8d0046a47433d952bf6ed17062deb8bd2184ba9aec0f7781df6bf9487a3ffcf.png?imageMogr2/format/webp,600084704,2010153503
|
||||||
|
CGTN 俄语频道,http://liveru.cgtn.com/1000r/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/bf0a820893cbaf20dd0333e27042e1ef9c8806e5b602b6a8c95af399db0bc77a.png?imageMogr2/format/webp,600084758,2010152603
|
||||||
|
CGTN 阿拉伯语频道,http://livear.cgtn.com/1000a/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/2e44e2aa3e7a1cedf07fd0ae59fe69e86a60a2632660a006e3e9e7397b2d107e.png?imageMogr2/format/webp,600084782,2010155203
|
||||||
|
CGTN 西班牙语频道,http://livees.cgtn.com/500e/prog_index.m3u8;http://livees.cgtn.com/1000e/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202309/7c337e3dbe64402ec7e4678a619a4a6d95144e42f35161181ff78e143b7cf67a.png?imageMogr2/format/webp,600084744,2010152503
|
||||||
|
CGTN 纪录频道,https://livedoc.cgtn.com/500d/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202309/74d3ac436a7e374879578de1d87a941fbf566d39d5632b027c5097891ed32bd5.png?imageMogr2/format/webp,600084781,2010155403
|
||||||
电视指南,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226987/index.m3u8
|
电视指南,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226987/index.m3u8
|
||||||
风云足球,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226984/index.m3u8
|
风云足球,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226984/index.m3u8
|
||||||
风云剧场,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226950/index.m3u8
|
风云剧场,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226950/index.m3u8
|
||||||
@@ -40,12 +46,6 @@ CCTV17 农业农村,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/322122619
|
|||||||
兵器科技,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226975/index.m3u8
|
兵器科技,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226975/index.m3u8
|
||||||
高尔夫网球,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226978/index.m3u8
|
高尔夫网球,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226978/index.m3u8
|
||||||
央视文化精品,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226981/index.m3u8
|
央视文化精品,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226981/index.m3u8
|
||||||
CGTN,http://live.cgtn.com/1000/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/a72dff758ca1c17cd0ecc8cedc11b893d208f409d5e6302faa0e9d298848abc3.png?imageMogr2/format/webp,600014550,2001656803
|
|
||||||
CGTN 法语频道,https://livefr.cgtn.com/1000f/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/a8d0046a47433d952bf6ed17062deb8bd2184ba9aec0f7781df6bf9487a3ffcf.png?imageMogr2/format/webp,600084704,2010153503
|
|
||||||
CGTN 俄语频道,http://liveru.cgtn.com/1000r/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/bf0a820893cbaf20dd0333e27042e1ef9c8806e5b602b6a8c95af399db0bc77a.png?imageMogr2/format/webp,600084758,2010152603
|
|
||||||
CGTN 阿拉伯语频道,http://livear.cgtn.com/1000a/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/2e44e2aa3e7a1cedf07fd0ae59fe69e86a60a2632660a006e3e9e7397b2d107e.png?imageMogr2/format/webp,600084782,2010155203
|
|
||||||
CGTN 西班牙语频道,http://livees.cgtn.com/500e/prog_index.m3u8;http://livees.cgtn.com/1000e/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202309/7c337e3dbe64402ec7e4678a619a4a6d95144e42f35161181ff78e143b7cf67a.png?imageMogr2/format/webp,600084744,2010152503
|
|
||||||
CGTN 纪录频道,https://livedoc.cgtn.com/500d/prog_index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202309/74d3ac436a7e374879578de1d87a941fbf566d39d5632b027c5097891ed32bd5.png?imageMogr2/format/webp,600084781,2010155403
|
|
||||||
|
|
||||||
地方频道
|
地方频道
|
||||||
东方卫视,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226217/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/9bd372ca292a82ce3aa08772b07efc4af1f85c21d1f268ea33440c49e9a0a488.png?imageMogr2/format/webp,600002483,2000292403
|
东方卫视,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226217/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/9bd372ca292a82ce3aa08772b07efc4af1f85c21d1f268ea33440c49e9a0a488.png?imageMogr2/format/webp,600002483,2000292403
|
||||||
@@ -69,6 +69,11 @@ CGTN 纪录频道,https://livedoc.cgtn.com/500d/prog_index.m3u8,https://resource
|
|||||||
四川卫视,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp,600002516,2000295003
|
四川卫视,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp,600002516,2000295003
|
||||||
东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp,600002484,2000292503
|
东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp,600002484,2000292503
|
||||||
海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp,600002506,2000291503
|
海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp,600002506,2000291503
|
||||||
|
|
||||||
|
移动专区
|
||||||
|
|
||||||
|
三沙卫视,https://pullsstv90080111.ssws.tv/live/SSTV20220729.m3u8
|
||||||
|
|
||||||
天津卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221225740/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226204/index.m3u8
|
天津卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221225740/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226204/index.m3u8
|
||||||
吉林卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226397/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225792/index.m3u8
|
吉林卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226397/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225792/index.m3u8
|
||||||
云南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226444/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225751/index.m3u8
|
云南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226444/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225751/index.m3u8
|
||||||
@@ -84,9 +89,9 @@ CGTN 纪录频道,https://livedoc.cgtn.com/500d/prog_index.m3u8,https://resource
|
|||||||
三沙卫视,https://pullsstv90080111.ssws.tv/live/SSTV20220729.m3u8
|
三沙卫视,https://pullsstv90080111.ssws.tv/live/SSTV20220729.m3u8
|
||||||
延边卫视,http://live.ybtvyun.com/video/s10006-44f040627ca1/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226220/index.m3u8
|
延边卫视,http://live.ybtvyun.com/video/s10006-44f040627ca1/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226220/index.m3u8
|
||||||
浙江少儿,http://hw-m-l.cztv.com/channels/lantian/channel008/1080p.m3u8
|
浙江少儿,http://hw-m-l.cztv.com/channels/lantian/channel008/1080p.m3u8
|
||||||
南京少儿,http://live.nbs.cn/channels/njtv/sepd/500k.m3u8
|
|
||||||
|
|
||||||
移动专区
|
|
||||||
|
|
||||||
CETV1,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225753/index.m3u8
|
CETV1,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225753/index.m3u8
|
||||||
CETV2,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225756/index.m3u8
|
CETV2,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225756/index.m3u8
|
||||||
CETV3,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226226/index.m3u8
|
CETV3,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226226/index.m3u8
|
||||||
@@ -161,6 +166,9 @@ CHC动作电影,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226465/in
|
|||||||
}
|
}
|
||||||
if (!i.contains(",")) {
|
if (!i.contains(",")) {
|
||||||
channel = i.trim()
|
channel = i.trim()
|
||||||
|
if (channel == "移动专区") {
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val p = i.split(",")
|
val p = i.split(",")
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.lizongying.mytv
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
object Utils {
|
||||||
|
fun getDateFormat(format: String): String {
|
||||||
|
return SimpleDateFormat(format, Locale.CHINA).format(Date())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDateTimestamp(): Int {
|
||||||
|
return (Date().time / 1000).toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,13 @@ package com.lizongying.mytv.api
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
import com.lizongying.mytv.Encryptor
|
import com.lizongying.mytv.Encryptor
|
||||||
import com.lizongying.mytv.MainActivity
|
import com.lizongying.mytv.MainActivity
|
||||||
import com.lizongying.mytv.models.TVViewModel
|
import com.lizongying.mytv.models.TVViewModel
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
class YSP(var context: Context) {
|
class YSP(var context: Context) {
|
||||||
private var cnlid = ""
|
private var cnlid = ""
|
||||||
@@ -87,14 +89,8 @@ class YSP(var context: Context) {
|
|||||||
|
|
||||||
fun generateGuid(): String {
|
fun generateGuid(): String {
|
||||||
val timestamp = (System.currentTimeMillis()).toString(36)
|
val timestamp = (System.currentTimeMillis()).toString(36)
|
||||||
val originalString = Math.random().toString()
|
val randomPart = Random.nextLong().toString(36).take(11)
|
||||||
val resultString = if (originalString.startsWith("0.")) {
|
return timestamp + "_" + "0".repeat(11 - randomPart.length) + randomPart
|
||||||
originalString.substring(2)
|
|
||||||
} else {
|
|
||||||
originalString
|
|
||||||
}
|
|
||||||
val randomPart = resultString.toLong().toString(36)
|
|
||||||
return timestamp + "_" + randomPart
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGuid(): String {
|
fun getGuid(): String {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import androidx.media3.common.MediaItem
|
|||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.datasource.DefaultHttpDataSource
|
import androidx.media3.datasource.DefaultHttpDataSource
|
||||||
import androidx.media3.exoplayer.hls.HlsMediaSource
|
import androidx.media3.exoplayer.hls.HlsMediaSource
|
||||||
import com.lizongying.mytv.CustomLoadErrorHandlingPolicy
|
|
||||||
import com.lizongying.mytv.TV
|
import com.lizongying.mytv.TV
|
||||||
|
import com.lizongying.mytv.Utils.getDateTimestamp
|
||||||
import com.lizongying.mytv.proto.Ysp.cn.yangshipin.omstv.common.proto.programModel.Program
|
import com.lizongying.mytv.proto.Ysp.cn.yangshipin.omstv.common.proto.programModel.Program
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@@ -232,6 +232,8 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
private var rowPosition: Int = 0
|
private var rowPosition: Int = 0
|
||||||
private var itemPosition: Int = 0
|
private var itemPosition: Int = 0
|
||||||
|
|
||||||
|
var programUpdateTime: Int = 0
|
||||||
|
|
||||||
private val _programId = MutableLiveData<String>()
|
private val _programId = MutableLiveData<String>()
|
||||||
val programId: LiveData<String>
|
val programId: LiveData<String>
|
||||||
get() = _programId
|
get() = _programId
|
||||||
@@ -325,7 +327,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
_title.value = tv.title
|
_title.value = tv.title
|
||||||
_videoUrl.value = tv.videoUrl
|
_videoUrl.value = tv.videoUrl
|
||||||
_videoIndex.value = tv.videoIndex
|
_videoIndex.value = tv.videoIndex
|
||||||
Log.i(TAG, "tv.title ${tv.title} ${mappingLogo[tv.title]}")
|
Log.d(TAG, "${tv.title} ${mappingLogo[tv.title]}")
|
||||||
if (mappingLogo[tv.title] != null) {
|
if (mappingLogo[tv.title] != null) {
|
||||||
_logo.value = mappingLogo[tv.title]
|
_logo.value = mappingLogo[tv.title]
|
||||||
}
|
}
|
||||||
@@ -377,10 +379,10 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
return mapping[tv.title]
|
return mapping[tv.title]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProgram(): MutableList<Program>? {
|
// fun getProgram(): MutableList<Program>? {
|
||||||
_program.value = (_program.value?.filter { it.et > (Date().time / 1000) })?.toMutableList()
|
// _program.value = (_program.value?.filter { it.et > (Date().time / 1000) })?.toMutableList()
|
||||||
return _program.value?.subList(0, 2)
|
// return _program.value?.subList(0, 2)
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun getProgramOne(): Program? {
|
fun getProgramOne(): Program? {
|
||||||
val programNew = (_program.value?.filter { it.et > (Date().time / 1000) })?.toMutableList()
|
val programNew = (_program.value?.filter { it.et > (Date().time / 1000) })?.toMutableList()
|
||||||
@@ -394,7 +396,10 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addProgram(p: MutableList<Program>) {
|
fun addProgram(p: MutableList<Program>) {
|
||||||
val p1 = (p.filter { it.et > (Date().time / 1000) }).toMutableList()
|
val timestamp = getDateTimestamp()
|
||||||
|
|
||||||
|
// after now & not empty & different
|
||||||
|
val p1 = (p.filter { it.et > timestamp }).toMutableList()
|
||||||
if (p1.isEmpty() || _program.value == p1) {
|
if (p1.isEmpty() || _program.value == p1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -403,7 +408,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
_program.value = p1
|
_program.value = p1
|
||||||
} else {
|
} else {
|
||||||
_program.value =
|
_program.value =
|
||||||
((_program.value?.filter { it.et > (Date().time / 1000) && it.st < p1.first().st })?.plus(
|
((_program.value?.filter { it.et > timestamp && it.st < p1.first().st })?.plus(
|
||||||
p1
|
p1
|
||||||
))?.toMutableList()
|
))?.toMutableList()
|
||||||
}
|
}
|
||||||
@@ -416,7 +421,6 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
mHeaders = headers
|
mHeaders = headers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setMinimumLoadableRetryCount(minimumLoadableRetryCount: Int) {
|
fun setMinimumLoadableRetryCount(minimumLoadableRetryCount: Int) {
|
||||||
mMinimumLoadableRetryCount = minimumLoadableRetryCount
|
mMinimumLoadableRetryCount = minimumLoadableRetryCount
|
||||||
}
|
}
|
||||||
@@ -426,9 +430,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
val httpDataSource = DefaultHttpDataSource.Factory()
|
val httpDataSource = DefaultHttpDataSource.Factory()
|
||||||
mHeaders?.let { httpDataSource.setDefaultRequestProperties(it) }
|
mHeaders?.let { httpDataSource.setDefaultRequestProperties(it) }
|
||||||
|
|
||||||
return HlsMediaSource.Factory(httpDataSource).setLoadErrorHandlingPolicy(
|
return HlsMediaSource.Factory(httpDataSource).createMediaSource(
|
||||||
CustomLoadErrorHandlingPolicy(mMinimumLoadableRetryCount)
|
|
||||||
).createMediaSource(
|
|
||||||
MediaItem.fromUri(
|
MediaItem.fromUri(
|
||||||
Uri.parse(videoUrl)
|
Uri.parse(videoUrl)
|
||||||
)
|
)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
<corners android:radius="4dp" /> <!-- Adjust the radius as needed -->
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#FF263238" />
|
||||||
|
<corners android:radius="4dp" /> <!-- Adjust the radius as needed -->
|
||||||
|
</shape>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -5,15 +5,50 @@
|
|||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_gravity="center_horizontal|bottom"
|
android:layout_gravity="center_horizontal|bottom"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:background="@color/fastlane_background"
|
android:background="@drawable/rounded_background">
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/info_logo"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal|top"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginTop="10dp"
|
android:contentDescription="@string/logo"
|
||||||
android:textSize="40sp"
|
android:padding="10dp" />
|
||||||
/>
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="216dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="100dp"
|
||||||
|
android:background="#FF263238"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="7dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="#FFEEEEEE"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/info_desc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="#B3EEEEEE"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="8dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:background="@drawable/rounded_background2" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/player_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"
|
||||||
|
android:keepScreenOn="true">
|
||||||
|
|
||||||
|
<androidx.media3.ui.PlayerView
|
||||||
|
android:id="@+id/player_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:resize_mode="fill"
|
||||||
|
app:use_controller="false" />
|
||||||
|
</FrameLayout>
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Must be kept in sync with AspectRatioFrameLayout -->
|
||||||
|
<attr name="resize_mode" format="enum">
|
||||||
|
<enum name="fit" value="0"/>
|
||||||
|
<enum name="fixed_width" value="1"/>
|
||||||
|
<enum name="fixed_height" value="2"/>
|
||||||
|
<enum name="fill" value="3"/>
|
||||||
|
<enum name="zoom" value="4"/>
|
||||||
|
</attr>
|
||||||
|
|
||||||
|
<!-- Must be kept in sync with LegacyPlayerView and PlayerView -->
|
||||||
|
<attr name="surface_type" format="enum">
|
||||||
|
<enum name="none" value="0"/>
|
||||||
|
<enum name="surface_view" value="1"/>
|
||||||
|
<enum name="texture_view" value="2"/>
|
||||||
|
<enum name="spherical_gl_surface_view" value="3"/>
|
||||||
|
<enum name="video_decoder_gl_surface_view" value="4"/>
|
||||||
|
</attr>
|
||||||
|
|
||||||
|
<!-- Must be kept in sync with RepeatModeUtil -->
|
||||||
|
<attr name="repeat_toggle_modes">
|
||||||
|
<flag name="none" value="0"/>
|
||||||
|
<flag name="one" value="1"/>
|
||||||
|
<flag name="all" value="2"/>
|
||||||
|
</attr>
|
||||||
|
|
||||||
|
<!-- LegacyPlayerView and PlayerView attributes -->
|
||||||
|
<attr name="use_artwork" format="boolean"/>
|
||||||
|
<attr name="artwork_display_mode" format="enum">
|
||||||
|
<enum name="off" value="0"/>
|
||||||
|
<enum name="fit" value="1"/>
|
||||||
|
<enum name="fill" value="2"/>
|
||||||
|
</attr>
|
||||||
|
<attr name="shutter_background_color" format="color"/>
|
||||||
|
<attr name="default_artwork" format="reference"/>
|
||||||
|
<attr name="use_controller" format="boolean"/>
|
||||||
|
<attr name="hide_on_touch" format="boolean"/>
|
||||||
|
<attr name="hide_during_ads" format="boolean"/>
|
||||||
|
<attr name="auto_show" format="boolean"/>
|
||||||
|
<attr name="show_buffering" format="enum">
|
||||||
|
<enum name="never" value="0"/>
|
||||||
|
<enum name="when_playing" value="1"/>
|
||||||
|
<enum name="always" value="2"/>
|
||||||
|
</attr>
|
||||||
|
<attr name="keep_content_on_player_reset" format="boolean"/>
|
||||||
|
<attr name="player_layout_id" format="reference"/>
|
||||||
|
|
||||||
|
<!-- LegacyPlayerControlView and PlayerControlView attributes -->
|
||||||
|
<attr name="show_timeout" format="integer"/>
|
||||||
|
<attr name="show_rewind_button" format="boolean"/>
|
||||||
|
<attr name="show_fastforward_button" format="boolean"/>
|
||||||
|
<attr name="show_previous_button" format="boolean"/>
|
||||||
|
<attr name="show_next_button" format="boolean"/>
|
||||||
|
<attr name="show_shuffle_button" format="boolean"/>
|
||||||
|
<attr name="show_subtitle_button" format="boolean"/>
|
||||||
|
<attr name="show_vr_button" format="boolean"/>
|
||||||
|
<attr name="time_bar_min_update_interval" format="integer"/>
|
||||||
|
<attr name="controller_layout_id" format="reference"/>
|
||||||
|
<attr name="animation_enabled" format="boolean"/>
|
||||||
|
|
||||||
|
<!-- Needed for https://github.com/google/ExoPlayer/issues/7898 -->
|
||||||
|
<attr name="backgroundTint" format="color"/>
|
||||||
|
|
||||||
|
<!-- DefaultTimeBar attributes -->
|
||||||
|
<attr name="bar_height" format="dimension"/>
|
||||||
|
<attr name="bar_gravity" format="enum">
|
||||||
|
<enum name="center" value="0"/>
|
||||||
|
<enum name="bottom" value="1"/>
|
||||||
|
</attr>
|
||||||
|
<attr name="touch_target_height" format="dimension"/>
|
||||||
|
<attr name="ad_marker_width" format="dimension"/>
|
||||||
|
<attr name="scrubber_enabled_size" format="dimension"/>
|
||||||
|
<attr name="scrubber_disabled_size" format="dimension"/>
|
||||||
|
<attr name="scrubber_dragged_size" format="dimension"/>
|
||||||
|
<attr name="scrubber_drawable" format="reference"/>
|
||||||
|
<attr name="played_color" format="color"/>
|
||||||
|
<attr name="scrubber_color" format="color"/>
|
||||||
|
<attr name="buffered_color" format="color"/>
|
||||||
|
<attr name="unplayed_color" format="color"/>
|
||||||
|
<attr name="ad_marker_color" format="color"/>
|
||||||
|
<attr name="played_ad_marker_color" format="color"/>
|
||||||
|
|
||||||
|
<declare-styleable name="PlayerView">
|
||||||
|
<attr name="use_artwork"/>
|
||||||
|
<attr name="artwork_display_mode"/>
|
||||||
|
<attr name="shutter_background_color"/>
|
||||||
|
<attr name="default_artwork"/>
|
||||||
|
<attr name="use_controller"/>
|
||||||
|
<attr name="hide_on_touch"/>
|
||||||
|
<attr name="hide_during_ads"/>
|
||||||
|
<attr name="auto_show"/>
|
||||||
|
<attr name="show_buffering"/>
|
||||||
|
<attr name="keep_content_on_player_reset"/>
|
||||||
|
<attr name="player_layout_id"/>
|
||||||
|
<attr name="surface_type"/>
|
||||||
|
<!-- AspectRatioFrameLayout attributes -->
|
||||||
|
<attr name="resize_mode"/>
|
||||||
|
<!-- PlayerControlView attributes -->
|
||||||
|
<attr name="show_timeout"/>
|
||||||
|
<attr name="repeat_toggle_modes"/>
|
||||||
|
<attr name="show_shuffle_button"/>
|
||||||
|
<attr name="show_subtitle_button"/>
|
||||||
|
<attr name="show_vr_button"/>
|
||||||
|
<attr name="time_bar_min_update_interval"/>
|
||||||
|
<attr name="controller_layout_id"/>
|
||||||
|
<attr name="animation_enabled"/>
|
||||||
|
<!-- DefaultTimeBar attributes -->
|
||||||
|
<attr name="bar_height"/>
|
||||||
|
<attr name="bar_gravity"/>
|
||||||
|
<attr name="touch_target_height"/>
|
||||||
|
<attr name="ad_marker_width"/>
|
||||||
|
<attr name="scrubber_enabled_size"/>
|
||||||
|
<attr name="scrubber_disabled_size"/>
|
||||||
|
<attr name="scrubber_dragged_size"/>
|
||||||
|
<attr name="scrubber_drawable"/>
|
||||||
|
<attr name="played_color"/>
|
||||||
|
<attr name="scrubber_color"/>
|
||||||
|
<attr name="buffered_color" />
|
||||||
|
<attr name="unplayed_color"/>
|
||||||
|
<attr name="ad_marker_color"/>
|
||||||
|
<attr name="played_ad_marker_color"/>
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="AspectRatioFrameLayout">
|
||||||
|
<attr name="resize_mode"/>
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="LegacyPlayerControlView">
|
||||||
|
<attr name="show_timeout"/>
|
||||||
|
<attr name="repeat_toggle_modes"/>
|
||||||
|
<attr name="show_rewind_button"/>
|
||||||
|
<attr name="show_fastforward_button"/>
|
||||||
|
<attr name="show_previous_button"/>
|
||||||
|
<attr name="show_next_button"/>
|
||||||
|
<attr name="show_shuffle_button"/>
|
||||||
|
<attr name="time_bar_min_update_interval"/>
|
||||||
|
<attr name="controller_layout_id"/>
|
||||||
|
<!-- DefaultTimeBar attributes -->
|
||||||
|
<attr name="bar_height"/>
|
||||||
|
<attr name="bar_gravity"/>
|
||||||
|
<attr name="touch_target_height"/>
|
||||||
|
<attr name="ad_marker_width"/>
|
||||||
|
<attr name="scrubber_enabled_size"/>
|
||||||
|
<attr name="scrubber_disabled_size"/>
|
||||||
|
<attr name="scrubber_dragged_size"/>
|
||||||
|
<attr name="scrubber_drawable"/>
|
||||||
|
<attr name="played_color"/>
|
||||||
|
<attr name="scrubber_color"/>
|
||||||
|
<attr name="buffered_color" />
|
||||||
|
<attr name="unplayed_color"/>
|
||||||
|
<attr name="ad_marker_color"/>
|
||||||
|
<attr name="played_ad_marker_color"/>
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="PlayerControlView">
|
||||||
|
<attr name="show_timeout"/>
|
||||||
|
<attr name="repeat_toggle_modes"/>
|
||||||
|
<attr name="show_rewind_button"/>
|
||||||
|
<attr name="show_fastforward_button"/>
|
||||||
|
<attr name="show_previous_button"/>
|
||||||
|
<attr name="show_next_button"/>
|
||||||
|
<attr name="show_shuffle_button"/>
|
||||||
|
<attr name="show_subtitle_button"/>
|
||||||
|
<attr name="show_vr_button"/>
|
||||||
|
<attr name="time_bar_min_update_interval"/>
|
||||||
|
<attr name="controller_layout_id"/>
|
||||||
|
<attr name="animation_enabled"/>
|
||||||
|
<!-- DefaultTimeBar attributes -->
|
||||||
|
<attr name="bar_height"/>
|
||||||
|
<attr name="bar_gravity"/>
|
||||||
|
<attr name="touch_target_height"/>
|
||||||
|
<attr name="ad_marker_width"/>
|
||||||
|
<attr name="scrubber_enabled_size"/>
|
||||||
|
<attr name="scrubber_disabled_size"/>
|
||||||
|
<attr name="scrubber_dragged_size"/>
|
||||||
|
<attr name="scrubber_drawable"/>
|
||||||
|
<attr name="played_color"/>
|
||||||
|
<attr name="scrubber_color"/>
|
||||||
|
<attr name="buffered_color" />
|
||||||
|
<attr name="unplayed_color"/>
|
||||||
|
<attr name="ad_marker_color"/>
|
||||||
|
<attr name="played_ad_marker_color"/>
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="DefaultTimeBar">
|
||||||
|
<attr name="bar_height"/>
|
||||||
|
<attr name="bar_gravity"/>
|
||||||
|
<attr name="touch_target_height"/>
|
||||||
|
<attr name="ad_marker_width"/>
|
||||||
|
<attr name="scrubber_enabled_size"/>
|
||||||
|
<attr name="scrubber_disabled_size"/>
|
||||||
|
<attr name="scrubber_dragged_size"/>
|
||||||
|
<attr name="scrubber_drawable"/>
|
||||||
|
<attr name="played_color"/>
|
||||||
|
<attr name="scrubber_color"/>
|
||||||
|
<attr name="buffered_color" />
|
||||||
|
<attr name="unplayed_color"/>
|
||||||
|
<attr name="ad_marker_color"/>
|
||||||
|
<attr name="played_ad_marker_color"/>
|
||||||
|
</declare-styleable>
|
||||||
|
</resources>
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<color name="fastlane_background">#30000000</color>
|
<color name="fastlane_background">#30000000</color>
|
||||||
|
<color name="black">#000</color>
|
||||||
|
<color name="white">#FFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">My TV</string>
|
<string name="app_name">我的电视</string>
|
||||||
|
<string name="logo">logo</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -5,5 +5,4 @@
|
|||||||
<item name="browsePaddingEnd">11dp</item>
|
<item name="browsePaddingEnd">11dp</item>
|
||||||
<item name="browseRowsMarginTop">54dp</item>
|
<item name="browseRowsMarginTop">54dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
+1
-1
@@ -21,5 +21,5 @@ kotlin.code.style=official
|
|||||||
# resources declared in the library itself and none from the library's dependencies,
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
# thereby reducing the size of the R class for that library
|
# thereby reducing the size of the R class for that library
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
android.defaults.buildfeatures.buildconfig=true
|
#android.defaults.buildfeatures.buildconfig=true
|
||||||
android.nonFinalResIds=false
|
android.nonFinalResIds=false
|
||||||
Reference in New Issue
Block a user