问题描述:

I am using FreeStreamer in Swift and am trying to set the onStateChange block.

audioStream.onStateChange = { (state) in

if state == kFsAudioStreamBuffering {

//blah

}

}

I am getting this error:

Binary operator '==' cannot be applied to operands of type '(FSAudioStreamState)' and 'FSAudioStreamState'

Edit: Still the same error without the parentheses around state in the block params

EDIT: As a temporary fix, state.value == kFsAudioStreamBuffering.value works

网友答案:

try putting a dot (.) before kFsAudioStreamBuffering something like this:

if state == .kFsAudioStreamBuffering {
    //blah
}

UPDATE: Try this instead

audioStream.onStateChange = { state in
    if state.value == kFsAudioStreamBuffering.value {
        //blah
    }
}
网友答案:

It should be something like this to make it work.

    self.audioControler?.onStateChange = { (state:FSAudioStreamState) -> Void in
        switch state {
        case .fsAudioStreamRetrievingURL:
相关阅读:
Top