Comments (10)
字幕的下载你是用什么来下载的呢?f
from ksplayer.
dataSource.infos = thirdPartySubtitles.map({ s in
let url = URL(string: s.url)!
return URLSubtitleInfo(subtitleID: url.path, name: s.name, url: url)
})
我把字幕的下载连接传进来的。
from ksplayer.
URLSubtitleInfo 是用URLSession.shared.downloadTask来进行下载的,没有设置过ua。需要你自己设置UA
from ksplayer.
你也可以用自己的方法来下载字幕,然后把这个下载下来的文件传给URLSubtitleInfo。URLSubtitleInfo 也是支持本地文件的字幕。
from ksplayer.
下载比较麻烦。一个文件夹下可能有很多字幕,比如一季美剧下,每集都带着字幕,批量下载的话容易触发后台 qps。
我大致看了下源码,不能强制设置某个 UA,因为项目集成了很多不同的平台,每个平台需要有不同的 UA,是否能跟随视频下载连接一样的 UA?或者给一个可选的参数来设置 UA?
from ksplayer.
@kingslay 当设置名字的时候 URLSubtitleInfo(subtitleID: url.path, name: s.name, url: url, userAgent: "custom agent")
由于加了判断:
if !url.isFileURL, name.isEmpty {}
名字不为空,它就不会走 download 函数下载字幕文件。
如果名字设置为空,则字幕列表的字幕都是乱七八糟的名字。
是否能去掉 name.isEmpty
这个判断?
from ksplayer.
可以把name.isEmpty 去掉。但是这个字幕下载之后,会重新设置名字。这个名字会是对的吗?你可以现在设置把这个判断去掉下。看下是否可以
url.download(userAgent: userAgent) { [weak self] filename, tmpUrl in
guard let self else {
return
}
self.name = filename
self.downloadURL = tmpUrl
var fileURL = URL(fileURLWithPath: NSTemporaryDirectory())
fileURL.appendPathComponent(filename)
try? FileManager.default.moveItem(at: tmpUrl, to: fileURL)
self.downloadURL = fileURL
}
from ksplayer.
之前的逻辑就是因为字幕的名字都是乱七八糟的名字。所以才在init就去下载的。不然这个字幕应该是要等到用户选中的时候再去下载。提前下载字幕可能会浪费网络。
from ksplayer.
哦,明白了,如果传进去名字,那么它不会自动下载,只有当选中字幕时候再下载。但是 download 接口只有在 init 时候才会被调用。这样的话又不能满足设置 UA 了。能否再改一下源代码,适配一下。
from ksplayer.
逻辑是这样的,进入播放页面时候,会将播放列表的所有字幕文件也传进去,传进去的字幕加上视频内置的字幕。这样用户可以手动选择使用哪个字幕。
传进去的字幕文件不只有下载连接,还有名字。
from ksplayer.
Related Issues (20)
- Video stutters (visionOS) HOT 5
- Installing via SPM as a package dependency fails in Xcode 15.3. HOT 1
- Video rebuffers? on seek in demo even cache option enabled HOT 9
- FPS Variability HOT 17
- Dolby Vision is purple HOT 2
- Playing this streams times out HOT 7
- Stream buffers very frequently on 3G but OK on WiFi HOT 1
- 前后台切换bug HOT 2
- [tvOS] 4K content on 1080p displays stutter and buffer a lot HOT 5
- TracyPlayer does not play stream HOT 5
- avformat can't open input - In test app it works, production app it doesn't HOT 2
- Cannot run AV1 codecs Video HOT 4
- 打开了logLevel为debug,还是没有显示debug的日志 HOT 2
- Invalid bundle identifier when pushing to testflight using KSPlayer via SPM (doesnt happen over ccoapods) HOT 2
- Xcode 15.4上传App Store报错
- Can the caching function be added? HOT 5
- 您好,如何在不播放的情况下,获取视频的总时间长度? 目前貌似没有 api 可以获取? HOT 1
- Stream doesn't start HOT 2
- Compilation warning in AudioEnginePlayer.swift
- Unable to add via Swift Package manager HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksplayer.