Video Streaming dal player standard Android verso device non convenzionali GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chi siamo? +AlessandroMartellu cci +MatteoBonifazi u om
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Reply spa è una delle società leader nel settore IT Opera in Italia, Germania, UK, Benelux, USA and Brasile. Open Reply è una società del Gruppo Reply spa specializzata su tecnologie open source, soluzioni web multicanale and applicazioni mobile. Based in Rome, Open Reply’s Android Lab is a young team of over 20 engineers 100% focused on Android development. Specializzati in applicazioni broadcasting, bancarie e customizzazioni del sistema operativo Android. Open Reply & Android Lab
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Ex1 – Streaming di un contenuto su smartphone e tablet Ex2 – Streaming con app per Ex3 – Divertirsi utilizzando il Codelab Millestones
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Android multimedia framework Android supporta diversi tipi di formati per lo streaming di contenuti I file possono essere salvati all’interno dell’applicazione (raw resources, standalone files) oppure utilizzando servizi di OTT streaming. La documentazione dell’Android multimedia framework copre soltanto i casi base.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Tipi supportati HttpLiveStreaming Protocol 3 è supportato da Android 4.0. La migliore implementazione si trova su dispositivi KitKat. source: formats.html formats.html
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci //1. Recuperare la view VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview); //2. Setup video url myVideoView.setVideoURI(Uri.parse(SrcPath)); //3. Impostare il video controller myVideoView.setMediaController(new MediaController(this)); //4. Inizio dello streaming. myVideoView.requestFocus(); myVideoView.start(); android.widget.VideoView MediaPlayer code example
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Android TV L’intrattenimento per la nostra sala Source:
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Nexus Player Source: 1.8GHz Quad Core, Intel® Atom™ Imagination PowerVR Series 6 Graphics 2D/3D Engine 1GB RAM 8GB storage Asus device – 235 g
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Android TV app caratteristiche tecniche Android TV device hanno Android Lollipop 5.0. Android TV possiede la stessa versione del Multimedia Framework dei normali dispisitvi Android. Android TV app sono compatibili dalle API 17. Basate sulla libreria Leanback Android Support.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci 10 feet experience Smartphone 5” 320 dp TV Full HD 30” 320 dpi 3 metri 50 centimetri
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Manifest features Supportare landscape Portrait activity sono escluse
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Manifest features No touch screen
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Manifest features Limit sensor
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Keep calm and lean back!! Fornisce componeti built-in customizzati per lo schermo della TV
Leanback support library <uses-feature android:name="android.software.leanback" android:required="true" /> <application android:allowBackup="false” > <activity android:name="MainActivity” android:screenOrientation="landscape" > GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback support library Model View Presenter Presenter Model View GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback UI component BroswerFragment Permette agli sviluppatore di avere un layout della propria applicazione già precostruito e pronto all’uso.
Leanback UI component DetailFragment Mostra informazioni riguardo i contenuti selezionati dall’utente. GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast un cast-ready device per la multi-screen experience source: GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast caratteristiche hardware source: GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast componenti Google Cast Esperienza Multi-Screen Google Cast SDK Applicazione client Android app iOS app Chrome app Applicazione receiver Default Media Receiver Styled Media Receiver Custom Media Receiver GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Applicazione client Android librerie e dipendenze Versione minima supportata è la 9 (Gingerbread) MediaRouter API nel android-support-v7 Google Play Services AppCompat API nel android-support-v7 GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Applicazione client Android tipico flusso di esecuzione Client usa MediaRouter per fare il discovery: MediaRouter.addCallback MediaRouter informa il client della route selezionata: MediaRouter.Callback.onRouteSelected Il client recupera l’istanza di CastDevice: CastDevice.getFromBundle Il client usa GoogleApiClient per collegarsi allo strato di sistema: GoogleApiClient.Builder Il client avvia l’applicazione receiver: Cast.CastApi.launchApplication Il client instaura il canale di comunicazione: Cast.CastApi.setMessageReceivedCallbacks Il client invia messaggi di protocollo sul canale di trasmissione: Cast.CastApi.sendMessage source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Ricerca Cast-Ready Device caratteristiche Remote Playback Live AudioLive Video MediaRouteSelector.Builder mediaRouteSelectorBuilder = new MediaRouteSelector.Builder(); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_REM OTE_PLAYBACK); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE _AUDIO); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE _VIDEO); MediaRouterSelector mediaRouterSelector = mediaRouterSelectorBuilder.build();
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Media Cast Button facile approccio alla ricerca source: developers.google.com public boolean onCreateOptionsMenu(Menu menu) { MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem); mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); …. }
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Applicazione Receiver quale mistero? Che cosa è? Applicazione HTML5 - Javascript Che cosa fa? Visualizza il contenuto a video Gestisce i messaggi Quali tipo esistono? Default Media Receiver Styled Media ReceiverCustom Media Receiver
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Default Media Receiver il più semplice Off-the-shelf Nessuna personalizzazione Nessuna registrazione Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Styled Media Receiver semplice e personalizzabile Simile al Default Media Player CSS per la personalizzazione Registrazione Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Custom Media Receiver (1/3) qualsiasi cosa Web Applicaiton Debug(able) at 9222 Registrazione Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci Custom Media Receiver (2/3) esempio Example minimum receiver window.mediaElement = document.getElementById('media'); window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance(); window.castReceiverManager.start();
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Custom Media Receiver (3/3) caratteristiche avanzate Video Codification/Decodification H.264 High Profile Level 4.1, 4.2 and 5 VP8 Adaptive Bitrate Streaming HTTP Live Streaming (HLS) Dynamic Adaptive Streaming over HTTP (MPEG-DASH) Smooth Streaming Digital Rights Management Play Ready DRM Widevine DRM Media Player Library
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Channel, Namespace e Protocol (1/2) comunicazione Protocol: insieme di messaggi Namespace: nome protocollo Channel: lo strato di comunicazione class CustomChannel implements Cast.MessageReceivedCallback { public String getNamespace() { return “urn:x-cast:com.channel.custom”; public void onMessageReceiver(CastDevice castDevice, String namespace, String message) { … } } … Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mCustomChannel.getNamespace(), mCustomChannel); …
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Channel, Namespace e Protocol (2/2) comunicazione Media Namespace: urn:x-cast:com.google.media.cast RemoteMediaPlayer MediaManager RECEIVER MEDIA CHANNEL … window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); … CLIENT MEDIA CHANNEL … Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mRemoteMediaPlayer.getNamespace(), mCustomChannel); …
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Google Api Client e Media Route Provider manufacturer Source: developers.google.com CastDevice selectedCastDevice = CastDevice.getFromBundle(selectedRouteInfo.getExtras); Cast.CastOptions.Builder apiOptionsBuilder = new Cast.CastOptions.Builder(selectedCastDevice, …); googleApiClient = new GoogleApiClient.Builder().addApi(Cast.API, apiOptionsBuilder.build()).build(); googleApiClient.connect(); Cast.CastApi.launchApplication(googleApiClient, applicationId, launchOptions); Cast.CastApi.joinApplication(googleApiClient); Cast.CastApi.stopApplication(googleApiClient); Cast.CastApi.leaveApplication(googleApiClient);
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci RemoteMediaPlayer …finalmente MediaInfo mediaInfo = new MediaInfo.Builder(" … mRemoteMediaPlayer = new RemoteMediaPlayer(); mRemoteMediaPlayer.load(mApiClient, mediaInfo, true); …
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Buona visione Source: Grazie a tutti
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Risorse Google Cast -> Chromecast App -> Google Cast Downloads -> Github -> Android TV -> Nvidia Guideline -> Github -> Android Mediaplayer-> ExoPlayer ->
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Libro Sviluppare applicazioni Android in sette giorni
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci Contatti +AlessandroMartellu cci +MatteoBonifazi u om