更新记录
1.0.8(2025-06-26)
startServer接口新增path参数,设置自定义下载视频缓存路径。
1.0.7(2025-02-16)
修复eventListener事件多次触发事件失效问题。
1.0.6(2024-04-02)
对iOS的config配置文件增加frameworks配置信息。
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 4.4 | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | - | × | × | × | × |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | - | - | × |
概述
XF-m3u8CacheServerUTS实现了iOS、Android系统下m3u8的下载功能,根据解析的m3u8文件分片ts文件进行下载。然后手机内部将下载的ts文件重新组装进行发布,以供本地播放。
插件接口
startServer
开启本地服务(可以多次执行,需要在合适的时机执行,保证服务不会挂掉)
uni-app项目中(nvue)调用示例:
import { startServer } from "@/uni_modules/XF-m3u8CacheServerUTS"
startServer({
port: 8080,
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { startServer } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { StartServerOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
port: 8080,
complete: (res : any) => {
console.log(res)
}
} as StartServerOptions;
startServer(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
stopServer
停止本地服务
uni-app项目中(nvue)调用示例:
import { stopServer } from "@/uni_modules/XF-m3u8CacheServerUTS"
stopServer({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { stopServer } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { M3u8CacheOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as M3u8CacheOptions;
stopServer(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
eventListener
m3u8视频下载进度监听事件
uni-app项目中(nvue)调用示例:
import { eventListener } from "@/uni_modules/XF-m3u8CacheServerUTS"
eventListener({
process: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { eventListener } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { ListenerOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
process: (res : any) => {
console.log(res)
}
} as ListenerOptions;
eventListener(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
start
开始下载
uni-app项目中(nvue)调用示例:
import { start } from "@/uni_modules/XF-m3u8CacheServerUTS"
start({
url : "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { start } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { StartOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
url : "",
complete: (res : any) => {
console.log(res)
}
} as StartOptions;
start(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
pause
暂停下载
uni-app项目中(nvue)调用示例:
import { pause } from "@/uni_modules/XF-m3u8CacheServerUTS"
pause({
url : "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { pause } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { DownloadOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
url : "",
complete: (res : any) => {
console.log(res)
}
} as DownloadOptions;
pause(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
isDownloadFinish
是否下载完成
uni-app项目中(nvue)调用示例:
import { isDownloadFinish } from "@/uni_modules/XF-m3u8CacheServerUTS"
isDownloadFinish({
url : "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { isDownloadFinish } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { DownloadOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
url : "",
complete: (res : any) => {
console.log(res)
}
} as DownloadOptions;
isDownloadFinish(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
getCacheSize
获取缓存大小
uni-app项目中(nvue)调用示例:
import { getCacheSize } from "@/uni_modules/XF-m3u8CacheServerUTS"
getCacheSize({
url : "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { getCacheSize } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { FileCacheOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
url : "",
complete: (res : any) => {
console.log(res)
}
} as FileCacheOptions;
getCacheSize(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
clearCache
清除缓存文件
uni-app项目中(nvue)调用示例:
import { clearCache } from "@/uni_modules/XF-m3u8CacheServerUTS"
clearCache({
url : "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { clearCache } from "@/uni_modules/XF-m3u8CacheServerUTS";
import { FileCacheOptions } from "@/uni_modules/XF-m3u8CacheServerUTS/utssdk/interface.uts";
let options = {
url : "",
complete: (res : any) => {
console.log(res)
}
} as FileCacheOptions;
clearCache(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本