Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- For example, I can pass a JSON object from my main device (PC) to my second screen device (tablet) using something like websockets.
- When I was using it for media players, I would click on a movie, which then sends a JSON object to the player (the PC). That object has all of the info the player that it needs to get going:
- // Passed in as a parameter, from the tablet, to the video player (PC)
- MovieObject{
- Title: Independance Day,
- Audio: Dolby 5,
- URL: www.PlayIndependanceDayMovie.com,
- ImageURL: wwww.PlayIndependanceDayMovie.com/CoverArt,
- Cast: Actor 1, Actor2, Actor 3
- }
- // On the video player (PC side) you run a for loop, which loops through the data, and displays it on screen
- PlayMovie function(MovieObject){
- movieTitle = MovieObject.Title
- url = MovieObject.URL
- // Gets cast of actors
- for (var i, i = MovieObject.Cast.length, i++){
- actor = MovieObject.Cast.Length
- }
- }
- Once you have that URL, you can play the movie :)
- But imagine doing the same thing with controls:
- On your tablet, if you press the "right" arrow it passes a string to the PC, which parses the string, and acts accordingly:
- // On the PC side:
- handleInput function (inputStringFromTablet){
- switch(inputStringFromTablet) {
- case right:
- fastForward();
- break;
- case left:
- rewind();
- break;
- default:
- }
RAW Paste Data