How to use the react-native-google-cast.getCastState 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
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 / mobile / screens / Player / PlayerManager / PlayerManager.js View on Github external
componentDidMount() {
    GoogleCast.EventEmitter.addListener(GoogleCast.SESSION_STARTED, this.handleCastSessionStarted)
    GoogleCast.EventEmitter.addListener(GoogleCast.SESSION_ENDED, this.handleCastSessionEnded)
    GoogleCast.EventEmitter.addListener(GoogleCast.MEDIA_PLAYBACK_STARTED, this.handleMediaPlaybackStarted)
    GoogleCast.EventEmitter.addListener(GoogleCast.MEDIA_PROGRESS_UPDATED, this.handleMediaProgressUpdate)
    GoogleCast.EventEmitter.addListener(GoogleCast.MEDIA_PLAYBACK_ENDED, this.handleMediaPlaybackEnded)

    GoogleCast.getCastState().then((state) => {
      if (state.toLowerCase() === 'connected') {
        this.setState({
          casting: true,
        })
      }
    })
  }