How to use the react-native-google-cast.castMedia function in react-native-google-cast

To help you get started, we’ve selected a few react-native-google-cast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pct-org / native-app / app / screens / Player / PlayerScreen.working.js View on Github external
const { navigation: { state: { params: { item } } } } = this.props

    console.log('onReady', data)
    console.log('item', item)
    console.log('castState', GoogleCast.getCastState())

    const { casting } = this.state

    if (casting || await GoogleCast.getCastState().toLowerCase() === 'connected') {
      const { navigation: { state: { params: { item } } } } = this.props
      console.log('data.url', data.url)
      const mediaUrl = this.serverUrl + data.url.replace(RNFS.CachesDirectoryPath, '')
      console.log('\n\n\nmediaUrl', mediaUrl)

      GoogleCast.castMedia({
        title   : item.title,
        subtitle: item.summary,
        // studio: video.studio,
        // duration: video.duration,
        mediaUrl,

        imageUrl : item.images.fanart.high,
        posterUrl: item.images.poster.high,
      })

      GoogleCast.launchExpandedControls()


    } else {
      this.setState({
        url: data.url,
github react-native-google-cast / react-native-google-cast / example / src / main.js View on Github external
cast(video) {
    GoogleCast.getCastDevice().then(console.log)
    GoogleCast.castMedia(video)
    GoogleCast.launchExpandedControls()
    this.sendMessage()
  }
github pct-org / native-app / app / mobile / screens / Player / PlayerManager / PlayerManager.js View on Github external
handleStartCasting = (force = false) => {
    const { item } = this.props
    const { casting, mediaUrl } = this.state

    if (force || casting) {
      Orientation.lockToPortrait()

      GoogleCast.castMedia({
        title: (
          item.type === 'episode'
            ? `${item.show.title}: ${item.number}. ${item.title}`
            : item.title
        ),
        subtitle: item.synopsis,
        mediaUrl: `${mediaUrl}?device=chromecast`,
        posterUrl: item.type === 'episode'
          ? item.show.images.poster.high
          : item.images.poster.high,
      })
    }
  }