Skip to content

Commit

Permalink
apple tv demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cfjedimaster committed Nov 5, 2015
1 parent c01e4db commit 3b5ca25
Show file tree
Hide file tree
Showing 29 changed files with 130,202 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arialscreensaver/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions arialscreensaver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore

node_modules/
platforms/
plugins/
4 changes: 4 additions & 0 deletions arialscreensaver/www/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#mainVideo {
width: 100%;
height: 100%;
}
Binary file added arialscreensaver/www/img/ionic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions arialscreensaver/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter">

<ion-pane>
<ion-header-bar class="bar-dark">
<h1 class="title">Apple Arial Viewer</h1>
</ion-header-bar>
<ion-content ng-controller="MainCtrl">
<ion-refresher
pulling-text="Pull to select new video..."
on-refresh="loadVideo()">
</ion-refresher>
<video autoplay loop id="mainVideo" controls2>
<source src="" />
</video>
</ion-content>
</ion-pane>
</body>
</html>
92 changes: 92 additions & 0 deletions arialscreensaver/www/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.controller('MainCtrl', function($scope, AppleVideoService) {

$scope.loadVideo = function() {
AppleVideoService.getVideo().then(function(vid) {
console.log(vid.url);
document.querySelector("#mainVideo source").setAttribute("src", vid.url);
document.querySelector("#mainVideo").load();
$scope.$broadcast('scroll.refreshComplete');
});
};

$scope.loadVideo();

})
.factory('AppleVideoService', function($http,$q) {

var jsonURL = "http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json";
var videoData = "";

//http://stackoverflow.com/a/7228322
var randomIntFromInterval = function (min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}

/*
first, I determine if night or data
then, I pick a random video matching that
*/
var randomVideo = function() {
//what time is it?
var hour = new Date().getHours();
if(hour > 6 && hour < 18) {
return videoData.day[randomIntFromInterval(0, videoData.day.length)];
} else {
return videoData.night[randomIntFromInterval(0, videoData.night.length)];
}
};

/*
I convert Apple's JSON into two array of day and night videos. That makes it easier to pick a random one.
*/
var process = function(data) {
var processed = {night:[], day:[]};
for(var i=0; i<data.length;i++) {
for(var video in data[i].assets) {
if(data[i].assets[video].timeOfDay === "day") {
processed.day.push(data[i].assets[video]);
} else {
processed.night.push(data[i].assets[video]);
}
}
}
return processed;
};

return {

getVideo:function() {
var deferred = $q.defer();
if(videoData === "") {
$http.get(jsonURL).success(function(data) {
videoData = process(data);
deferred.resolve(randomVideo());
});
} else deferred.resolve(randomVideo());
return deferred.promise;
}

};

})
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}


});
})
7,697 changes: 7,697 additions & 0 deletions arialscreensaver/www/lib/ionic/css/ionic.css

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions arialscreensaver/www/lib/ionic/css/ionic.min.css

Large diffs are not rendered by default.

Binary file not shown.
2,230 changes: 2,230 additions & 0 deletions arialscreensaver/www/lib/ionic/fonts/ionicons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3b5ca25

Please sign in to comment.