Fix some subtitles being extracted before needed
This commit is contained in:
parent
e8a229eaec
commit
9d425fae84
|
@ -328,26 +328,6 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let request2 = RestRequest(method: .get, url: (globalData.server?.baseURI ?? "") + "/System/Endpoint")
|
|
||||||
request2.headerParameters["X-Emby-Authorization"] = globalData.authHeader
|
|
||||||
request2.contentType = "application/json"
|
|
||||||
request2.acceptType = "application/json"
|
|
||||||
|
|
||||||
request2.responseData(){ (result: Result<RestResponse<Data>, RestError>) in
|
|
||||||
switch result {
|
|
||||||
case .success( let resp):
|
|
||||||
do {
|
|
||||||
let json = try JSON(data: resp.body)
|
|
||||||
globalData.isInNetwork = json["IsInNetwork"].bool ?? true;
|
|
||||||
} catch {
|
|
||||||
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case .failure( let error):
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,84 +106,78 @@ struct ContinueWatchingView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if(resumeItems.count != 0) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
LazyHStack() {
|
||||||
LazyHStack() {
|
Spacer().frame(width:16)
|
||||||
if(isLoading == false) {
|
ForEach(resumeItems, id: \.Id) { item in
|
||||||
Spacer().frame(width:16)
|
NavigationLink(destination: ItemView(item: item)) {
|
||||||
ForEach(resumeItems, id: \.Id) { item in
|
VStack(alignment: .leading) {
|
||||||
NavigationLink(destination: ItemView(item: item)) {
|
Spacer().frame(height: 10)
|
||||||
VStack(alignment: .leading) {
|
if(item.Type == "Episode") {
|
||||||
Spacer().frame(height: 10)
|
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(item.Id)/Images/\(item.ImageType)?maxWidth=550&quality=80&tag=\(item.Image)")!)
|
||||||
if(item.Type == "Episode") {
|
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
||||||
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(item.Id)/Images/\(item.ImageType)?maxWidth=550&quality=80&tag=\(item.Image)")!)
|
.placeholder {
|
||||||
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 6, height: 6))!)
|
||||||
.placeholder {
|
.resizable()
|
||||||
Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 6, height: 6))!)
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 320, height: 180)
|
|
||||||
.cornerRadius(10)
|
|
||||||
}
|
|
||||||
.frame(width: 320, height: 180)
|
.frame(width: 320, height: 180)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.overlay(
|
|
||||||
ZStack {
|
|
||||||
Text("S\(String(item.ParentIndexNumber ?? 0)):E\(String(item.IndexNumber ?? 0)) - \(item.Name)")
|
|
||||||
.font(.caption)
|
|
||||||
.padding(6)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
}.background(Color.black)
|
|
||||||
.opacity(0.8)
|
|
||||||
.cornerRadius(10.0)
|
|
||||||
.padding(6), alignment: .topTrailing
|
|
||||||
)
|
|
||||||
.overlay(
|
|
||||||
Rectangle()
|
|
||||||
.fill(Color(red: 172/255, green: 92/255, blue: 195/255))
|
|
||||||
.mask(CustomShape(radius: 10))
|
|
||||||
.frame(width: CGFloat((item.ItemProgress/100)*320), height: 7)
|
|
||||||
.padding(0), alignment: .bottomLeading
|
|
||||||
)
|
|
||||||
.shadow(radius: 5)
|
|
||||||
} else {
|
|
||||||
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(item.Id)/Images/\(item.ImageType)?maxWidth=550&quality=80&tag=\(item.Image)")!)
|
|
||||||
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
|
||||||
.placeholder {
|
|
||||||
Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 6, height: 6))!)
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 320, height: 180)
|
|
||||||
.cornerRadius(10)
|
|
||||||
}
|
|
||||||
.frame(width: 320, height: 180)
|
|
||||||
.cornerRadius(10)
|
|
||||||
.overlay(
|
|
||||||
Rectangle()
|
|
||||||
.fill(Color(red: 172/255, green: 92/255, blue: 195/255))
|
|
||||||
.mask(CustomShape(radius: 10))
|
|
||||||
.frame(width: CGFloat((item.ItemProgress/100)*320), height: 7)
|
|
||||||
.padding(0), alignment: .bottomLeading
|
|
||||||
)
|
|
||||||
.shadow(radius: 5)
|
|
||||||
}
|
}
|
||||||
Text("\(item.Type == "Episode" ? item.SeriesName ?? "" : item.Name)")
|
.frame(width: 320, height: 180)
|
||||||
.font(.callout)
|
.cornerRadius(10)
|
||||||
.fontWeight(.semibold)
|
.overlay(
|
||||||
.foregroundColor(.primary)
|
ZStack {
|
||||||
.lineLimit(1)
|
Text("S\(String(item.ParentIndexNumber ?? 0)):E\(String(item.IndexNumber ?? 0)) - \(item.Name)")
|
||||||
.frame(width: 320, alignment: .leading)
|
.font(.caption)
|
||||||
Spacer().frame(height: 5)
|
.padding(6)
|
||||||
}.padding(.trailing, 5)
|
.foregroundColor(.white)
|
||||||
|
}.background(Color.black)
|
||||||
|
.opacity(0.8)
|
||||||
|
.cornerRadius(10.0)
|
||||||
|
.padding(6), alignment: .topTrailing
|
||||||
|
)
|
||||||
|
.overlay(
|
||||||
|
Rectangle()
|
||||||
|
.fill(Color(red: 172/255, green: 92/255, blue: 195/255))
|
||||||
|
.mask(CustomShape(radius: 10))
|
||||||
|
.frame(width: CGFloat((item.ItemProgress/100)*320), height: 7)
|
||||||
|
.padding(0), alignment: .bottomLeading
|
||||||
|
)
|
||||||
|
.shadow(radius: 5)
|
||||||
|
} else {
|
||||||
|
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(item.Id)/Images/\(item.ImageType)?maxWidth=550&quality=80&tag=\(item.Image)")!)
|
||||||
|
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
||||||
|
.placeholder {
|
||||||
|
Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 6, height: 6))!)
|
||||||
|
.resizable()
|
||||||
|
.frame(width: 320, height: 180)
|
||||||
|
.cornerRadius(10)
|
||||||
|
}
|
||||||
|
.frame(width: 320, height: 180)
|
||||||
|
.cornerRadius(10)
|
||||||
|
.overlay(
|
||||||
|
Rectangle()
|
||||||
|
.fill(Color(red: 172/255, green: 92/255, blue: 195/255))
|
||||||
|
.mask(CustomShape(radius: 10))
|
||||||
|
.frame(width: CGFloat((item.ItemProgress/100)*320), height: 7)
|
||||||
|
.padding(0), alignment: .bottomLeading
|
||||||
|
)
|
||||||
|
.shadow(radius: 5)
|
||||||
}
|
}
|
||||||
}
|
Text("\(item.Type == "Episode" ? item.SeriesName ?? "" : item.Name)")
|
||||||
Spacer().frame(width:14)
|
.font(.callout)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.foregroundColor(.primary)
|
||||||
|
.lineLimit(1)
|
||||||
|
.frame(width: 320, alignment: .leading)
|
||||||
|
Spacer().frame(height: 5)
|
||||||
|
}.padding(.trailing, 5)
|
||||||
}
|
}
|
||||||
}.frame(height: 215)
|
}
|
||||||
}
|
Spacer().frame(width:14)
|
||||||
.frame(height: 215)
|
}.frame(height: 215)
|
||||||
.padding(.bottom, 10)
|
}.onAppear(perform: onAppear)
|
||||||
} else {
|
.frame(height: 215)
|
||||||
EmptyView().onAppear(perform: onAppear)
|
.padding(.bottom, 10)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ struct NextUpView: View {
|
||||||
.frame(width: 100)
|
.frame(width: 100)
|
||||||
Spacer().frame(width:12)
|
Spacer().frame(width:12)
|
||||||
}
|
}
|
||||||
|
Spacer().frame(width: 13.6)
|
||||||
}
|
}
|
||||||
Spacer().frame(width:18)
|
Spacer().frame(width:18)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct VideoPlayerView: View {
|
||||||
@State private var lastPosition: Double = 0;
|
@State private var lastPosition: Double = 0;
|
||||||
@State private var iterations: Int = 0;
|
@State private var iterations: Int = 0;
|
||||||
@State private var startTime: Int = 0;
|
@State private var startTime: Int = 0;
|
||||||
|
@State private var hasSentPlayReport: Bool = false;
|
||||||
@State private var captionConfiguration: Bool = false {
|
@State private var captionConfiguration: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
if(captionConfiguration == false) {
|
if(captionConfiguration == false) {
|
||||||
|
@ -122,6 +123,10 @@ struct VideoPlayerView: View {
|
||||||
} else {
|
} else {
|
||||||
_iterations.wrappedValue = 0;
|
_iterations.wrappedValue = 0;
|
||||||
_streamLoading.wrappedValue = false;
|
_streamLoading.wrappedValue = false;
|
||||||
|
if(_hasSentPlayReport.wrappedValue == false) {
|
||||||
|
sendPlayReport()
|
||||||
|
_hasSentPlayReport.wrappedValue = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(vlcplayer.state == VLCMediaPlayerState.error) {
|
if(vlcplayer.state == VLCMediaPlayerState.error) {
|
||||||
playing.wrappedValue = false;
|
playing.wrappedValue = false;
|
||||||
|
@ -173,7 +178,6 @@ struct VideoPlayerView: View {
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let resp):
|
case .success(let resp):
|
||||||
print(resp.body)
|
print(resp.body)
|
||||||
self.playing.wrappedValue = false;
|
|
||||||
break
|
break
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
debugPrint(error)
|
debugPrint(error)
|
||||||
|
@ -186,7 +190,7 @@ struct VideoPlayerView: View {
|
||||||
var progressBody: String = "";
|
var progressBody: String = "";
|
||||||
_startTime.wrappedValue = Int(Date().timeIntervalSince1970) * 10000000
|
_startTime.wrappedValue = Int(Date().timeIntervalSince1970) * 10000000
|
||||||
if(pbitem.videoType == VideoType.hls) {
|
if(pbitem.videoType == VideoType.hls) {
|
||||||
progressBody = "{\"VolumeLevel\":100,\"IsMuted\":false,\"IsPaused\":true,\"RepeatMode\":\"RepeatNone\",\"ShuffleMode\":\"Sorted\",\"MaxStreamingBitrate\":120000000,\"PositionTicks\":\(Int(item.Progress)),\"PlaybackStartTimeTicks\":\(startTime),\"AudioStreamIndex\":\(selectedAudioTrack),\"BufferedRanges\":[{\"start\":0,\"end\":100000}],\"PlayMethod\":\"Transcode\",\"PlaySessionId\":\"\(playSessionId)\",\"PlaylistItemId\":\"playlistItem0\",\"MediaSourceId\":\"\(item.Id)\",\"CanSeek\":true,\"ItemId\":\"\(item.Id)\",\"NowPlayingQueue\":[{\"Id\":\"\(item.Id)\",\"PlaylistItemId\":\"playlistItem0\"}]}";
|
progressBody = "{\"VolumeLevel\":100,\"IsMuted\":false,\"IsPaused\":false,\"RepeatMode\":\"RepeatNone\",\"ShuffleMode\":\"Sorted\",\"MaxStreamingBitrate\":120000000,\"PositionTicks\":\(Int(item.Progress)),\"PlaybackStartTimeTicks\":\(startTime),\"AudioStreamIndex\":\(selectedAudioTrack),\"BufferedRanges\":[],\"PlayMethod\":\"Transcode\",\"PlaySessionId\":\"\(playSessionId)\",\"PlaylistItemId\":\"playlistItem0\",\"MediaSourceId\":\"\(item.Id)\",\"CanSeek\":true,\"ItemId\":\"\(item.Id)\",\"NowPlayingQueue\":[{\"Id\":\"\(item.Id)\",\"PlaylistItemId\":\"playlistItem0\"}]}";
|
||||||
} else {
|
} else {
|
||||||
progressBody = "{\"VolumeLevel\":100,\"IsMuted\":false,\"IsPaused\":false,\"RepeatMode\":\"RepeatNone\",\"ShuffleMode\":\"Sorted\",\"MaxStreamingBitrate\":120000000,\"PositionTicks\":\(Int(item.Progress)),\"PlaybackStartTimeTicks\":\(startTime),\"AudioStreamIndex\":\(selectedAudioTrack),\"BufferedRanges\":[],\"PlayMethod\":\"DirectStream\",\"PlaySessionId\":\"\(playSessionId)\",\"PlaylistItemId\":\"playlistItem0\",\"MediaSourceId\":\"\(item.Id)\",\"CanSeek\":true,\"ItemId\":\"\(item.Id)\",\"NowPlayingQueue\":[{\"Id\":\"\(item.Id)\",\"PlaylistItemId\":\"playlistItem0\"}]}";
|
progressBody = "{\"VolumeLevel\":100,\"IsMuted\":false,\"IsPaused\":false,\"RepeatMode\":\"RepeatNone\",\"ShuffleMode\":\"Sorted\",\"MaxStreamingBitrate\":120000000,\"PositionTicks\":\(Int(item.Progress)),\"PlaybackStartTimeTicks\":\(startTime),\"AudioStreamIndex\":\(selectedAudioTrack),\"BufferedRanges\":[],\"PlayMethod\":\"DirectStream\",\"PlaySessionId\":\"\(playSessionId)\",\"PlaylistItemId\":\"playlistItem0\",\"MediaSourceId\":\"\(item.Id)\",\"CanSeek\":true,\"ItemId\":\"\(item.Id)\",\"NowPlayingQueue\":[{\"Id\":\"\(item.Id)\",\"PlaylistItemId\":\"playlistItem0\"}]}";
|
||||||
}
|
}
|
||||||
|
@ -216,7 +220,7 @@ struct VideoPlayerView: View {
|
||||||
|
|
||||||
let jsonEncoder = JSONEncoder()
|
let jsonEncoder = JSONEncoder()
|
||||||
let jsonData = try! jsonEncoder.encode(DeviceProfile)
|
let jsonData = try! jsonEncoder.encode(DeviceProfile)
|
||||||
let jsonString = String(data: jsonData, encoding: .utf8)!
|
let jsonString = String(data: jsonData, encoding: .ascii)!
|
||||||
print(jsonString)
|
print(jsonString)
|
||||||
|
|
||||||
_streamLoading.wrappedValue = true;
|
_streamLoading.wrappedValue = true;
|
||||||
|
@ -228,7 +232,7 @@ struct VideoPlayerView: View {
|
||||||
request.headerParameters["X-Emby-Authorization"] = globalData.authHeader
|
request.headerParameters["X-Emby-Authorization"] = globalData.authHeader
|
||||||
request.contentType = "application/json"
|
request.contentType = "application/json"
|
||||||
request.acceptType = "application/json"
|
request.acceptType = "application/json"
|
||||||
request.messageBody = jsonData
|
request.messageBody = jsonString.data(using: .ascii)
|
||||||
|
|
||||||
request.responseData() { (result: Result<RestResponse<Data>, RestError>) in
|
request.responseData() { (result: Result<RestResponse<Data>, RestError>) in
|
||||||
switch result {
|
switch result {
|
||||||
|
@ -239,13 +243,13 @@ struct VideoPlayerView: View {
|
||||||
_playSessionId.wrappedValue = json["PlaySessionId"].string ?? "";
|
_playSessionId.wrappedValue = json["PlaySessionId"].string ?? "";
|
||||||
if(json["MediaSources"][0]["TranscodingUrl"].string != nil) {
|
if(json["MediaSources"][0]["TranscodingUrl"].string != nil) {
|
||||||
print("Transcoding!")
|
print("Transcoding!")
|
||||||
let streamURL: URL = URL(string: "\(globalData.server?.baseURI ?? "")\((json["MediaSources"][0]["TranscodingUrl"].string ?? ""))")!
|
let streamURL: URL = URL(string: "\(globalData.server?.baseURI ?? "")\((json["MediaSources"][0]["TranscodingUrl"].string ?? ""))".replacingOccurrences(of: "master.m3u8", with: "main.m3u8"))!
|
||||||
print(streamURL)
|
print(streamURL)
|
||||||
let item = PlaybackItem(videoType: VideoType.hls, videoUrl: streamURL, subtitles: [])
|
let item = PlaybackItem(videoType: VideoType.hls, videoUrl: streamURL, subtitles: [])
|
||||||
let disableSubtitleTrack = Subtitle(name: "Disabled", id: -1, url: URL(string: "https://example.com")!, delivery: "Embed")
|
let disableSubtitleTrack = Subtitle(name: "Disabled", id: -1, url: URL(string: "https://example.com")!, delivery: "Embed")
|
||||||
_subtitles.wrappedValue.append(disableSubtitleTrack);
|
_subtitles.wrappedValue.append(disableSubtitleTrack);
|
||||||
for (_,stream):(String, JSON) in json["MediaSources"][0]["MediaStreams"] {
|
for (_,stream):(String, JSON) in json["MediaSources"][0]["MediaStreams"] {
|
||||||
if(stream["Type"].string == "Subtitle") {
|
if(stream["Type"].string == "Subtitle" && stream["Codec"] != "subrip") { //ignore ripped subtitles - we don't want to extract subtitles
|
||||||
let deliveryUrl = URL(string: "\(globalData.server?.baseURI ?? "")\(stream["DeliveryUrl"].string ?? "")")!
|
let deliveryUrl = URL(string: "\(globalData.server?.baseURI ?? "")\(stream["DeliveryUrl"].string ?? "")")!
|
||||||
let subtitle = Subtitle(name: stream["DisplayTitle"].string ?? "", id: Int32(stream["Index"].int ?? 0), url: deliveryUrl, delivery: stream["DeliveryMethod"].string ?? "")
|
let subtitle = Subtitle(name: stream["DisplayTitle"].string ?? "", id: Int32(stream["Index"].int ?? 0), url: deliveryUrl, delivery: stream["DeliveryMethod"].string ?? "")
|
||||||
_subtitles.wrappedValue.append(subtitle);
|
_subtitles.wrappedValue.append(subtitle);
|
||||||
|
@ -267,7 +271,6 @@ struct VideoPlayerView: View {
|
||||||
|
|
||||||
pbitem = item;
|
pbitem = item;
|
||||||
pbitem.subtitles = subtitles;
|
pbitem.subtitles = subtitles;
|
||||||
sendPlayReport();
|
|
||||||
_isPlaying.wrappedValue = true;
|
_isPlaying.wrappedValue = true;
|
||||||
} else {
|
} else {
|
||||||
print("Direct playing!");
|
print("Direct playing!");
|
||||||
|
@ -298,7 +301,6 @@ struct VideoPlayerView: View {
|
||||||
|
|
||||||
pbitem = item;
|
pbitem = item;
|
||||||
pbitem.subtitles = subtitles;
|
pbitem.subtitles = subtitles;
|
||||||
sendPlayReport();
|
|
||||||
_isPlaying.wrappedValue = true;
|
_isPlaying.wrappedValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,6 +358,7 @@ struct VideoPlayerView: View {
|
||||||
HStack() {
|
HStack() {
|
||||||
Button() {
|
Button() {
|
||||||
sendStopReport()
|
sendStopReport()
|
||||||
|
self.playing.wrappedValue = false;
|
||||||
} label: {
|
} label: {
|
||||||
HStack() {
|
HStack() {
|
||||||
Image(systemName: "chevron.left").font(.system(size: 20)).foregroundColor(.white)
|
Image(systemName: "chevron.left").font(.system(size: 20)).foregroundColor(.white)
|
||||||
|
|
Loading…
Reference in New Issue