1.0.2 • Published 4 years ago

react-native-google-cast-ios v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-native-google-cast-ios

Instalation

yarn add react-native-google-cast-ios

then go to iOS project folder and

pod install

Usage

import GoogleCast, { RemoteMediaClient, CastButton } from 'react-native-google-cast-ios'

...

//cast button (Visible if has a device nearby)
<CastButton
  tintColor='#fff' //Tint color of button
  style={{}} //Inherits View props
  triggersDefaultCastDialog=true //Default true, if false application must handle cast session start
  accessibilityLabel=''
/>

//cast the video
const cast = (video) => {
    RemoteMediaClient.getCurrent()
      .loadMedia(video, { autoplay: true }) //See Video model
      .then(console.log)
      .catch(console.warn)
    GoogleCast.showExpandedControls()
  }

Video model

To cast a video, the object must be in MediaInfo pattern

{
      contentUrl: String, //Content to be played
      metadata: {
        images: [
          { url: String, width: Number, height: Number },
          { url: String, width: Number, height: Number },
        ],
        studio: String,
        subtitle: String,
        title: String,
        type: 'movie' | 'musicTrack' | 'photo' | 'tvShow',
      },
      streamDuration: Number,
    }
  }
}