SlideShare a Scribd company logo
1 of 43
Download to read offline
MARIO VIVIANI
E U T E C H N O L O G Y E V A N G E L I S T,
A M A Z O N D I G I T A L A P P S A N D G A M E S S E R V I C E S
@mariuxtheone marioviviani
IMPLEMENTING VOICE CONTROL
WITH THE ANDROID MEDIA SESSION API
ON AMAZON FIRE TV
I T ’ S A - M E !
Ma r io V ivia n i
EU Technology Evangelist, Amazon DAGS
@mariuxtheone
Android Developer since 2010
95+ apps published
12,000,000+ downloads
Google Developer Expert 2013-15
Startup Founder, Co-Worker
Speaker at: Droidcon,
Casual Connect, Big Android BBQ,
Google I/O
bit.ly/firetvspecs
FullHD
Quad-core CPU 1.3 GHz
1 GB RAM
(up to 1080p,60fps)
WiFi – Bluetooth 4.1
8 GB Internal Storage
(actual formatted capacity will be less)
4K compatible
Quad-core CPU 1.5GHz
2 GB RAM
(up to 2160p, 60fps)
WiFi – Bluetooth 4.1
8 GB Internal Storage
(actual formatted capacity will be less)
HDR10 Support
FIRE TV FIRE TV STICK
FIRE TV + ECHO
*available in US only
INTEGRATING
MEDIA SESSIONS
ON ANDROID
S U P P O RT E D V O I C E C O M M A N D S
Command Type Sample Voice Command Description
Play "Alexa, play"
"Alexa, resume"
Plays/Resumes the media.
Pause "Alexa, pause"
"Alexa, stop"
Pauses the media.
Fast-forward "Alexa, fast-forward 30 seconds"
"Alexa, fast-forward"
Fast-forwards the media by the given
duration. If no duration is provided, the
default is 10 seconds.
Rewind "Alexa, rewind 30 seconds"
"Alexa, rewind"
Rewinds the media by the given
duration. If no duration is provided, the
default is 10 seconds.
Next "Alexa, next" Triggers the next command and plays
the next media in the playlist.
Previous "Alexa, previous" Triggers the previous command and
plays the previous media in the playlist.
Restart "Alexa, restart" Seeks back to beginning of the media.
MediaSession
onPlay() onPause() onSkipToNext() onSeekTo()
Media Player
…
MediaSession Callbacks
MediaSession
onPlay() onPause() onSkipToNext() onSeekTo()
“Alexa, pause”
Media Player
pause()
S T E P S TO I M P L E M E N T M E D I A S E S S I O N
1.Initialise Video Player
2.Initialise Media Session
3.Configure Actions
4.Manage Media Session in Activity LifeCycle
5.Set up Media Session Callbacks
INITIALISE
VIDEO PLAYER
A D D V O I C E C O N T R O L P E R M I S S I O N T O A N D R O I D M A N I F E S T
<uses-permission
android:name="com.amazon.permission.media.session.voicecommandcontrol" />
I N I T I A L I S E T H E M E D I A P L AY E R
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the video player view
setContentView(R.layout.activity_media_session);
mVideo = (VideoView) findViewById(R.id.video_view);
…
}
I N I T I A L I S E T H E M E D I A C O N T R O L L E R A N D T H E V I D E O U R I
@Override
protected void onStart() {
super.onStart();
//Initialize the media controller for the video player
final MediaController mediaController = new MediaController(MediaSessionActivity.this);
mediaController.hide();
//Set the URI of the video
mVideo.setMediaController(mediaController);
//Set the URI of the video
mVideo.setVideoURI(“myvideoURL.mp4”);
mVideo.requestFocus();
...
INITIALISE
MEDIA SESSION
I N I T I A L I S E T H E M E D I A S E S S I O N
mVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
//Initialize the the media session
mMediaSession = new MediaSession(getApplicationContext(), TAG);
//Assign the Callbacks to the Media Session
mMediaSession.setCallback(getMediaSessionCallback());
//Set the flags that allow the app to take over the remote controls
mMediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
...
ADD ACTIONS TO
MEDIA SESSION
@Override
public void onPrepared(MediaPlayer mp) {
...
PlaybackStateCompat state = new PlaybackStateCompat.Builder()
.setActions(PlaybackState.ACTION_PLAY_PAUSE
| PlaybackState.ACTION_PLAY
| PlaybackState.ACTION_PAUSE
| PlaybackState.ACTION_FAST_FORWARD
| PlaybackState.ACTION_REWIND
| PlaybackState.ACTION_SKIP_TO_NEXT
| PlaybackState.ACTION_SKIP_TO_PREVIOUS)
.setState(PlaybackState.STATE_PLAYING,
mVideo.getCurrentPosition(), 1.0f)
.build();
mMediaSession.setPlaybackState(state);
mMediaSession.setActive(true);
}
C R E AT E A P L AY B A C K S TAT E – A C T I O N S - A C T I VAT E
MANAGE
MEDIA SESSION IN
ACTIVITY LIFECYCLE
M A N A G E A C T I V I T Y L I F E C Y C L E – O N PA U S E
@Override
protected void onPause() {
// Pause the activity
super.onPause();
// Pause the video player
mPlaybackState = PlaybackState.STATE_PAUSED;
mVideo.pause();
//deactivate the media session
mMediaSession.setActive(false);
mMediaSession.setPlaybackState(new PlaybackState.Builder()
.setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f)
.setActions(getActions())
.build());
}
M A N A G E A C T I V I T Y L I F E C Y C L E – O N S TO P
@Override
protected void onStop() {
// Stop the activity
super.onStop();
// Pause the video player
mPlaybackState = PlaybackState.STATE_STOPPED;
mVideo.stopPlayback();
//deactivate the media session
mMediaSession.setActive(false);
mMediaSession.setPlaybackState(new PlaybackState.Builder()
.setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f)
.setActions(getActions())
.build());
}
M A N A G E A C T I V I T Y L I F E C Y C L E – O N R E S U M E
@Override
protected void onResume() {
super.onResume();
mMediaSession.setActive(true);
mPlaybackState = PlaybackState.STATE_PLAYING;
mMediaSession.setPlaybackState(new PlaybackState.Builder()
.setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f)
.setActions(getActions())
.build());
mVideo.requestFocus();
mVideo.start();
}
M A N A G E A C T I V I T Y L I F E C Y C L E – O N D E S T R O Y
@Override
protected void onDestroy() {
//We release the media session as we’re destroying the Activity
if (mMediaSession != null) {
mMediaSession.release();
mMediaSession = null;
}
super.onDestroy();
}
SET MEDIA SESSION
CALLBACKS
M E D I A S E S S I O N C A L L B A C K S
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
@Override
public void onPlay() { }
@Override
public void onPause() { }
@Override
public void onSeekTo(long pos) { }
@Override
public void onFastForward() { }
@Override
public void onSkipToNext() { }
...
M E D I A S E S S I O N C A L L B A C K S - P L AY
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
@Override
public void onPlay() {
mPlaybackState = PlaybackState.STATE_PLAYING;
mVideo.start();
updatePlaybackState(mPlaybackState, mVideo.getCurrentPosition(),1.0f );
mMediaController.hide();
}
...
M E D I A S E S S I O N C A L L B A C K S - PA U S E
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
...
@Override
public void onPause() {
mPlaybackState = PlaybackState.STATE_PAUSED;
mVideo.pause();
updatePlaybackState(mPlaybackState, mVideo.getCurrentPosition(),1.0f );
mMediaController.show();
}
...
M E D I A S E S S I O N C A L L B A C K S – S E E K TO
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
...
@Override
public void onSeekTo(long pos) {
mPlaybackState = PlaybackState.STATE_BUFFERING;
mVideo.seekTo(mVideo.getCurrentPosition() + (int) pos);
}
...
M E D I A S E S S I O N C A L L B A C K S – FA S T F O RWA R D
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
...
@Override
public void onFastForward() {
mPlaybackState = PlaybackState.STATE_BUFFERING;
mVideo.seekTo(mVideo.getCurrentPosition() + 10 * 1000);
}
...
M E D I A S E S S I O N C A L L B A C K S – S K I P TO N E X T
private MediaSession.Callback getMediaSessionCallback() {
return new MediaSession.Callback() {
...
@Override
public void onSkipToNext() {
mPlaybackState = PlaybackState.STATE_SKIPPING_TO_NEXT;
//Skip to the next video in the playlist
skipToNextVideo();
}
...
R E C A P : S T E P S TO I M P L E M E N T M E D I A S E S S I O N
1.Initialise Video Player
2.Initialise Media Session
3.Configure Actions
4.Manage Media Session in Activity LifeCycle
5.Set up Media Session Callbacks
BUILDING APPS
FOR TV
IN MINUTES
F I R E A P P B U I L D E R
STREAMING MEDIA PLAYERS
Plug and Play template for audio and video
apps. Create an app in less than 1 hour.
E A S Y, FA S T A N D
B E A U T I F U L
Contains modules (plugins) to enable advanced
functionality
Handles JSON feeds, branding and
customisation
Supports Amazon Fire TV family
Fully supports Media Session API + Voice
Controls
M O D U L E S
Social logins
In-App Purchasing
& Subscriptions
Ads
Analytics
Media Player AD
F I R E A P P B U I L D E R W O R K F L O W
CONFIGURE YOUR
FEED LAUNCH THE APP!
CUSTOMIZE UI &
MODULAR COMPONENTS
SETUP RECIPE FOR
CATEGORIES AND CONTENTS
JSON
S TA RT TO D AY !
D O W N L O A D
github.com/amzn/fire-app-builder
D O C U M E N TAT I O N
bit.ly/FireAppBuilderDoc
bit.ly/firetvebook
F R E E E B O O K !
THANK YOU!
Mario Viviani
@mariuxtheone
@AmazonAppDev
vivianim@amazon.co.uk
developer.amazon.com/appstore
bit.ly/firetvebook

More Related Content

What's hot

Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embeddedtrx2001
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Opersys inc.
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work managerbhatnagar.gaurav83
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Introduction to Operating System and its Types
Introduction to Operating System and its TypesIntroduction to Operating System and its Types
Introduction to Operating System and its Typessundas Shabbir
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with PieOpersys inc.
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia FrameworkOpersys inc.
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALOpersys inc.
 
Designing of media player
Designing of media playerDesigning of media player
Designing of media playerNur Islam
 

What's hot (20)

Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embedded
 
Android Audio System
Android Audio SystemAndroid Audio System
Android Audio System
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Introduction to Operating System and its Types
Introduction to Operating System and its TypesIntroduction to Operating System and its Types
Introduction to Operating System and its Types
 
Deep Dive into the AOSP
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Programming guide for linux usb device drivers
Programming guide for linux usb device driversProgramming guide for linux usb device drivers
Programming guide for linux usb device drivers
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Designing of media player
Designing of media playerDesigning of media player
Designing of media player
 

Similar to IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE TV - Mario Viviani

First meet with Android Auto
First meet with Android AutoFirst meet with Android Auto
First meet with Android AutoJohnny Sung
 
The unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingThe unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingMatteo Bonifazi
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidAlessandro Martellucci
 
The sounds of Android (Android Makers 2018)
The sounds of Android (Android Makers 2018)The sounds of Android (Android Makers 2018)
The sounds of Android (Android Makers 2018)Yannick Lemin
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in AndroidPerfect APK
 
Flash runtime on mobile
Flash runtime on mobileFlash runtime on mobile
Flash runtime on mobilehoward-wu
 
KKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - DolphinKKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - DolphinLiyao Chen
 
Adobe OSMF Overview
Adobe OSMF OverviewAdobe OSMF Overview
Adobe OSMF OverviewYoss Cohen
 
Videos on Android - Stuff What I Learned
Videos on Android - Stuff What I LearnedVideos on Android - Stuff What I Learned
Videos on Android - Stuff What I LearnedMark Hemmings
 
Reactive Programming with Rx
 Reactive Programming with Rx Reactive Programming with Rx
Reactive Programming with RxC4Media
 
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...Amazon Appstore Developers
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18종인 전
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsVIA Embedded
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at NetflixC4Media
 
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...Amitesh Madhur
 

Similar to IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE TV - Mario Viviani (20)

First meet with Android Auto
First meet with Android AutoFirst meet with Android Auto
First meet with Android Auto
 
Video service
Video serviceVideo service
Video service
 
Java media framework
Java media frameworkJava media framework
Java media framework
 
The unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingThe unconventional devices for the Android video streaming
The unconventional devices for the Android video streaming
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
 
The sounds of Android (Android Makers 2018)
The sounds of Android (Android Makers 2018)The sounds of Android (Android Makers 2018)
The sounds of Android (Android Makers 2018)
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
 
Flash runtime on mobile
Flash runtime on mobileFlash runtime on mobile
Flash runtime on mobile
 
Integrando sua app Android com Chromecast
Integrando sua app Android com ChromecastIntegrando sua app Android com Chromecast
Integrando sua app Android com Chromecast
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
KKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - DolphinKKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - Dolphin
 
Adobe OSMF Overview
Adobe OSMF OverviewAdobe OSMF Overview
Adobe OSMF Overview
 
Videos on Android - Stuff What I Learned
Videos on Android - Stuff What I LearnedVideos on Android - Stuff What I Learned
Videos on Android - Stuff What I Learned
 
Android Media Hacks
Android Media HacksAndroid Media Hacks
Android Media Hacks
 
Reactive Programming with Rx
 Reactive Programming with Rx Reactive Programming with Rx
Reactive Programming with Rx
 
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...
Creating Rich Multi-Screen Experiences on Android with Amazon Fling - Mario V...
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded Applications
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
 
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
 

More from Amazon Appstore Developers

Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...
Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...
Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...Amazon Appstore Developers
 
Designing Apps in the Age of Media Streaming: Optimise Your Content for TV
Designing Apps in the Age of Media Streaming: Optimise Your Content for TVDesigning Apps in the Age of Media Streaming: Optimise Your Content for TV
Designing Apps in the Age of Media Streaming: Optimise Your Content for TVAmazon Appstore Developers
 
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...Amazon Appstore Developers
 
Scale up your apps and games building new experiences on amazon fire tv
Scale up your apps and games building new experiences on amazon fire tvScale up your apps and games building new experiences on amazon fire tv
Scale up your apps and games building new experiences on amazon fire tvAmazon Appstore Developers
 
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...Amazon Appstore Developers
 
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...Amazon Appstore Developers
 
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario Viviani
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario VivianiIn-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario Viviani
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario VivianiAmazon Appstore Developers
 
5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani
5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani
5 Best Practices of Top-Earning Mobile Apps and Games - Mario VivianiAmazon Appstore Developers
 
Developing Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App BuilderDeveloping Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App BuilderAmazon Appstore Developers
 
Building New Experiences on Amazon Fire TV - Mario Viviani
Building New Experiences on Amazon Fire TV - Mario VivianiBuilding New Experiences on Amazon Fire TV - Mario Viviani
Building New Experiences on Amazon Fire TV - Mario VivianiAmazon Appstore Developers
 
Amazon Underground, a Year After - Mario Viviani
Amazon Underground, a Year After - Mario VivianiAmazon Underground, a Year After - Mario Viviani
Amazon Underground, a Year After - Mario VivianiAmazon Appstore Developers
 
Is This Really All There Is? More Ways to Monetize - Mike Hines
Is This Really All There Is? More Ways to Monetize - Mike HinesIs This Really All There Is? More Ways to Monetize - Mike Hines
Is This Really All There Is? More Ways to Monetize - Mike HinesAmazon Appstore Developers
 
Bringing Unity Games to Fire TV - Peter Heinrich
Bringing Unity Games to Fire TV - Peter HeinrichBringing Unity Games to Fire TV - Peter Heinrich
Bringing Unity Games to Fire TV - Peter HeinrichAmazon Appstore Developers
 
Working Backward from Amazon Customers: Audience Marketing Strategies - Lau...
Working Backward from Amazon Customers:  Audience Marketing Strategies  - Lau...Working Backward from Amazon Customers:  Audience Marketing Strategies  - Lau...
Working Backward from Amazon Customers: Audience Marketing Strategies - Lau...Amazon Appstore Developers
 
Designing for Tablet - Patterns and Best Practices
Designing for Tablet - Patterns and Best Practices Designing for Tablet - Patterns and Best Practices
Designing for Tablet - Patterns and Best Practices Amazon Appstore Developers
 
Actionable Analytics: Using Better Data Better
Actionable Analytics: Using Better Data BetterActionable Analytics: Using Better Data Better
Actionable Analytics: Using Better Data BetterAmazon Appstore Developers
 

More from Amazon Appstore Developers (20)

Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...
Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...
Bring Your Content Forward on Amazon Fire TV: Creating TV Apps in the Age of ...
 
Designing Apps in the Age of Media Streaming: Optimise Your Content for TV
Designing Apps in the Age of Media Streaming: Optimise Your Content for TVDesigning Apps in the Age of Media Streaming: Optimise Your Content for TV
Designing Apps in the Age of Media Streaming: Optimise Your Content for TV
 
Bring Your Content Forward on Amazon Fire TV
Bring Your Content Forward on Amazon Fire TVBring Your Content Forward on Amazon Fire TV
Bring Your Content Forward on Amazon Fire TV
 
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...
Developing Media Streaming Android Apps the Easy Way with Fire App Builder - ...
 
Scale up your apps and games building new experiences on amazon fire tv
Scale up your apps and games building new experiences on amazon fire tvScale up your apps and games building new experiences on amazon fire tv
Scale up your apps and games building new experiences on amazon fire tv
 
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...
Why and How to Add In-App Purchasing and Subscriptions to your Apps - Mario V...
 
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...
Working Backward from Amazon Customers - Audience Marketing Strategies for Ap...
 
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario Viviani
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario VivianiIn-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario Viviani
In-App Purchase Like a Pro: Best Practices from the Top 50 Apps - Mario Viviani
 
5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani
5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani
5 Best Practices of Top-Earning Mobile Apps and Games - Mario Viviani
 
Developing Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App BuilderDeveloping Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App Builder
 
Building New Experiences on Amazon Fire TV - Mario Viviani
Building New Experiences on Amazon Fire TV - Mario VivianiBuilding New Experiences on Amazon Fire TV - Mario Viviani
Building New Experiences on Amazon Fire TV - Mario Viviani
 
Amazon Underground, a Year After - Mario Viviani
Amazon Underground, a Year After - Mario VivianiAmazon Underground, a Year After - Mario Viviani
Amazon Underground, a Year After - Mario Viviani
 
Is This Really All There Is? More Ways to Monetize - Mike Hines
Is This Really All There Is? More Ways to Monetize - Mike HinesIs This Really All There Is? More Ways to Monetize - Mike Hines
Is This Really All There Is? More Ways to Monetize - Mike Hines
 
Bringing Unity Games to Fire TV - Peter Heinrich
Bringing Unity Games to Fire TV - Peter HeinrichBringing Unity Games to Fire TV - Peter Heinrich
Bringing Unity Games to Fire TV - Peter Heinrich
 
Working Backward from Amazon Customers: Audience Marketing Strategies - Lau...
Working Backward from Amazon Customers:  Audience Marketing Strategies  - Lau...Working Backward from Amazon Customers:  Audience Marketing Strategies  - Lau...
Working Backward from Amazon Customers: Audience Marketing Strategies - Lau...
 
Designing for Tablet - Patterns and Best Practices
Designing for Tablet - Patterns and Best Practices Designing for Tablet - Patterns and Best Practices
Designing for Tablet - Patterns and Best Practices
 
Amazon Lab126
Amazon Lab126Amazon Lab126
Amazon Lab126
 
Workshop: Integrating Amazon APIs in Unity
Workshop: Integrating Amazon APIs in Unity Workshop: Integrating Amazon APIs in Unity
Workshop: Integrating Amazon APIs in Unity
 
Keynote - What's New in Amazon Appstore 2016
Keynote - What's New in Amazon Appstore 2016Keynote - What's New in Amazon Appstore 2016
Keynote - What's New in Amazon Appstore 2016
 
Actionable Analytics: Using Better Data Better
Actionable Analytics: Using Better Data BetterActionable Analytics: Using Better Data Better
Actionable Analytics: Using Better Data Better
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE TV - Mario Viviani

  • 1. MARIO VIVIANI E U T E C H N O L O G Y E V A N G E L I S T, A M A Z O N D I G I T A L A P P S A N D G A M E S S E R V I C E S @mariuxtheone marioviviani IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE TV
  • 2. I T ’ S A - M E ! Ma r io V ivia n i EU Technology Evangelist, Amazon DAGS @mariuxtheone Android Developer since 2010 95+ apps published 12,000,000+ downloads Google Developer Expert 2013-15 Startup Founder, Co-Worker Speaker at: Droidcon, Casual Connect, Big Android BBQ, Google I/O
  • 3.
  • 4.
  • 5. bit.ly/firetvspecs FullHD Quad-core CPU 1.3 GHz 1 GB RAM (up to 1080p,60fps) WiFi – Bluetooth 4.1 8 GB Internal Storage (actual formatted capacity will be less) 4K compatible Quad-core CPU 1.5GHz 2 GB RAM (up to 2160p, 60fps) WiFi – Bluetooth 4.1 8 GB Internal Storage (actual formatted capacity will be less) HDR10 Support FIRE TV FIRE TV STICK
  • 6. FIRE TV + ECHO
  • 7.
  • 10. S U P P O RT E D V O I C E C O M M A N D S Command Type Sample Voice Command Description Play "Alexa, play" "Alexa, resume" Plays/Resumes the media. Pause "Alexa, pause" "Alexa, stop" Pauses the media. Fast-forward "Alexa, fast-forward 30 seconds" "Alexa, fast-forward" Fast-forwards the media by the given duration. If no duration is provided, the default is 10 seconds. Rewind "Alexa, rewind 30 seconds" "Alexa, rewind" Rewinds the media by the given duration. If no duration is provided, the default is 10 seconds. Next "Alexa, next" Triggers the next command and plays the next media in the playlist. Previous "Alexa, previous" Triggers the previous command and plays the previous media in the playlist. Restart "Alexa, restart" Seeks back to beginning of the media.
  • 11. MediaSession onPlay() onPause() onSkipToNext() onSeekTo() Media Player … MediaSession Callbacks
  • 12. MediaSession onPlay() onPause() onSkipToNext() onSeekTo() “Alexa, pause” Media Player pause()
  • 13. S T E P S TO I M P L E M E N T M E D I A S E S S I O N 1.Initialise Video Player 2.Initialise Media Session 3.Configure Actions 4.Manage Media Session in Activity LifeCycle 5.Set up Media Session Callbacks
  • 15. A D D V O I C E C O N T R O L P E R M I S S I O N T O A N D R O I D M A N I F E S T <uses-permission android:name="com.amazon.permission.media.session.voicecommandcontrol" />
  • 16. I N I T I A L I S E T H E M E D I A P L AY E R @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the video player view setContentView(R.layout.activity_media_session); mVideo = (VideoView) findViewById(R.id.video_view); … }
  • 17. I N I T I A L I S E T H E M E D I A C O N T R O L L E R A N D T H E V I D E O U R I @Override protected void onStart() { super.onStart(); //Initialize the media controller for the video player final MediaController mediaController = new MediaController(MediaSessionActivity.this); mediaController.hide(); //Set the URI of the video mVideo.setMediaController(mediaController); //Set the URI of the video mVideo.setVideoURI(“myvideoURL.mp4”); mVideo.requestFocus(); ...
  • 19. I N I T I A L I S E T H E M E D I A S E S S I O N mVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { //Initialize the the media session mMediaSession = new MediaSession(getApplicationContext(), TAG); //Assign the Callbacks to the Media Session mMediaSession.setCallback(getMediaSessionCallback()); //Set the flags that allow the app to take over the remote controls mMediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); ...
  • 21. @Override public void onPrepared(MediaPlayer mp) { ... PlaybackStateCompat state = new PlaybackStateCompat.Builder() .setActions(PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_FAST_FORWARD | PlaybackState.ACTION_REWIND | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .setState(PlaybackState.STATE_PLAYING, mVideo.getCurrentPosition(), 1.0f) .build(); mMediaSession.setPlaybackState(state); mMediaSession.setActive(true); } C R E AT E A P L AY B A C K S TAT E – A C T I O N S - A C T I VAT E
  • 23. M A N A G E A C T I V I T Y L I F E C Y C L E – O N PA U S E @Override protected void onPause() { // Pause the activity super.onPause(); // Pause the video player mPlaybackState = PlaybackState.STATE_PAUSED; mVideo.pause(); //deactivate the media session mMediaSession.setActive(false); mMediaSession.setPlaybackState(new PlaybackState.Builder() .setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f) .setActions(getActions()) .build()); }
  • 24. M A N A G E A C T I V I T Y L I F E C Y C L E – O N S TO P @Override protected void onStop() { // Stop the activity super.onStop(); // Pause the video player mPlaybackState = PlaybackState.STATE_STOPPED; mVideo.stopPlayback(); //deactivate the media session mMediaSession.setActive(false); mMediaSession.setPlaybackState(new PlaybackState.Builder() .setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f) .setActions(getActions()) .build()); }
  • 25. M A N A G E A C T I V I T Y L I F E C Y C L E – O N R E S U M E @Override protected void onResume() { super.onResume(); mMediaSession.setActive(true); mPlaybackState = PlaybackState.STATE_PLAYING; mMediaSession.setPlaybackState(new PlaybackState.Builder() .setState(mPlaybackState, mVideo.getCurrentPosition(),1.0f) .setActions(getActions()) .build()); mVideo.requestFocus(); mVideo.start(); }
  • 26. M A N A G E A C T I V I T Y L I F E C Y C L E – O N D E S T R O Y @Override protected void onDestroy() { //We release the media session as we’re destroying the Activity if (mMediaSession != null) { mMediaSession.release(); mMediaSession = null; } super.onDestroy(); }
  • 28. M E D I A S E S S I O N C A L L B A C K S private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { @Override public void onPlay() { } @Override public void onPause() { } @Override public void onSeekTo(long pos) { } @Override public void onFastForward() { } @Override public void onSkipToNext() { } ...
  • 29. M E D I A S E S S I O N C A L L B A C K S - P L AY private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { @Override public void onPlay() { mPlaybackState = PlaybackState.STATE_PLAYING; mVideo.start(); updatePlaybackState(mPlaybackState, mVideo.getCurrentPosition(),1.0f ); mMediaController.hide(); } ...
  • 30. M E D I A S E S S I O N C A L L B A C K S - PA U S E private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { ... @Override public void onPause() { mPlaybackState = PlaybackState.STATE_PAUSED; mVideo.pause(); updatePlaybackState(mPlaybackState, mVideo.getCurrentPosition(),1.0f ); mMediaController.show(); } ...
  • 31. M E D I A S E S S I O N C A L L B A C K S – S E E K TO private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { ... @Override public void onSeekTo(long pos) { mPlaybackState = PlaybackState.STATE_BUFFERING; mVideo.seekTo(mVideo.getCurrentPosition() + (int) pos); } ...
  • 32. M E D I A S E S S I O N C A L L B A C K S – FA S T F O RWA R D private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { ... @Override public void onFastForward() { mPlaybackState = PlaybackState.STATE_BUFFERING; mVideo.seekTo(mVideo.getCurrentPosition() + 10 * 1000); } ...
  • 33. M E D I A S E S S I O N C A L L B A C K S – S K I P TO N E X T private MediaSession.Callback getMediaSessionCallback() { return new MediaSession.Callback() { ... @Override public void onSkipToNext() { mPlaybackState = PlaybackState.STATE_SKIPPING_TO_NEXT; //Skip to the next video in the playlist skipToNextVideo(); } ...
  • 34. R E C A P : S T E P S TO I M P L E M E N T M E D I A S E S S I O N 1.Initialise Video Player 2.Initialise Media Session 3.Configure Actions 4.Manage Media Session in Activity LifeCycle 5.Set up Media Session Callbacks
  • 36.
  • 37. F I R E A P P B U I L D E R STREAMING MEDIA PLAYERS Plug and Play template for audio and video apps. Create an app in less than 1 hour. E A S Y, FA S T A N D B E A U T I F U L Contains modules (plugins) to enable advanced functionality Handles JSON feeds, branding and customisation Supports Amazon Fire TV family Fully supports Media Session API + Voice Controls
  • 38.
  • 39. M O D U L E S Social logins In-App Purchasing & Subscriptions Ads Analytics Media Player AD
  • 40. F I R E A P P B U I L D E R W O R K F L O W CONFIGURE YOUR FEED LAUNCH THE APP! CUSTOMIZE UI & MODULAR COMPONENTS SETUP RECIPE FOR CATEGORIES AND CONTENTS JSON
  • 41. S TA RT TO D AY ! D O W N L O A D github.com/amzn/fire-app-builder D O C U M E N TAT I O N bit.ly/FireAppBuilderDoc
  • 42. bit.ly/firetvebook F R E E E B O O K !