Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AudioStreaming/Streaming/Audio Entry/AudioEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class AudioEntry {
return seekTime + (Double(framesState.played) / outputAudioFormat.sampleRate)
}

var framesPlayed: Int {
lock.lock(); defer { lock.unlock() }
return framesState.played
}

var audioStreamFormat = AudioStreamBasicDescription()

/// Hold the seek time, if a seek was requested
Expand Down
10 changes: 10 additions & 0 deletions AudioStreaming/Streaming/AudioPlayer/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ open class AudioPlayer {
return entry.progress
}

/// The number of audio frames that have been played
public var framesPlayed: Int {
guard playerContext.internalState != .pendingNext else { return 0 }
playerContext.entriesLock.lock()
let playingEntry = playerContext.audioPlayingEntry
playerContext.entriesLock.unlock()
guard let entry = playingEntry else { return 0 }
return entry.framesPlayed
}

public private(set) var customAttachedNodes = [AVAudioNode]()

/// The current configuration of the player.
Expand Down