htmlplayer 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/PKG-INFO +20 -3
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/README.md +19 -2
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer/__init__.py +1 -1
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer/core.py +20 -17
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer/examples/advanced_example.py +18 -9
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer/examples/simple_example.py +7 -8
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer.egg-info/PKG-INFO +20 -3
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/pyproject.toml +1 -1
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/setup.py +1 -1
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/MANIFEST.in +0 -0
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer/examples/__init__.py +0 -0
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer.egg-info/SOURCES.txt +0 -0
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer.egg-info/dependency_links.txt +0 -0
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/htmlplayer.egg-info/top_level.txt +0 -0
- {htmlplayer-0.1.2 → htmlplayer-0.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlplayer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: 一个简单的HTML视频播放器,使用Edge浏览器或系统默认浏览器播放视频
|
|
5
5
|
Home-page: https://github.com/yourusername/htmlplayer
|
|
6
6
|
Author: lenvy1
|
|
@@ -93,9 +93,26 @@ play_with_browser('https://example.com/video.mp4')
|
|
|
93
93
|
|
|
94
94
|
查找Microsoft Edge浏览器的安装路径。
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
**返回:**
|
|
97
|
+
- `str` or `None`: Edge浏览器的安装路径,若未找到返回None
|
|
98
|
+
|
|
99
|
+
### calculate_window_size(width=None, height=None, scale=None)
|
|
100
|
+
|
|
101
|
+
根据输入的宽高计算合适的窗口大小(严格等比缩放)。
|
|
102
|
+
|
|
103
|
+
**参数:**
|
|
104
|
+
- `width` (int/float, optional): 目标宽度(像素),不传则自动检测屏幕宽度
|
|
105
|
+
- `height` (int/float, optional): 目标高度(像素),不传则自动检测屏幕高度
|
|
106
|
+
- `scale` (float, optional): 窗口相对于输入尺寸的缩放比例,默认None表示自动计算
|
|
107
|
+
|
|
108
|
+
**返回:**
|
|
109
|
+
- `tuple`: 包含窗口宽度和高度的元组 (final_width, final_height)
|
|
97
110
|
|
|
98
|
-
|
|
111
|
+
**自动缩放规则:**
|
|
112
|
+
- 竖屏视频 (宽高比 <= 0.6): 自动使用 90% 尺寸
|
|
113
|
+
- 高度 >= 1080: 自动使用 50% 尺寸
|
|
114
|
+
- 高度 >= 720: 自动使用 60% 尺寸
|
|
115
|
+
- 高度 >= 480: 自动使用 100% 尺寸
|
|
99
116
|
|
|
100
117
|
## 系统要求
|
|
101
118
|
|
|
@@ -69,9 +69,26 @@ play_with_browser('https://example.com/video.mp4')
|
|
|
69
69
|
|
|
70
70
|
查找Microsoft Edge浏览器的安装路径。
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
**返回:**
|
|
73
|
+
- `str` or `None`: Edge浏览器的安装路径,若未找到返回None
|
|
74
|
+
|
|
75
|
+
### calculate_window_size(width=None, height=None, scale=None)
|
|
76
|
+
|
|
77
|
+
根据输入的宽高计算合适的窗口大小(严格等比缩放)。
|
|
78
|
+
|
|
79
|
+
**参数:**
|
|
80
|
+
- `width` (int/float, optional): 目标宽度(像素),不传则自动检测屏幕宽度
|
|
81
|
+
- `height` (int/float, optional): 目标高度(像素),不传则自动检测屏幕高度
|
|
82
|
+
- `scale` (float, optional): 窗口相对于输入尺寸的缩放比例,默认None表示自动计算
|
|
83
|
+
|
|
84
|
+
**返回:**
|
|
85
|
+
- `tuple`: 包含窗口宽度和高度的元组 (final_width, final_height)
|
|
73
86
|
|
|
74
|
-
|
|
87
|
+
**自动缩放规则:**
|
|
88
|
+
- 竖屏视频 (宽高比 <= 0.6): 自动使用 90% 尺寸
|
|
89
|
+
- 高度 >= 1080: 自动使用 50% 尺寸
|
|
90
|
+
- 高度 >= 720: 自动使用 60% 尺寸
|
|
91
|
+
- 高度 >= 480: 自动使用 100% 尺寸
|
|
75
92
|
|
|
76
93
|
## 系统要求
|
|
77
94
|
|
|
@@ -15,48 +15,51 @@ def find_edge_browser():
|
|
|
15
15
|
return None
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def calculate_window_size(width, height, scale=
|
|
18
|
+
def calculate_window_size(width=None, height=None, scale=None):
|
|
19
19
|
"""
|
|
20
20
|
根据输入的宽高计算合适的窗口大小(严格等比缩放)
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
参数:
|
|
23
|
-
width (int/float):
|
|
24
|
-
height (int/float):
|
|
25
|
-
scale (float): 窗口相对于输入尺寸的缩放比例,默认
|
|
26
|
-
|
|
23
|
+
width (int/float, optional): 目标宽度(像素),不传则自动检测屏幕宽度
|
|
24
|
+
height (int/float, optional): 目标高度(像素),不传则自动检测屏幕高度
|
|
25
|
+
scale (float, optional): 窗口相对于输入尺寸的缩放比例,默认None表示自动计算
|
|
26
|
+
|
|
27
27
|
返回:
|
|
28
28
|
tuple: 包含窗口宽度和高度的元组 (final_width, final_height),均为真实的浮点数
|
|
29
29
|
"""
|
|
30
|
-
# 1. 跨平台自动检测屏幕分辨率
|
|
31
30
|
if width is None or height is None:
|
|
32
31
|
try:
|
|
33
32
|
import tkinter as tk
|
|
34
33
|
root = tk.Tk()
|
|
35
|
-
root.withdraw()
|
|
34
|
+
root.withdraw()
|
|
36
35
|
width = root.winfo_screenwidth()
|
|
37
36
|
height = root.winfo_screenheight()
|
|
38
37
|
root.destroy()
|
|
39
38
|
except Exception as e:
|
|
40
|
-
raise RuntimeError(f"无法自动获取屏幕分辨率,请手动传入
|
|
41
|
-
|
|
39
|
+
raise RuntimeError(f"无法自动获取屏幕分辨率,请手动传入 width 和 height。错误信息: {e}")
|
|
40
|
+
|
|
42
41
|
target_ratio = width / height
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
# 竖屏视频(如 9:16,比例约为 0.56)若按默认比例缩放会导致画面过小,因此放大显示
|
|
43
|
+
auto_scale = 0.5
|
|
46
44
|
if target_ratio <= 0.6:
|
|
47
|
-
|
|
45
|
+
auto_scale = 0.9
|
|
46
|
+
elif height >= 1080:
|
|
47
|
+
auto_scale = 0.5
|
|
48
|
+
elif height >= 720:
|
|
49
|
+
auto_scale = 0.6
|
|
50
|
+
elif height >= 480:
|
|
51
|
+
auto_scale = 1.0
|
|
52
|
+
|
|
53
|
+
if scale is None:
|
|
54
|
+
scale = auto_scale
|
|
48
55
|
|
|
49
|
-
# 4. 计算允许的最大边界
|
|
50
56
|
max_width = width * scale
|
|
51
57
|
max_height = height * scale
|
|
52
58
|
|
|
53
|
-
# 5. 核心等比缩放计算(取最小限制比例,确保不超出屏幕且保持绝对比例)
|
|
54
59
|
if max_width / target_ratio <= max_height:
|
|
55
|
-
# 宽度先触达边界,以宽度为基准计算高度
|
|
56
60
|
final_width = max_width
|
|
57
61
|
final_height = max_width / target_ratio
|
|
58
62
|
else:
|
|
59
|
-
# 高度先触达边界,以高度为基准计算宽度
|
|
60
63
|
final_height = max_height
|
|
61
64
|
final_width = max_height * target_ratio
|
|
62
65
|
|
|
@@ -11,10 +11,10 @@ def check_edge_availability():
|
|
|
11
11
|
"""检查Edge浏览器是否可用"""
|
|
12
12
|
edge_path = find_edge_browser()
|
|
13
13
|
if edge_path:
|
|
14
|
-
print(f"
|
|
14
|
+
print(f"Edge浏览器可用: {edge_path}")
|
|
15
15
|
return True
|
|
16
16
|
else:
|
|
17
|
-
print("
|
|
17
|
+
print("Edge浏览器未找到")
|
|
18
18
|
return False
|
|
19
19
|
|
|
20
20
|
|
|
@@ -22,23 +22,32 @@ def demo_window_calculation():
|
|
|
22
22
|
"""演示窗口大小计算"""
|
|
23
23
|
print("\n窗口大小计算演示:")
|
|
24
24
|
print("-" * 30)
|
|
25
|
-
|
|
26
|
-
#
|
|
25
|
+
|
|
26
|
+
# 自动检测屏幕尺寸并计算默认窗口大小
|
|
27
27
|
width, height = calculate_window_size()
|
|
28
28
|
print(f"默认窗口大小: {int(width)}x{int(height)}")
|
|
29
29
|
|
|
30
|
+
# 指定输入尺寸自动计算缩放
|
|
31
|
+
for test_w, test_h in [(1920, 1080), (1280, 720), (640, 480), (1080, 1920)]:
|
|
32
|
+
w, h = calculate_window_size(width=test_w, height=test_h)
|
|
33
|
+
print(f"输入 {test_w}x{test_h} -> 窗口 {int(w)}x{int(h)}")
|
|
34
|
+
|
|
35
|
+
# 指定自定义缩放比例
|
|
36
|
+
w, h = calculate_window_size(width=1920, height=1080, scale=0.3)
|
|
37
|
+
print(f"自定义缩放 scale=0.3: {int(w)}x{int(h)}")
|
|
38
|
+
|
|
30
39
|
|
|
31
40
|
def demo_different_configs():
|
|
32
41
|
"""演示不同配置的播放"""
|
|
33
42
|
print("\n不同配置演示:")
|
|
34
43
|
print("-" * 30)
|
|
35
|
-
|
|
44
|
+
|
|
36
45
|
print("1. 仅Edge浏览器(无回退):")
|
|
37
46
|
print(" play_video(url, use_edge=True, use_browser_fallback=False)")
|
|
38
|
-
|
|
47
|
+
|
|
39
48
|
print("\n2. 强制使用系统浏览器:")
|
|
40
49
|
print(" play_video(url, use_edge=False, use_browser_fallback=True)")
|
|
41
|
-
|
|
50
|
+
|
|
42
51
|
print("\n3. 自定义窗口大小:")
|
|
43
52
|
print(" play_video(url, width=1920, height=1080)")
|
|
44
53
|
|
|
@@ -46,11 +55,11 @@ def demo_different_configs():
|
|
|
46
55
|
def main():
|
|
47
56
|
print("HTMLPlayer 高级示例")
|
|
48
57
|
print("=" * 50)
|
|
49
|
-
|
|
58
|
+
|
|
50
59
|
check_edge_availability()
|
|
51
60
|
demo_window_calculation()
|
|
52
61
|
demo_different_configs()
|
|
53
|
-
|
|
62
|
+
|
|
54
63
|
print("\n" + "=" * 50)
|
|
55
64
|
print("提示:参考 simple_example.py 来运行实际的视频播放")
|
|
56
65
|
|
|
@@ -9,26 +9,26 @@ from htmlplayer import play_video, play_with_edge, play_with_browser
|
|
|
9
9
|
def main():
|
|
10
10
|
print("HTMLPlayer 视频播放库 - 简单示例")
|
|
11
11
|
print("=" * 50)
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
print("\n1. 基础用法:")
|
|
14
14
|
print(" from htmlplayer import play_video")
|
|
15
15
|
print(" play_video('https://example.com/video.m3u8')")
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
print("\n2. 指定窗口大小:")
|
|
18
18
|
print(" play_video('https://example.com/video.m3u8', width=1280, height=720)")
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
print("\n3. 仅使用Edge浏览器:")
|
|
21
21
|
print(" from htmlplayer import play_with_edge")
|
|
22
22
|
print(" play_with_edge('https://example.com/video.m3u8')")
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
print("\n4. 使用系统默认浏览器:")
|
|
25
25
|
print(" from htmlplayer import play_with_browser")
|
|
26
26
|
print(" play_with_browser('https://example.com/video.m3u8')")
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
print("\n" + "=" * 50)
|
|
29
|
-
print("
|
|
29
|
+
print("提示:取消下面代码的注释可以实际运行一个示例")
|
|
30
30
|
print("=" * 50)
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# 实际演示(取消注释以运行)
|
|
33
33
|
# print("\n正在播放示例视频...")
|
|
34
34
|
# play_video('https://jx.xmflv.com/?url=https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8')
|
|
@@ -36,4 +36,3 @@ def main():
|
|
|
36
36
|
|
|
37
37
|
if __name__ == '__main__':
|
|
38
38
|
main()
|
|
39
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlplayer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: 一个简单的HTML视频播放器,使用Edge浏览器或系统默认浏览器播放视频
|
|
5
5
|
Home-page: https://github.com/yourusername/htmlplayer
|
|
6
6
|
Author: lenvy1
|
|
@@ -93,9 +93,26 @@ play_with_browser('https://example.com/video.mp4')
|
|
|
93
93
|
|
|
94
94
|
查找Microsoft Edge浏览器的安装路径。
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
**返回:**
|
|
97
|
+
- `str` or `None`: Edge浏览器的安装路径,若未找到返回None
|
|
98
|
+
|
|
99
|
+
### calculate_window_size(width=None, height=None, scale=None)
|
|
100
|
+
|
|
101
|
+
根据输入的宽高计算合适的窗口大小(严格等比缩放)。
|
|
102
|
+
|
|
103
|
+
**参数:**
|
|
104
|
+
- `width` (int/float, optional): 目标宽度(像素),不传则自动检测屏幕宽度
|
|
105
|
+
- `height` (int/float, optional): 目标高度(像素),不传则自动检测屏幕高度
|
|
106
|
+
- `scale` (float, optional): 窗口相对于输入尺寸的缩放比例,默认None表示自动计算
|
|
107
|
+
|
|
108
|
+
**返回:**
|
|
109
|
+
- `tuple`: 包含窗口宽度和高度的元组 (final_width, final_height)
|
|
97
110
|
|
|
98
|
-
|
|
111
|
+
**自动缩放规则:**
|
|
112
|
+
- 竖屏视频 (宽高比 <= 0.6): 自动使用 90% 尺寸
|
|
113
|
+
- 高度 >= 1080: 自动使用 50% 尺寸
|
|
114
|
+
- 高度 >= 720: 自动使用 60% 尺寸
|
|
115
|
+
- 高度 >= 480: 自动使用 100% 尺寸
|
|
99
116
|
|
|
100
117
|
## 系统要求
|
|
101
118
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|