Search code examples
iosgoogle-cast-sdk

Google Cast SDK RemoteMediaClient setStreamVolume not changing volume of cast on iOS


I am having the exact same issue as described in this issue, though it seems that on iOS there is no setVolume function in RemoteMediaClient.

For reference, here is what my setStreamVolume call looks like:

if let request = sessionManager.currentCastSession?.remoteMediaClient?.setStreamVolume(volume) {
        request.delegate = self
    }

In addition, other calls work just fine such as

if let request = sessionManager.currentCastSession?.remoteMediaClient?.pause() {
        request.delegate = self
    }

Does iOS have another function I need to call so set the volume, or is my implementation incorrect?


Solution

  • I actually found the solution. Make an instance of GCKUIDeviceVolumeController then when you call setVolume, it changes the volume of the current cast session.

    private let volumeController = GCKUIDeviceVolumeController()    
    volumeController.setVolume(volume)