Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vizbee/685ebafa808f3439bfa5c47b84879978 to your computer and use it in GitHub Desktop.
Save vizbee/685ebafa808f3439bfa5c47b84879978 to your computer and use it in GitHub Desktop.

SmartPlay API returns true but content not playing on the receiver.

Example scenario

  • The sender is connected to the receiver.
  • The User selects any video to cast to the receiver.

Application code dos and don'ts

DO

Make sure AppAdapter methods are implemented

  • Step 1 - Make sure the following adapter method is implemented to return the success callback with the right metadata
func getVZBMetadata(
    fromVideo appVideoObject: Any,
    onSuccess successCallback: @escaping (VZBVideoMetadata) -> Void,
    onFailure failureCallback: @escaping (Error) -> Void
  ) {

    if let videoModel = appVideoObject as? VideoModel {
      let metadata = VZBVideoMetadata()
      metadata.guid = videoModel.videoId
      metadata.title = videoModel.title
      metadata.subTitle = videoModel.playListTitle
      metadata.imageURL = videoModel.imageURL
      metadata.isLive = videoModel.isLive
      
      successCallback(metadata)
      return
    }

    // default
    failureCallback(NSError(domain: "Unrecognized video type: \(appVideoObject)", code: 2, userInfo: nil))
  }
  • Step 2 - Make sure the following adapter method is implemented to return the success callback with the right stream information
func getVZBStreamInfo(
    fromVideo appVideoObject: Any,
    for _: VZBScreenType,
    onSuccess successCallback: @escaping (VZBVideoStreamInfo) -> Void,
    onFailure failureCallback: @escaping (Error) -> Void
  ) {

     if let videoModel = appVideoObject as? VideoModel {

        let streamInfo = VZBVideoStreamInfo()
        streamInfo.videoURL = videoModel.hlsURL
        stramInfo.guid = videoModel.guid
     
        // optional
        streamInfo.customStreamInfo = [
            "authToken" : "<authToken>",
            "refreshToken" : "<refreshToken>",
            ...
        ]
     
        successCallback(streamInfo)
        return
    }

     // default
     failureCallback(NSError(domain: "Unrecognized video type: \(appVideoObject)", code: 2, userInfo: nil))
  }
  • Step 3 - Make sure the receiver is able to deep-link to the player with the right playback information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment