Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chromecast - DevParty Torino 2014

1,119 views

Published on

Chromecast by Google - Gianluca Arbezzano @ CorleyCloud

Published in: Software
  • Be the first to comment

  • Be the first to like this

Chromecast - DevParty Torino 2014

  1. 1. DEVPARTY GOOGLE CHROMECAST AND ANGULARJS Createdby /GianlucaArbezzano @gianarb
  2. 2. WHAT IS THIS?! Chromecastis athumb-sized mediastreamingdevice thatplugs into the HDMI porton your TV
  3. 3. SETUP CHROMECAST.COM/SETUP
  4. 4. DEVELOPER PROGRAM DEVELOPERS.GOOGLE.COM/CAST
  5. 5. SENDER GOOGLE CAST SUPPORTS SENDER APPLICATIONS WRITTEN FOR THE ANDROID, IOS, AND CHROME PLATFORMS.
  6. 6. RECEIVER GOOGLE CAST SUPPORTS SENDER APPLICATIONS WRITTEN FOR THE ANDROID, IOS, AND CHROME PLATFORMS.
  7. 7. MY CHROMECAST GENERIC SENDER sendev-cast.gianarb.it/#/home
  8. 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. 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. 10. $scope.cast=function(){ $rootScope.cast.then(function(cast){ cast.requestSession(function(e){ $window.session=e; },function(){ console.log("ERROR"); }); }); };
  11. 11. WORK WITH BUS $window.session.sendMessage( namespace, message, function(e){ console.log("OK"); }, function(e){ console.log("error"); } );
  12. 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. 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. 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. 15. THANKS AND GOOD PATY

×