Skip to content

Commit 6b77597

Browse files
authored
Merge pull request #11 from BunnyWay/feature/remove-cdn
Removed explicit CDN setting
2 parents c653fed + a746a44 commit 6b77597

15 files changed

Lines changed: 99 additions & 115 deletions

File tree

Example-App/Example-App.xcodeproj/project.pbxproj

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,11 @@
530530
buildSettings = {
531531
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
532532
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
533-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
534-
CODE_SIGN_STYLE = Manual;
535-
CURRENT_PROJECT_VERSION = 2;
533+
CODE_SIGN_IDENTITY = "Apple Development";
534+
CODE_SIGN_STYLE = Automatic;
535+
CURRENT_PROJECT_VERSION = 5;
536536
DEVELOPMENT_ASSET_PATHS = "\"Example-App/Preview Content\"";
537537
DEVELOPMENT_TEAM = "";
538-
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = GX6PPA6X9F;
539538
ENABLE_PREVIEWS = YES;
540539
GENERATE_INFOPLIST_FILE = YES;
541540
INFOPLIST_FILE = "Example-App/Info.plist";
@@ -557,7 +556,6 @@
557556
PRODUCT_BUNDLE_IDENTIFIER = net.bunny.StreamSDKDemo;
558557
PRODUCT_NAME = "$(TARGET_NAME)";
559558
PROVISIONING_PROFILE_SPECIFIER = "";
560-
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Stream SDK Demo App Development profile";
561559
SWIFT_EMIT_LOC_STRINGS = YES;
562560
SWIFT_VERSION = 5.0;
563561
TARGETED_DEVICE_FAMILY = "1,2";
@@ -569,12 +567,11 @@
569567
buildSettings = {
570568
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
571569
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
572-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
573-
CODE_SIGN_STYLE = Manual;
574-
CURRENT_PROJECT_VERSION = 2;
570+
CODE_SIGN_IDENTITY = "Apple Development";
571+
CODE_SIGN_STYLE = Automatic;
572+
CURRENT_PROJECT_VERSION = 5;
575573
DEVELOPMENT_ASSET_PATHS = "\"Example-App/Preview Content\"";
576-
DEVELOPMENT_TEAM = "";
577-
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = GX6PPA6X9F;
574+
DEVELOPMENT_TEAM = GX6PPA6X9F;
578575
ENABLE_PREVIEWS = YES;
579576
GENERATE_INFOPLIST_FILE = YES;
580577
INFOPLIST_FILE = "Example-App/Info.plist";
@@ -596,7 +593,6 @@
596593
PRODUCT_BUNDLE_IDENTIFIER = net.bunny.StreamSDKDemo;
597594
PRODUCT_NAME = "$(TARGET_NAME)";
598595
PROVISIONING_PROFILE_SPECIFIER = "";
599-
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Stream SDK Demo Provisioning profile";
600596
SWIFT_EMIT_LOC_STRINGS = YES;
601597
SWIFT_VERSION = 5.0;
602598
TARGETED_DEVICE_FAMILY = "1,2";

Example-App/Example-App/App/ContentView.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct ContentView: View {
1313
@EnvironmentObject var dependenciesManager: DependenciesManager
1414
@State private var isShowingSheet = false
1515
@State private var tempAccessKey: String = ""
16-
@State private var cdnHostname: String = ""
1716
@State private var libraryId: String = ""
1817
@State private var isStreamingPresented: Bool = false
1918
@State private var isShowingVideoIdAlert = false
@@ -79,7 +78,6 @@ struct ContentView: View {
7978
})
8079
.onAppear {
8180
tempAccessKey = dependenciesManager.accessKey
82-
cdnHostname = dependenciesManager.cdnHostname
8381
libraryId = String(dependenciesManager.libraryId)
8482
}
8583
}
@@ -93,19 +91,14 @@ private extension ContentView {
9391
.sheet(isPresented: $isShowingSheet) {
9492
NavigationStack {
9593
Form {
96-
Section("Access Key") {
97-
TextField("Access your Key", text: $tempAccessKey)
94+
Section("API Key") {
95+
TextField("Enter your API Key", text: $tempAccessKey)
9896
.autocapitalization(.none)
9997
.disableAutocorrection(true)
10098

10199
}
102-
Section("CDN Hostname") {
103-
TextField("Enter CDN Gostname", text: $cdnHostname)
104-
.autocapitalization(.none)
105-
.disableAutocorrection(true)
106-
}
107-
Section("Library ID") {
108-
TextField("Enter Library ID", text: $libraryId)
100+
Section("Video Library ID") {
101+
TextField("Enter your Library ID", text: $libraryId)
109102
.keyboardType(.numberPad)
110103
.autocapitalization(.none)
111104
.disableAutocorrection(true)
@@ -131,7 +124,6 @@ private extension ContentView {
131124

132125
private func saveConfig() {
133126
dependenciesManager.storedAccessKey = tempAccessKey
134-
dependenciesManager.cdnHostname = cdnHostname
135127
dependenciesManager.libraryId = Int(libraryId) ?? .zero
136128
isShowingSheet = false
137129
}

Example-App/Example-App/App/DependenciesManager.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class DependenciesManager: ObservableObject {
1616
}
1717
@Published var accessKey: String
1818

19-
@AppStorage("cdnHostname") var cdnHostname: String = ""
2019
@AppStorage("libraryId") var libraryId: Int = .zero
2120

2221
var tusVideoUploader: TUSVideoUploader

Example-App/Example-App/Resources/Localizable.xcstrings

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
"%lld views" : {
1515

1616
},
17-
"Access Key" : {
18-
19-
},
20-
"Access your Key" : {
17+
"Actions" : {
2118

2219
},
23-
"Actions" : {
20+
"API Key" : {
2421

2522
},
2623
"BunnyStream Configuration" : {
@@ -34,23 +31,20 @@
3431
},
3532
"Cancel" : {
3633

37-
},
38-
"CDN Hostname" : {
39-
4034
},
4135
"Configuration" : {
4236

4337
},
4438
"Direct Video Play" : {
4539

4640
},
47-
"Enter CDN Gostname" : {
41+
"Enter Video ID" : {
4842

4943
},
50-
"Enter Library ID" : {
44+
"Enter your API Key" : {
5145

5246
},
53-
"Enter Video ID" : {
47+
"Enter your Library ID" : {
5448

5549
},
5650
"Error: %@" : {
@@ -72,9 +66,6 @@
7266
}
7367
}
7468
}
75-
},
76-
"Library ID" : {
77-
7869
},
7970
"No videos!" : {
8071

@@ -111,6 +102,9 @@
111102
},
112103
"Video ID" : {
113104

105+
},
106+
"Video Library ID" : {
107+
114108
},
115109
"Video List" : {
116110

Example-App/Example-App/Scenes/VideoPlayerDemo/Player/BunnyStreamPlayer+Default.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extension BunnyStreamPlayer {
1717
accessKey: accessKey,
1818
videoId: videoId,
1919
libraryId: dependenciesManager.libraryId,
20-
cdn: dependenciesManager.cdnHostname,
2120
playerIcons: playerIcons
2221
)
2322
}

Example-App/Example-App/Scenes/VideoPlayerDemo/VideoList/VideoListRow.swift

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import SwiftUI
1010

1111
struct VideoListRow: View {
1212
var video: VideoResponseInfo
13-
var cdn: String
14-
13+
1514
var body: some View {
1615
ZStack {
1716
RoundedRectangle(cornerRadius: 16)
@@ -39,41 +38,42 @@ extension VideoListRow {
3938
var imageView: some View {
4039
GeometryReader { geometry in
4140
VStack {
42-
AsyncImage(url: video.thumbnailFileURL(cdn: cdn)) { phase in
43-
switch phase {
44-
case .empty:
45-
ProgressView()
46-
.transition(.opacity)
47-
case .success(let image):
48-
image
49-
.resizable()
50-
.transition(.opacity)
51-
.aspectRatio(contentMode: .fill)
52-
.overlay {
53-
LinearGradient(
54-
gradient: Gradient(
55-
colors: [
56-
.clear,
57-
.black.opacity(
58-
0.7
59-
)]
60-
),
61-
startPoint: .center,
62-
endPoint: .bottom
63-
)
64-
}
65-
case .failure:
41+
// No Thumbnail is available at this time
42+
// AsyncImage(url: video.thumbnailFileURL()) { phase in
43+
// switch phase {
44+
// case .empty:
45+
// ProgressView()
46+
// .transition(.opacity)
47+
// case .success(let image):
48+
// image
49+
// .resizable()
50+
// .transition(.opacity)
51+
// .aspectRatio(contentMode: .fill)
52+
// .overlay {
53+
// LinearGradient(
54+
// gradient: Gradient(
55+
// colors: [
56+
// .clear,
57+
// .black.opacity(
58+
// 0.7
59+
// )]
60+
// ),
61+
// startPoint: .center,
62+
// endPoint: .bottom
63+
// )
64+
// }
65+
// case .failure:
6666
Image(systemName: "photo")
6767
.resizable()
6868
.foregroundColor(.black.opacity(0.2))
6969
.scaledToFit()
7070
.frame(width: 50)
7171
.transition(.opacity)
72-
@unknown default:
73-
EmptyView()
74-
}
75-
}
76-
.clipped()
72+
// @unknown default:
73+
// EmptyView()
74+
// }
75+
// }
76+
// .clipped()
7777
}
7878
.frame(width: geometry.size.width, height: 230)
7979
}

Example-App/Example-App/Scenes/VideoPlayerDemo/VideoList/VideoListView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ struct VideoListView: View {
3030
Button(action: {
3131
selectedVideoInfo = videoInfo
3232
}) {
33-
VideoListRow(video: videoInfo, cdn: dependenciesManager.cdnHostname)
33+
VideoListRow(video: videoInfo)
3434
}
3535
} else {
36-
VideoListRow(video: videoInfo, cdn: dependenciesManager.cdnHostname)
36+
VideoListRow(video: videoInfo)
3737
}
3838
}
3939
}

Example-App/Example-App/Scenes/VideoPlayerDemo/VideoList/VideoResponseInfo.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct VideoResponseInfo: Hashable, Identifiable {
2121
var averageWatchTime: Int64
2222
var views: Int
2323

24-
func thumbnailFileURL(cdn: String) -> URL? {
25-
guard let fileName = thumbnailFileName else { return nil }
26-
return URL(string: "https://\(cdn)/\(id)/\(fileName)")
24+
func thumbnailFileURL() -> URL? {
25+
// No thumbnail URL available here
26+
return nil
2727
}
2828

2929
var formattedFileSize: String {

Sources/BunnyStreamPlayer/Model/Caption.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ import Foundation
33
struct Caption: Hashable {
44
var languageCode: String
55
var label: String
6-
7-
func url(cdn: String, videoId: String) -> URL? {
8-
URL(string: "https://\(cdn)/\(videoId)/captions/\(languageCode).vtt?ver=1")
9-
}
6+
var captionsPath: String?
107
}

Sources/BunnyStreamPlayer/Model/Video.swift

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ struct Video {
88
var width: CGFloat
99
var height: CGFloat
1010
var length: Double
11-
var cdn: String
1211
var captions: [Caption]
1312
var libraryId: Int
1413
let resolutions: [Resolution]
14+
var seekPath: String?
15+
var playlistUrl: String?
1516
}
1617

1718
extension Video {
@@ -29,18 +30,22 @@ extension Video {
2930
}
3031

3132
func seekThumbnailURLs(thumbnailsPerImage: Int) -> [URL] {
33+
guard let seekPath = seekPath else { return [] }
3234
let numberOfPreviews = Int(ceil(Double(thumbnailCount) / Double(thumbnailsPerImage)))
33-
return (0..<numberOfPreviews).compactMap {
34-
URL(string: "https://\(cdn)/\(guid)/seek/_\($0).jpg")
35+
return (0..<numberOfPreviews).compactMap { index in
36+
URL(string: "\(seekPath)/_\(index).jpg")
3537
}
3638
}
3739
}
3840

3941
extension Video {
40-
init(videoConfigResponse: VideoConfigResponse.Video, cdn: String) {
42+
init(response: VideoConfigResponse) {
43+
let videoConfigResponse = response.video
4144
let chapters = videoConfigResponse.chapters.map { Chapter(start: Double($0.start), end: Double($0.end), type: .regular(title: $0.title)) }
4245
let moments = videoConfigResponse.moments.map { Moment(label: $0.label, second: $0.timestamp)}
43-
let captions = videoConfigResponse.captions.map { Caption(languageCode: $0.srclang, label: $0.label) }
46+
let captions = videoConfigResponse.captions.map {
47+
Caption(languageCode: $0.srclang, label: $0.label, captionsPath: response.captionsPath)
48+
}
4449

4550
var computedResolutions = [Video.Resolution.auto]
4651
let resolutionStrings = videoConfigResponse.availableResolutions.split(separator: ",")
@@ -51,17 +56,20 @@ extension Video {
5156
}
5257
computedResolutions.sort { $0.bitrate < $1.bitrate }
5358

54-
self.init(guid: videoConfigResponse.guid,
55-
chaptersList: ValidatedChapterList(originalChapters: chapters, duration: videoConfigResponse.length),
56-
moments: moments,
57-
thumbnailCount: videoConfigResponse.thumbnailCount,
58-
width: CGFloat(videoConfigResponse.width),
59-
height: CGFloat(videoConfigResponse.height),
60-
length: videoConfigResponse.length,
61-
cdn: cdn,
62-
captions: captions,
63-
libraryId: videoConfigResponse.videoLibraryId,
64-
resolutions: computedResolutions)
59+
self.init(
60+
guid: videoConfigResponse.guid,
61+
chaptersList: ValidatedChapterList(originalChapters: chapters, duration: videoConfigResponse.length),
62+
moments: moments,
63+
thumbnailCount: videoConfigResponse.thumbnailCount,
64+
width: CGFloat(videoConfigResponse.width),
65+
height: CGFloat(videoConfigResponse.height),
66+
length: videoConfigResponse.length,
67+
captions: captions,
68+
libraryId: videoConfigResponse.videoLibraryId,
69+
resolutions: computedResolutions,
70+
seekPath: response.seekPath,
71+
playlistUrl: response.videoPlaylistUrl
72+
)
6573
}
6674

6775
mutating func adjustLength(_ length: Double?) {

0 commit comments

Comments
 (0)