一个简单的HTML视频播放器,使用Edge浏览器或系统默认浏览器播放视频
Project description
HTMLPlayer
一个简单的Python库,用于使用Microsoft Edge浏览器或系统默认浏览器播放HTML5视频。
安装
pip install htmlplayer
快速开始
基础用法
from htmlplayer import play_video
play_video('https://example.com/video.mp4')
指定窗口大小
play_video('https://example.com/video.mp4', width=1280, height=720)
指定视频宽高比
play_video('https://example.com/video.mp4', video_aspect_ratio=21/9)
仅使用Edge浏览器
from htmlplayer import play_with_edge
play_with_edge('https://example.com/video.mp4')
使用系统默认浏览器
from htmlplayer import play_with_browser
play_with_browser('https://example.com/video.mp4')
API 文档
play_video(url, width=None, height=None, video_aspect_ratio=16/9, use_edge=True, use_browser_fallback=True)
使用Edge浏览器或系统默认浏览器播放视频。
参数:
url(str): 视频URL地址width(int, optional): 窗口宽度height(int, optional): 窗口高度video_aspect_ratio(float): 视频宽高比,默认16:9use_edge(bool): 是否优先使用Edge浏览器,默认Trueuse_browser_fallback(bool): Edge不可用时是否使用默认浏览器,默认True
返回:
bool: 播放是否成功启动
play_with_edge(url, width=None, height=None, video_aspect_ratio=16/9)
仅使用Edge浏览器播放视频。
play_with_browser(url, width=None, height=None, video_aspect_ratio=16/9)
使用系统默认浏览器播放视频。
find_edge_browser()
查找Microsoft Edge浏览器的安装路径。
calculate_window_size(screen_width=None, screen_height=None, video_aspect_ratio=16/9, scale=0.5)
计算合适的窗口大小。
系统要求
- 操作系统:Windows
- Python 3.8+
- Microsoft Edge浏览器(可选,推荐)
示例代码
安装后,你可以查看 examples/ 目录下的示例代码:
# 简单示例
python -c "import htmlplayer.examples.simple_example"
# 或找到安装位置查看文件
python -c "import htmlplayer; import os; print(os.path.join(os.path.dirname(htmlplayer.__file__), '..', 'examples'))"
示例文件:
simple_example.py- 基础使用示例advanced_example.py- 高级功能和自定义配置
许可证
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
htmlplayer-0.1.1.tar.gz
(5.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file htmlplayer-0.1.1.tar.gz.
File metadata
- Download URL: htmlplayer-0.1.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83339adebc15b32147146073f15c933ef5fc837e9f3d174d5fd3325a4464c6f8
|
|
| MD5 |
112f5a73ce23f634ea4a6297c534face
|
|
| BLAKE2b-256 |
902c048ce6173e66575d73dea04415ffd4d4baa4857af5cfd6f33dc0c61babf8
|
File details
Details for the file htmlplayer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: htmlplayer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512655579cd4c96168e2c89dba2967fe3ae0f9706aa7604eb97b74ec8ceb864f
|
|
| MD5 |
812b68a8becb68939f53e3fe5427173f
|
|
| BLAKE2b-256 |
86e316a5249c6a5da817327854d5bbd7bee54f18165fcd448b5d389be4c0e15f
|