Skip to content

Commit

Permalink
sz
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed May 17, 2024
1 parent 7954b1f commit 8a2a4ee
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 12 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## 更新日志

### v1.0.3

* 增加频道
* 优化样式
* 优化速度

### v1.0.0

* 基本视频播放
28 changes: 24 additions & 4 deletions app/src/main/java/com/lizongying/mytv1/WebFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lizongying.mytv1

import android.graphics.Bitmap
import android.net.Uri
import android.net.http.SslError
import android.os.Bundle
Expand All @@ -16,7 +17,6 @@ import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.Fragment
import com.lizongying.mytv1.databinding.InfoBinding
import com.lizongying.mytv1.databinding.PlayerBinding
import com.lizongying.mytv1.models.TVModel

Expand Down Expand Up @@ -79,6 +79,10 @@ class WebFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

webView.webChromeClient = object : WebChromeClient() {
override fun getDefaultVideoPoster(): Bitmap {
return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
}

override fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
if (consoleMessage != null) {
Log.e(
Expand Down Expand Up @@ -182,10 +186,28 @@ class WebFragment : Fragment() {
}
}
}

"www.sztv.com.cn" -> {
webView.evaluateJavascript(context.resources.openRawResource(R.raw.sztv)
.bufferedReader()
.use { it.readText() }) { value ->
if (value == "success") {
Log.e(TAG, "success")
}
}
}
"news.hbtv.com.cn" -> {
webView.evaluateJavascript(context.resources.openRawResource(R.raw.hbtv)
.bufferedReader()
.use { it.readText() }) { value ->
if (value == "success") {
Log.e(TAG, "success")
}
}
}
}
}
}
// var url = "https://www.yangshipin.cn/#/tv/home?pid=600002513"
}

fun play(tvModel: TVModel) {
Expand All @@ -205,11 +227,9 @@ class WebFragment : Fragment() {
"localStorage.setItem('cctv_live_resolution', '720');",
null
)
webView.loadUrl(url)
}

"www.gdtv.cn" -> {
webView.loadUrl(url)
}

"www.yangshipin.cn" -> {
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/raw/cctv.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
body.style.left = '100%';
body.style.backgroundColor = '#000';

const count = 0;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.attributes.controls = 'false';
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = "100vw";
Expand All @@ -23,7 +25,12 @@
clearInterval(interval);
setTimeout(function () {
console.log('success');
}, 500)
}, 0)
}
count ++;
if (count > 6 * 1000) {
clearInterval(interval);
console.log('timeout');
}
}, 10);
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/channels.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions app/src/main/res/raw/gdtv.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
divElement.style.zIndex = '9998';
document.body.appendChild(divElement);

const count = 0;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.attributes.controls = 'false';
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = "100vw";
Expand All @@ -30,6 +32,11 @@
console.log('success');
}, 0)
}
count ++;
if (count > 6 * 1000) {
clearInterval(interval);
console.log('timeout');
}
}, 10);
});
})()
32 changes: 32 additions & 0 deletions app/src/main/res/raw/hbtv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function () {
return new Promise(function (resolve, reject) {
const body = document.querySelector('body');
body.style.position = 'fixed';
body.style.left = '100%';
body.style.backgroundColor = '#000';

const count = 0;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.attributes.controls = 'false';
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = "100vw";
video.style.height = "100vh";
video.style.top = '0';
video.style.left = '0';
video.style.zIndex = '9999';
clearInterval(interval);
setTimeout(function () {
console.log('success');
}, 0)
}
count ++;
if (count > 6 * 1000) {
clearInterval(interval);
console.log('timeout');
}
}, 10);
});
})()
32 changes: 32 additions & 0 deletions app/src/main/res/raw/sztv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function () {
return new Promise(function (resolve, reject) {
const body = document.querySelector('body');
body.style.position = 'fixed';
body.style.left = '100%';
body.style.backgroundColor = '#000';

const count = 0;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.attributes.controls = 'false';
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = "100vw";
video.style.height = "100vh";
video.style.top = '0';
video.style.left = '0';
video.style.zIndex = '9999';
clearInterval(interval);
setTimeout(function () {
console.log('success');
}, 0)
}
count ++;
if (count > 6 * 1000) {
clearInterval(interval);
console.log('timeout');
}
}, 10);
});
})()
8 changes: 3 additions & 5 deletions app/src/main/res/raw/ysp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function () {
return new Promise(function (resolve, reject) {
// window.location.reload(true);

const divElement = document.createElement('div');
divElement.style.position = 'fixed';
divElement.style.top = '0';
Expand All @@ -12,14 +10,14 @@
divElement.style.zIndex = '9998';
document.body.appendChild(divElement);

const height = document.documentElement.clientHeight;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.attributes.controls = 'false';
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = height * 16 / 9 + 'px';
video.style.height = height + 'px';
video.style.width = "100vw";
video.style.height = "100vh";
video.style.top = '0';
video.style.left = '0';
video.style.zIndex = '9999';
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 16777216, "version_name": "v1.0.0"}
{"version_code": 16777984, "version_name": "v1.0.3"}

0 comments on commit 8a2a4ee

Please sign in to comment.