Skip to content

Commit

Permalink
First commit - fullscreen player
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfdanJ committed Mar 10, 2015
0 parents commit 78e978f
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# node-js-getting-started

A barebones Node.js app using [Express 4](http://expressjs.com/).

This application support the [Getting Started with Node on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs) article - check it out.

## Running Locally

Make sure you have [Node.js](http://nodejs.org/) and the [Heroku Toolbelt](https://toolbelt.heroku.com/) installed.

```sh
$ git clone git@github.com:heroku/node-js-getting-started.git # or clone your own fork
$ cd node-js-getting-started
$ npm install
$ npm start
```

Your app should now be running on [localhost:5000](http://localhost:5000/).

## Deploying to Heroku

```
$ heroku create
$ git push heroku master
$ heroku open
```

## Documentation

For more information about using Node.js on Heroku, see these Dev Center articles:

- [Getting Started with Node.js on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
- [Heroku Node.js Support](https://devcenter.heroku.com/articles/nodejs-support)
- [Node.js on Heroku](https://devcenter.heroku.com/categories/nodejs)
- [Best Practices for Node.js Development](https://devcenter.heroku.com/articles/node-best-practices)
- [Using WebSockets on Heroku with Node.js](https://devcenter.heroku.com/articles/node-websockets)
7 changes: 7 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Node.js Getting Started",
"description": "A barebones Node.js app using Express 4",
"repository": "https://github.com/heroku/node-js-getting-started",
"logo": "http://node-js-sample.herokuapp.com/node.svg",
"keywords": ["node", "express", "static"]
}
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var express = require('express');
var app = express();
var sassMiddleware = require('node-sass-middleware');
var path = require('path');

app.set('port', (process.env.PORT || 5000));

// adding the sass middleware
app.use(sassMiddleware({
src: path.join(__dirname,'sass'),
dest: path.join(__dirname, 'public'),
debug: false,
outputStyle: 'compressed'
}));

app.use(express.static(__dirname + '/public'));


app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'));
});
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "node-js-getting-started",
"version": "0.1.2",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "~4.9.x",
"node-sass-middleware": "^0.5.0"
},
"engines": {
"node": "0.10.x"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-getting-started"
},
"keywords": [
"node",
"heroku",
"express"
],
"license": "MIT"
}
22 changes: 22 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1">
<link rel="stylesheet" href="style.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://www.youtube.com/player_api"></script>
</head>
<body>


<div id="videocontainer">
<div id="ytplayer"></div>
</div>

<div id="ytblock"></div>

<script src="script.js"></script>

</body>
</html>
60 changes: 60 additions & 0 deletions public/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
var ytplayer;
function onYouTubePlayerAPIReady() {
ytplayer = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'SxWKffqBjMM',
playerVars: {
autoplay: 1, //< Play on start
controls: 0, //< Hide controls
disablekb: 1, //< Disable keyboard controls
enablejsapi: 1, //< Enable js api
fs: 0, // Disable fullscreen
modestbranding: 1, //< Thank you youtube, but no thanks
origin:'localhost', // Should be set for security
rel: 0, //< Dont show related videos
showinfo: 0 //< Hide info
}
});
}

var videoZoom = 1;
var videoPosX = 0;
var videoPosY = 0;
var paused = false;

$(document).ready(function(){

var updatePlayerSize = function(){
var player = $('#ytplayer');
player.width($( window ).width()*videoZoom);
player.height($( window ).height()*videoZoom);

if(ytplayer && ytplayer.pauseVideo) {
if (paused) {
ytplayer.pauseVideo();
console.log("Pause");

} else {
ytplayer.playVideo();
}
}
};

// Update player on window resize
$(window).resize(updatePlayerSize);
updatePlayerSize();

$("#ytblock").click(function(){
if(videoZoom == 1){
videoZoom = 2;
paused = true;
} else {
videoZoom = 1;
paused = false;
}

//player.pauseVideo();
updatePlayerSize();
})
});
1 change: 1 addition & 0 deletions public/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions sass/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
padding:0;
margin:0;
}

#videocontainer {
position:absolute;
top:0;
width:100%;
height:100%;
overflow:hidden;
}

#ytblock {
height:100%;
width:100%;
position:absolute;
top:0px;
}

0 comments on commit 78e978f

Please sign in to comment.