Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Sampaio committed Dec 19, 2015
0 parents commit beb7f33
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/
/bower_components/
.idea
48 changes: 48 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
release: {
options: {
//bump: false, //default: true
//file: 'bower.json', //default: package.json
//add: false, //default: true
//commit: false, //default: true
//tag: false, //default: true
//push: false, //default: true
//pushTags: false, //default: true
//npmtag: true, //default: no tag
//folder: 'folder/to/publish/to/npm', //default project root
//commitMessage: 'check out my release <%= version %>', //default: 'release <%= version %>'
//tagMessage: 'tagging version <%= version %>', //default: 'Version <%= version %>',
//tagName: 'v<%= version %>', //default: '<%= version %>'

file: 'bower.json', //default: package.json
add: false, //default: true
commit: false, //default: true
tag: false, //default: true
push: false, //default: true
pushTags: false, //default: true
npm: false
}
},
uglify: {
options: {
mangle: false
},
build: {
files: {
'./vg-hls.min.js': ['./vg-hls.js']
}
}
}
});

grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.registerTask('major', ['release:major']);
grunt.registerTask('minor', ['release:minor']);
grunt.registerTask('patch', ['release:patch']);

grunt.registerTask('build', ['uglify:build']);
};
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Pedro Sampaio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
bower-videogular-hls
=====================

Videogular `HLS` plugin repository for distribution on `bower`.

## Install

Install [Videogular](http://www.videogular.com/) `hls` plugin with Bower:

`bower install videogular-hls`

### Install Videogular

Install [Videogular](http://www.videogular.com/) with Bower:

`bower install videogular`

### Install themes

Install [Videogular](http://www.videogular.com/) themes with Bower:

`bower install videogular-themes-default`

### Install plugins

Install [Videogular](http://www.videogular.com/) plugins with Bower:

`bower install videogular-buffering`

`bower install videogular-overlay-play`

`bower install videogular-controls`

`bower install videogular-poster`

## Documentation

It's available on [Videogular's project Wiki](https://github.com/2fdevs/videogular/wiki).

## License

The MIT License (MIT)

Copyright (c) 2014 Pedro Sampaio

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "videogular-hls",
"version": "1.0.0",
"main": "./vg-hls.js",
"dependencies": {
"videogular": "~1.4.0"
}
}
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('./vg-hls');

module.exports = 'com.2fdevs.videogular';
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "videogular-hls",
"version": "0.0.1",
"main": "index.js",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "^0.11.0",
"grunt-release": "~0.7.0"
},
"engines": {
"node": ">=0.8.0"
}
}
77 changes: 77 additions & 0 deletions vg-hls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* @ngdoc directive
* @name com.2fdevs.videogular.plugins.dash.directive:vgHls
* @restrict A
* @description
* Adds HLS support for vg-media.
* This plugin requires hls.js file available at hls.js project:
* https://github.com/dailymotion/hls.js
*
* <pre>
* <videogular vg-theme="config.theme.url" vg-autoplay="config.autoPlay">
* <vg-media vg-src="sources" vg-hls></vg-media>
* </videogular>
* </pre>
*
*/
"use strict";
angular.module("com.2fdevs.videogular.plugins.hls", [])
.directive("vgHls", ['$log', function ($log) {
return {
restrict: "A",
require: "^videogular",
link: function (scope, elem, attr, API) {
var context;
var player;
var hlsTypeRegEx = /^application\/x-mpegURL/i;

//Proceed augmenting behavior only if the browser is capable of playing HLS
if(Hls.isSupported()) {
//Returns true if the source has the standard HLS type defined OR an .m3u8 extension.
scope.isHLS = function isHLS(source) {
var hasHlsType = hlsTypeRegEx.test(source.type);
var hasHlsExtension = source.src.indexOf && (source.src.indexOf(".m3u8") > 0);

return hasHlsType || hasHlsExtension;
};

scope.onSourceChange = function onSourceChange(source) {
var url = source.src;

// It's HLS, we use Hls.js
if (scope.isHLS(source)) {
var video = API.mediaElement[0];
var hls = new Hls();
hls.loadSource(url);
hls.attachMedia(API.mediaElement[0]);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
if(API.autoPlay){
video.play();
}
});
}
else if (player) {
//not HLS, but the Hls.js player is still wired up
//Dettach Hls.js from the mediaElement
player.reset();
player = null;

//player.reset() wipes out the new url already applied, so have to reapply
API.mediaElement.attr('src', url);
API.stop();
}
};

scope.$watch(
function () {
return API.sources;
},
function (newVal/*, oldVal*/) {
scope.onSourceChange(newVal[0]);
}
);
}
}
}
}
]);
1 change: 1 addition & 0 deletions vg-hls.min.js

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

0 comments on commit beb7f33

Please sign in to comment.