How to use react-native-google-cast - 10 common examples

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
async onReady(data) {
    // TorrentStreamer.open(data.url, 'video/mp4')

    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,
github pct-org / native-app / app / screens / Player / PlayerScreen.working.js View on Github external
async componentDidMount() {
    Orientation.lockToLandscape()

    const { navigation: { state: { params: { magnet, item } } } } = this.props
    console.log('magnet', magnet)
    console.log('NativeModules.RNFSManager', RNFS.CachesDirectoryPath)
    console.log('castState', await GoogleCast.getCastState())

    this.serverUrl = await this.server.start()

    console.log('serving from', this.serverUrl)

    TorrentStreamer.addEventListener('error', this.onError.bind(this))
    TorrentStreamer.addEventListener('status', this.onStatus.bind(this))
    TorrentStreamer.addEventListener('ready', this.onReady.bind(this))
    TorrentStreamer.addEventListener('stop', this.onStop.bind(this))

    console.log(' TorrentStreamer.start(magnet)', TorrentStreamer.start(magnet))

    /*    GoogleCast.castMedia({
     title    : item.title,
     subtitle : item.summary,
     // studio: video.studio,
github pct-org / native-app / app / screens / Player / PlayerScreen.working.js View on Github external
async onReady(data) {
    // TorrentStreamer.open(data.url, 'video/mp4')

    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,
      })
github react-native-google-cast / react-native-google-cast / example / src / main.js View on Github external
componentDidMount() {
    this.registerListeners()

    GoogleCast.getCastState().then(console.log)
    // GoogleCast.showIntroductoryOverlay();

    const CAST_VIDEOS_URL =
      'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/f.json'
    fetch(CAST_VIDEOS_URL)
      .then(response => response.json())
      .then(data => {
        const mp4Url = data.categories[0].mp4
        const imagesUrl = data.categories[0].images

        this.setState({
          videos: data.categories[0].videos.map(video => ({
            title: video.title,
            subtitle: video.subtitle,
            studio: video.studio,
            duration: video.duration,
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 pct-org / native-app / app / screens / Player / PlayerScreen.working.js View on Github external
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,
      }, () => {
        this.video.presentFullscreenPlayer()

      })
    }
  }
github pct-org / native-app / app / mobile / screens / Player / PlayerManager / PlayerManager.js View on Github external
componentWillUnmount() {
    const { casting } = this.state

    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_ENDED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PLAYBACK_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PROGRESS_UPDATED)

    if (casting) {
      // Stop casting but keep the connection
      GoogleCast.stop()
    }
  }
github pct-org / native-app / app / mobile / screens / Player / PlayerManager / PlayerManager.js View on Github external
componentWillUnmount() {
    const { casting } = this.state

    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_ENDED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PLAYBACK_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PROGRESS_UPDATED)

    if (casting) {
      // Stop casting but keep the connection
      GoogleCast.stop()
    }
  }
github pct-org / native-app / app / mobile / screens / Player / PlayerManager / PlayerManager.js View on Github external
componentWillUnmount() {
    const { casting } = this.state

    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_ENDED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PLAYBACK_STARTED)
    GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PROGRESS_UPDATED)

    if (casting) {
      // Stop casting but keep the connection
      GoogleCast.stop()
    }
  }
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()
  }