Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MultiSegmentPlayer to create its own audio engine #146

Merged
merged 3 commits into from
Jan 9, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import AudioKitEX
import AudioKitUI
import SwiftUI

class MultiSegmentPlayerConductor: ObservableObject {
class MultiSegmentPlayerConductor: ObservableObject, HasAudioEngine {
let engine = AudioEngine()
let player = MultiSegmentAudioPlayer()

Expand Down Expand Up @@ -126,7 +126,7 @@ class MultiSegmentPlayerConductor: ObservableObject {
}

struct MultiSegmentPlayerView: View {
@ObservedObject var conductor = MultiSegmentPlayerConductor()
@StateObject var conductor = MultiSegmentPlayerConductor()

var currentTimeText: String {
let currentTime = String(format: "%.1f", conductor.timeStamp)
Expand Down Expand Up @@ -164,6 +164,12 @@ struct MultiSegmentPlayerView: View {
Spacer()
}
.navigationBarTitle(Text("Multi Segment Player"))
.onAppear {
conductor.start()
}
.onDisappear {
conductor.stop()
}
}

struct PlayPauseView: View {
Expand Down
Loading