-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
157 lines (141 loc) · 5.13 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="zh">
<head>
<title>Leap Video Controller</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
</head>
<body>
<div class="center">
<br/>
<br/>
<button onclick="playPause()">Start</button>
<button onclick="makeBig()">Big</button>
<button onclick="makeNormal()">Medium</button>
<button onclick="makeSmall()">Small</button>
<br/>
<br/>
</div>
<!--
<div class="center">
<video class="front" id="video" src="video.mp4" controls="controls" height="640" align="center">
Your browser does not support HTML5 video.
</video>
</div>
-->
<div class="player" id="youkuplayer" style="width:480px;height:400px"></div>
<script src="js/leap-0.6.4.js"></script>
<script src="js/leap-plugins-0.1.11.js"></script>
<script src="js/jquery.min.js"></script>
<!--
<script src="js/app.js"></script>
-->
<script type="text/javascript" src="http://player.youku.com/jsapi">
player = new YKU.Player('youkuplayer',{
styleid: '0',
client_id: 'd55092f01596b95d',
vid: 'XMTM3NTM3MTU1Mg=='
});
var player=document.getElementById("youkuplayer");
function playVideo(){
player.playVideo();
}
function pauseVideo(){
player.pauseVideo();
}
var options = { enableGestures: true };
var flag = true;
var clockwise = false;
var controller = Leap.loop(options, function(frame){
/*if(frame.hands.length > 0) {
cardFlip(true, frame.hands[0].type, frame.hands[0].roll());
}
else {
cardFlip(false, "", 0); // if there are no hands detected, reset the rotations to 0
}
*/
if(frame.valid && frame.gestures.length > 0){
frame.gestures.forEach(function(gesture){
switch (gesture.type){
case "circle":
var circleProgress = gesture.progress;
var completeCircles = Math.floor(circleProgress);
var pointableID = gesture.pointableIds[0];
var direction = frame.pointable(pointableID).direction;
/*hack* for getting direction failure*/
if (direction === undefined) direction = [0,0,0];
/*hack*/
var dotProduct = Leap.vec3.dot(direction, gesture.normal);//get direction
if (dotProduct > 0) {
if (clockwise == false) circleProgress = 0;
clockwise = true;
//console.log("clockwise");
}
else if (dotProduct < 0){
if (clockwise == true) circleProgress = 0;
clockwise = false;
//console.log("counterclockwise");
}
if (completeCircles % 3 == 0 && completeCircles != 0) {
if (flag == true){
if (clockwise == true){
console.log("fastForward");
fastForward();
}
else {
console.log("fastBackward");
fastBackward();
}
flag = false;
}
}
else{
flag = true;
}
break;
case "screenTap":
console.log("Screen Tap Gesture");
//playPause();
playVideo();
break;
case "swipe":
//Classify swipe as either horizontal or vertical
var isHorizontal = Math.abs(gesture.direction[0]) > Math.abs(gesture.direction[1]);
var duration = gesture.duration;
var swipeDirection;
//Classify as right-left or up-down
if(isHorizontal){
if(gesture.direction[0] > 0){
if (duration > 5000){
swipeDirection = "right";
makeNormal();
}
} else {
if (duration > 5000){
swipeDirection = "left";
makeSmall();
}
}
} else { //vertical
if(gesture.direction[1] > 0){
//console.log(duration);
if (duration > 5000){
swipeDirection = "up";
unmute();
}
} else {
if (duration > 5000){
swipeDirection = "down";
mute();
}
}
}
console.log(swipeDirection);
break;
}
});
}
});
var myVideo=document.getElementById("video");
</script>
</body>
</html>