Category: Blog, Android, Development

How to Implement Google Cast v3 in Your Android App – Helpful Library

The basic Google Cast v3 tutorial

Do you want to support Chromecast in your Android app so yours app’s users can stream media on their TVs? If yes, you will need to add Google Cast v3 into your Android App. I prepared for you small Android library – must-read which will make your implementation process simple, fast and agile. Enjoy!   

Challenge: How to Implement Google Cast v3 In Your Android App

Some time ago I wanted to support Chromecast in one of my Android applications. I thought I would add a few lines of code and users would be able to stream movies directly to their TVs. I was terribly wrong. The basic Google Cast v3 tutorial has over 3000 words and it’s outdated (e.g. the minimum SDK has been changed to 14). Here is the the table of contents:

cast1cast2

Solution: Casty – Android Library Which Saves Your Time

I’ve decided to simplify this process, so I created Casty – a library which greatly simplifies the implementation process and reduces the amount of boilerplate code required. Check it out: Casty

Casty takes care of the following:

  • CastContext initialization,
  • session management,
  • setting up the Expanded Controller Activity,
  • notification controls,
  • creating a OnConnectChangeListener, which reacts to connect/disconnect events,
  • providing functions that add widgets to the Activity’s layout, without modifying XML files.

Additionally, I’ve included an extensible CastyActivity class, which supports all of the above functionality straight out of the box – it adds a Casty field and sets up all the widgets. This is the fastest way of including Chromecast support in your Application.

Have a look at the simplest example:

However, extending CastyActivity may not work for everyone – you cannot extend any other class or choose which widget should be included. Casty also provides standard methods that add different types of widgets, which you can check on GitHub README.

Discover Details and Start Your Implementation Process

I hope that the Android library which I prepared will help you with implementation of media player for Chromecast fully consistent with Google Cast v3. Now start discovering Casty and see how easily and fast you can add Chromecast support to your Android App!