File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ class AudioEntry {
37
37
return seekTime + ( Double ( framesState. played) / outputAudioFormat. sampleRate)
38
38
}
39
39
40
+ var framesPlayed : Int {
41
+ lock. lock ( ) ; defer { lock. unlock ( ) }
42
+ return framesState. played
43
+ }
44
+
40
45
var audioStreamFormat = AudioStreamBasicDescription ( )
41
46
42
47
/// Hold the seek time, if a seek was requested
Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ open class AudioPlayer {
81
81
return entry. progress
82
82
}
83
83
84
+ /// The number of audio frames that have been played
85
+ public var framesPlayed : Int {
86
+ guard playerContext. internalState != . pendingNext else { return 0 }
87
+ playerContext. entriesLock. lock ( )
88
+ let playingEntry = playerContext. audioPlayingEntry
89
+ playerContext. entriesLock. unlock ( )
90
+ guard let entry = playingEntry else { return 0 }
91
+ return entry. framesPlayed
92
+ }
93
+
84
94
public private( set) var customAttachedNodes = [ AVAudioNode] ( )
85
95
86
96
/// The current configuration of the player.
You can’t perform that action at this time.
0 commit comments