You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 12, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: r2-shared-swift/MediaOverlayNode.swift
+8-52Lines changed: 8 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,10 @@ public struct Clip {
24
24
/// End time in seconds.
25
25
publicvarend:Double!
26
26
/// Total clip duration in seconds (end - start).
27
+
@available(iOS, deprecated:9.0, message:"Don't use it when the value is negative, because some information is missing in the original SMIL file. Try to get the duration from file system or APIs in Fetcher, then minus the start value.")
27
28
publicvarduration:Double!
29
+
30
+
publicinit(){}
28
31
}
29
32
30
33
/// The Error enumeration of the MediaOverlayNode class.
@@ -39,13 +42,15 @@ public enum MediaOverlayNodeError: Error {
39
42
/// Represents a MediaOverlay XML node.
40
43
publicclassMediaOverlayNode{
41
44
publicvartext:String?
42
-
publicvaraudio:String?
45
+
publicvarclip:Clip?
46
+
43
47
publicvarrole=[String]()
44
48
publicvarchildren=[MediaOverlayNode]()
45
49
46
-
publicinit(_ text:String?=nil,audio:String?=nil){
50
+
publicinit(_ text:String?=nil,clip:Clip?=nil){
47
51
self.text = text
48
-
self.audio = audio
52
+
self.clip = clip
53
+
self.clip?.fragmentId =self.fragmentId()
49
54
}
50
55
51
56
// Mark: - Internal Methods.
@@ -59,53 +64,4 @@ public class MediaOverlayNode {
59
64
}
60
65
return text.components(separatedBy:"#").last
61
66
}
62
-
63
-
/// Generate a `Clip` from self.
64
-
///
65
-
/// - Returns: The generated `Clip`.
66
-
/// - Throws: `MediaOverlayNodeError.audio`,
67
-
/// `MediaOverlayNodeError.timersParsing`.
68
-
publicfunc clip()throws->Clip{
69
-
varnewClip=Clip()
70
-
71
-
// Retrieve the audioString (containing timers + audiofile url), then
72
-
// retrieve both.
73
-
guardlet audioString =self.audio,
74
-
let audioFileString = audioString.components(separatedBy:"#").first,
75
-
let audioFileUrl =URL(string: audioFileString)else
76
-
{
77
-
throwMediaOverlayNodeError.audio
78
-
}
79
-
// Relative audio file URL.
80
-
newClip.relativeUrl = audioFileUrl
81
-
guardlet times = audioString.components(separatedBy:"#").last else{
82
-
throwMediaOverlayNodeError.timersParsing
83
-
}
84
-
tryparseTimer(times, into:&newClip)
85
-
newClip.fragmentId =fragmentId()
86
-
return newClip
87
-
}
88
-
89
-
/// Parse the time String to fill `clip`.
90
-
///
91
-
/// - Parameters:
92
-
/// - times: The time string ("t=S.MS,S.MS")
93
-
/// - clip: The Clip instance where to fill the parsed data.
0 commit comments