Your SlideShare is downloading. ×

Chromecast - DevParty Torino 2014

253

Published on

Chromecast by Google - Gianluca Arbezzano @ CorleyCloud

Chromecast by Google - Gianluca Arbezzano @ CorleyCloud

Published in: Software
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
253
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DEVPARTY GOOGLE CHROMECAST AND ANGULARJS Createdby /GianlucaArbezzano @gianarb
  • 2. WHAT IS THIS?! Chromecastis athumb-sized mediastreamingdevice thatplugs into the HDMI porton your TV
  • 3. SETUP CHROMECAST.COM/SETUP
  • 4. DEVELOPER PROGRAM DEVELOPERS.GOOGLE.COM/CAST
  • 5. SENDER GOOGLE CAST SUPPORTS SENDER APPLICATIONS WRITTEN FOR THE ANDROID, IOS, AND CHROME PLATFORMS.
  • 6. RECEIVER GOOGLE CAST SUPPORTS SENDER APPLICATIONS WRITTEN FOR THE ANDROID, IOS, AND CHROME PLATFORMS.
  • 7. MY CHROMECAST GENERIC SENDER sendev-cast.gianarb.it/#/home
  • 8. .run(['$window','$timeout','$rootScope','$q',functionrun($window,$timeout,$ro otScope,$q){ /** *Managehistory */ $rootScope.logs=[]; /** *Castisready?! */ if(!$window.chrome.cast||!$window.chrome.cast.isAvailable){ vardef=$q.defer(); def.resolve(chrome.cast); $rootScope.cast=def.promise; } }])
  • 9. $rootScope.cast.then(function(cast){ $window.sessionRequest=newchrome.cast.SessionRequest(appId); $rootScope.configuration.appId=appId; varapiConfig=newchrome.cast.ApiConfig( $window.sessionRequest, $window.sessionListener, $window.receiverListener ); cast.initialize( apiConfig, function(event){ console.log("Good!"); }, function(event){ if(event){ console.log("D'oh"); } } ); });
  • 10. $scope.cast=function(){ $rootScope.cast.then(function(cast){ cast.requestSession(function(e){ $window.session=e; },function(){ console.log("ERROR"); }); }); };
  • 11. WORK WITH BUS $window.session.sendMessage( namespace, message, function(e){ console.log("OK"); }, function(e){ console.log("error"); } );
  • 12. WORK WITH MEDIA $scope.loadMedia=function(url) { varonMediaDiscovered=function(how,media){ console.log("newmediasessionID:"+media.mediaSessionId); $scope.currentMedia=media; }; $rootScope.cast.then(function(cast){ varmediaInfo=newcast.media.MediaInfo(url); mediaInfo.contentType='video/mp4'; varrequest=newchrome.cast.media.LoadRequest(mediaInfo); request.autoplay=true; request.currentTime=0; session.loadMedia(request, onMediaDiscovered.bind(this,'loadMedia'), function(e){ $rootScope.logs.push({ message:e, type:"error" }); } ); }); };
  • 13. BUS RECEIVER varhandlers={ onReady:function(event){ $rootScope.$broadcast("$castOnReady",event); session.setApplicationState("Applicationstatusisready..."); }, onSenderConnected:function(event){ statusConnect=true; $rootScope.$broadcast("$castOnSenderConnected",event); }, onSenderDisconnected:function(event){ $rootScope.$broadcast("$castOnSenderDisconnected",event); if(session.getSenders().length===0){ window.close(); } }, onSystemVolumeChanged:function(event){ $rootScope.$broadcast("$castOnSystemVolumeChanged",event); }, onMessage:function(event){ $rootScope.$broadcast("$cast-urn:x-cast:com.corley.google.cast",even t); messageBus.send(event.senderId,event.data); } };
  • 14. session=cast.receiver.CastReceiverManager.getInstance(); session.onSenderDisconnected=handlers.onSenderDisconnected; session.onSenderConnected=handlers.onSenderConnected; session.onSystemVolumeChanged=handlers.onSystemVolumeChanged; session.onReady=handlers.onReady; messageBus=session.getCastMessageBus('urn:x-cast:com.corley.google.cast'); messageBus.onMessage=handlers.onMessage;
  • 15. THANKS AND GOOD PATY

×