SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com

V id e o g u la r 
An HTML5 video player for AngularJS

WeLoveJS

26/10/2013
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com

Two Fucking Developers
3
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

r a ú l
jim é n e z 

@elecash

@2fdevs

m a rc o s
g o n z á le z 

@qmarcos

http://twofuckingdevelopers.com
4
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

angularjs

@2fdevs

http://twofuckingdevelopers.com

data binding
dependency injection
routing
templating
modules
filters
maintained by Google
extend HTML and build web components!
5
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular

@2fdevs

http://twofuckingdevelopers.com

bindable properties
themes
plugins and API
native fullscreen support
mobile support
library agnostic (next release)
it should extend HTML5 video capabilities.
6
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

videogular demo
bit.ly/1cmKI0k

http://twofuckingdevelopers.com
7
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
how
it
works
videogular
vg-width
vg-height
vg-theme

@2fdevs

http://twofuckingdevelopers.com

<!DOCTYPE html>
<html ng-app=”MyApp”>
<head>
<title>Videogular</title>
</head>
<body>
<div ng-controller=”MyAppController”>
<div videogular vg-width=”data.width” vg-height=”data.height” vg-theme=”theme.url”>
<video class=’videoPlayer’ preload=’metadata’>
<source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”>
<source src=”assets/videos/oceans-clip.webm” type=”video/webm”>
<source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”>
</video>
</div>
</div>

<!-- Dependencies -->
<script type=”text/javascript” src=”...”></script>

<!-- Videogular files -->
<script type=”text/javascript” src=”videogular.js”></script>

<!-- App -->
<script type=”text/javascript” src=“...”></script>

</body>
</html>
8
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
themes
vg-theme
css-based
two-way binding

@2fdevs

http://twofuckingdevelopers.com

<!DOCTYPE html>

<html ng-app=”MyApp”>

<head>
<link rel=”stylesheet” href=”themes/default/videogular.css”>
</head>

<body>

<!-- more code... -->
<div videogular vg-width=”data.width” vg-height=”data.height”
vg-theme=”theme.url” vg-autoplay=”data.autoPlay”>
<video class=’videoPlayer’ preload=’metadata’>
<source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”>
<source src=”assets/videos/oceans-clip.webm” type=”video/webm”>
<source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”>
</video>
</div>
<!-- more code... -->
</body>
</html>

when vg-theme is updated it removes previous theme and
injects the new one.
9
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
bindable
properties
$watch
directive
dispatch event

@2fdevs

http://twofuckingdevelopers.com

videogular.directive(”vgTheme”, function(VG_EVENTS) {
return {
restrict: “A”,
link: function (scope, elem, attrs) {
function updateTheme(value) {
//Inject theme and dispatch event
}

// More code...

if (attrs.vgTheme) {
if (attrs.vgTheme.indexOf(”.css”) < 0) {
scope.$watch(attrs.vgTheme, function(value) {
updateTheme(value);
});
}
else {
updateTheme(attrs.vgTheme);
}
}

}
}
}
);

we check if it’s a variable or a value to $watch or update.
10
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com

w h y p lu g in s ? 
HTML5 poster attribute is cool!
11
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com
12
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
adding
a plugin
directives
bindable properties
core independant

@2fdevs

http://twofuckingdevelopers.com

<div videogular vg-width=”data.width” vg-height=”data.height”
vg-theme=”theme.url” vg-autoplay=”data.autoPlay”>
<div vg-overlayPlay></div>

<video class=’videoPlayer’ preload=’metadata’>
<source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”>
<source src=”assets/videos/oceans-clip.webm” type=”video/webm”>
<source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”>
</video>
</div>

<script src=”js/vg/videogular.js” type=”text/javascript”></script>
<script src=”js/vg/plugins/overlayplay.js” type=”text/javascript”></script>

var videogularApp = angular.module(”videogularApp”, [
“MyAppController”,
“com.2fdevs.videogular”,
“com.2fdevs.videogular.plugins.overlayplay”
]
);

to add a plugin you only need to write it inside your 
videogular tag, add the .js file and import the plugin.
13
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
components
inside
plugins
directives
bindable properties
plugin dependant

@2fdevs

http://twofuckingdevelopers.com

<div videogular vg-width=”data.width” vg-height=”data.height”
vg-theme=”theme.url” vg-autoplay=”data.autoPlay”>
<div vg-controls vg-autohide=”data.autoHide” style=”height: 50px;”>
<div vg-playpauseButton></div>
<div vg-timeDisplay>{{ currentTime }}</div>
<div vg-scrubBar>
<div vg-scrubbarcurrenttime></div>
</div>
<div vg-timeDisplay>{{ totalTime }}</div>
<div vg-volume>
<div vg-mutebutton></div>
<div vg-volumebar></div>
</div>
<div vg-fullscreenButton></div>
</div>

<video class=’videoPlayer’ preload=’metadata’>
<source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”>
<source src=”assets/videos/oceans-clip.webm” type=”video/webm”>
<source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”>
</video>
</div>

you could write components inside plugins and they will
be encapsulated inside the plugin.
14
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
plugins
API
event-based
dependency injected
extendable

@2fdevs

http://twofuckingdevelopers.com

overLayPlay.directive(”vgOverlayplay”, function(VG_EVENTS){
....
function onClickOverlayPlay($event) {
scope.$emit(VG_EVENTS.ON_PLAY_PAUSE);
}

function onComplete(target, params) {
//Show plugin
}

elem.bind(”click”, onClickOverlayPlay);

scope.$on(VG_EVENTS.ON_COMPLETE, onComplete);
...
}

Videogular uses an event-based API to create plugins.

with $emit you can dispatch events to make others react
to your actions.

with $on you can react to events launched by other plugins
or by Videogular.
15
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

videogular
API
events
list

@2fdevs

ON_PLAY
ON_PAUSE
ON_PLAY_PAUSE
ON_START_PLAYING
ON_COMPLETE
ON_SET_STATE
ON_SET_VOLUME
ON_TOGGLE_FULLSCREEN
ON_ENTER_FULLSCREEN
ON_EXIT_FULLSCREEN
ON_BUFFERING
ON_UPDATE_TIME
ON_SEEK_TIME
ON_UPDATE_SIZE
ON_UPDATE_THEME
ON_PLAYER_READY
ON_LOAD_POSTER

http://twofuckingdevelopers.com
16
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com

videogular
 fullscreen support... http://caniuse.com/fullscreen

fullscreen
 desktop support for Chrome, Firefox and Safari.
support 
desktop
mobile
unsupported

mobile support for Chrome/Firefox for Android and iOS
fullscreen API.

future support for unsupported browsers like IE and
Android stock browser. http://youtube.com/html5

for now we just can detect if it has fullscreen support with
a custom polyfill

if (!window.fullScreenAPI) {
var fullScreenButton = angular.element(elem[0]);
fullScreenButton.css(”display”, “none”);
}
17
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

http://twofuckingdevelopers.com

videogular
 Videogular running on mobile devices

mobile
 · remove vg-width and vg-height to enter in
responsive mode!! NEW!
support


mobile detection
fullscreen
controls

· only video object will be in fullscreen.


· hide volume controls, it doesn’t work on mobile.

· util function to detect if we’re in a mobile

if (VG_UTILS.isMobileDevice()) // do stuff...

this.isMobileDevice = function() {
return (typeof window.orientation !== “undefined”);
};
/18

Videogular: an AngularJS video player
TwoFuckingDevelopers

@2fdevs

Fin :-)
Thanks!
Questions?
@2fdevs
www.twofuckingdevelopers.com
git.com
github.com/2fdevs
git.com
coderwall.com/2fdevs

http://twofuckingdevelopers.com

Más contenido relacionado

La actualidad más candente

android design pattern
android design patternandroid design pattern
android design pattern
Lucas Xu
 
Bea Web Logic Workshop81 Jump Start Guide
Bea Web Logic Workshop81 Jump Start GuideBea Web Logic Workshop81 Jump Start Guide
Bea Web Logic Workshop81 Jump Start Guide
guest4263ad
 
App開發 - Web Developer的逆襲
App開發 - Web Developer的逆襲App開發 - Web Developer的逆襲
App開發 - Web Developer的逆襲
益祥 許
 

La actualidad más candente (20)

2014 HTML5 총정리
2014 HTML5 총정리2014 HTML5 총정리
2014 HTML5 총정리
 
Amazing vue.js projects that are open source and free.
Amazing vue.js projects that are open source and free.Amazing vue.js projects that are open source and free.
Amazing vue.js projects that are open source and free.
 
Developing Android Apps
Developing Android AppsDeveloping Android Apps
Developing Android Apps
 
MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014
 
2013년 html5 총정리 (Summary of HTML5 Trend in 2013)
2013년 html5 총정리 (Summary of HTML5 Trend in 2013)2013년 html5 총정리 (Summary of HTML5 Trend in 2013)
2013년 html5 총정리 (Summary of HTML5 Trend in 2013)
 
riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott Andrews
 
android design pattern
android design patternandroid design pattern
android design pattern
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump Start
 
Bea Web Logic Workshop81 Jump Start Guide
Bea Web Logic Workshop81 Jump Start GuideBea Web Logic Workshop81 Jump Start Guide
Bea Web Logic Workshop81 Jump Start Guide
 
M.youtube can not display
M.youtube can not displayM.youtube can not display
M.youtube can not display
 
Android design patterns
Android design patternsAndroid design patterns
Android design patterns
 
Swift iOS Architecture with FLUX in mind. UA Mobile 2016.
Swift iOS Architecture with FLUX in mind. UA Mobile 2016.Swift iOS Architecture with FLUX in mind. UA Mobile 2016.
Swift iOS Architecture with FLUX in mind. UA Mobile 2016.
 
Learn How to Animate your Android App
Learn How to Animate your Android AppLearn How to Animate your Android App
Learn How to Animate your Android App
 
Effective Android UI - English
Effective Android UI - EnglishEffective Android UI - English
Effective Android UI - English
 
Angular material tutorial
Angular material tutorialAngular material tutorial
Angular material tutorial
 
Android the Agile way
Android the Agile wayAndroid the Agile way
Android the Agile way
 
App開發 - Web Developer的逆襲
App開發 - Web Developer的逆襲App開發 - Web Developer的逆襲
App開發 - Web Developer的逆襲
 
製作 Unity Plugin for Android
製作 Unity Plugin for Android製作 Unity Plugin for Android
製作 Unity Plugin for Android
 
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample CodeHTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
 

Similar a Welovejs AngularJS

Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJS
Edureka!
 
Developer Training for 23 Video
Developer Training for 23 VideoDeveloper Training for 23 Video
Developer Training for 23 Video
Steffen
 

Similar a Welovejs AngularJS (20)

Web applications support on AGL
Web applications support on AGLWeb applications support on AGL
Web applications support on AGL
 
Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJS
 
Embedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceEmbedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to Maintenance
 
Live Demo : Trending Angular JS Featues
Live Demo : Trending Angular JS FeatuesLive Demo : Trending Angular JS Featues
Live Demo : Trending Angular JS Featues
 
Predictable Web Apps with Angular and Redux
Predictable Web Apps with Angular and ReduxPredictable Web Apps with Angular and Redux
Predictable Web Apps with Angular and Redux
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Typescript 102 angular and type script
Typescript 102   angular and type scriptTypescript 102   angular and type script
Typescript 102 angular and type script
 
Web components api + Vuejs
Web components api + VuejsWeb components api + Vuejs
Web components api + Vuejs
 
Add Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.jsAdd Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.js
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
 
VizEx View HTML5 Workshop
VizEx View HTML5 WorkshopVizEx View HTML5 Workshop
VizEx View HTML5 Workshop
 
VizEx View HTML5 Workshop
VizEx View HTML5 WorkshopVizEx View HTML5 Workshop
VizEx View HTML5 Workshop
 
Developer Training for 23 Video
Developer Training for 23 VideoDeveloper Training for 23 Video
Developer Training for 23 Video
 
Polymer - El fin a tus problemas con el FrontEnd
Polymer - El fin a tus problemas con el FrontEndPolymer - El fin a tus problemas con el FrontEnd
Polymer - El fin a tus problemas con el FrontEnd
 
3d web
3d web3d web
3d web
 
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
 
Pluggable web app using Angular (Odessa JS conf)
Pluggable web app using Angular (Odessa JS conf)Pluggable web app using Angular (Odessa JS conf)
Pluggable web app using Angular (Odessa JS conf)
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 

Más de Tomas Corral Casas

Más de Tomas Corral Casas (9)

Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Mikado method
Mikado methodMikado method
Mikado method
 
Testea y aumenta tu karma
Testea y aumenta tu karmaTestea y aumenta tu karma
Testea y aumenta tu karma
 
Coderdojo bcn 12_10_2013
Coderdojo bcn 12_10_2013Coderdojo bcn 12_10_2013
Coderdojo bcn 12_10_2013
 
Lo que los desarrolladores web deberían saber
Lo que los desarrolladores web deberían saberLo que los desarrolladores web deberían saber
Lo que los desarrolladores web deberían saber
 
Hydra.js modula tu código
Hydra.js modula tu códigoHydra.js modula tu código
Hydra.js modula tu código
 
Less is more
Less is moreLess is more
Less is more
 
Design patterns in Javascript
Design patterns in JavascriptDesign patterns in Javascript
Design patterns in Javascript
 
Automatización Unit Testing Javascript
Automatización Unit Testing JavascriptAutomatización Unit Testing Javascript
Automatización Unit Testing Javascript
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Welovejs AngularJS

  • 1. /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com V id e o g u la r An HTML5 video player for AngularJS WeLoveJS 26/10/2013
  • 2. /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com Two Fucking Developers
  • 3. 3 /18 Videogular: an AngularJS video player TwoFuckingDevelopers r a ú l jim é n e z @elecash @2fdevs m a rc o s g o n z á le z @qmarcos http://twofuckingdevelopers.com
  • 4. 4 /18 Videogular: an AngularJS video player TwoFuckingDevelopers angularjs @2fdevs http://twofuckingdevelopers.com data binding dependency injection routing templating modules filters maintained by Google extend HTML and build web components!
  • 5. 5 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular @2fdevs http://twofuckingdevelopers.com bindable properties themes plugins and API native fullscreen support mobile support library agnostic (next release) it should extend HTML5 video capabilities.
  • 6. 6 /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs videogular demo bit.ly/1cmKI0k http://twofuckingdevelopers.com
  • 7. 7 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular how it works videogular vg-width vg-height vg-theme @2fdevs http://twofuckingdevelopers.com <!DOCTYPE html> <html ng-app=”MyApp”> <head> <title>Videogular</title> </head> <body> <div ng-controller=”MyAppController”> <div videogular vg-width=”data.width” vg-height=”data.height” vg-theme=”theme.url”> <video class=’videoPlayer’ preload=’metadata’> <source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”> <source src=”assets/videos/oceans-clip.webm” type=”video/webm”> <source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”> </video> </div> </div> <!-- Dependencies --> <script type=”text/javascript” src=”...”></script> <!-- Videogular files --> <script type=”text/javascript” src=”videogular.js”></script> <!-- App --> <script type=”text/javascript” src=“...”></script> </body> </html>
  • 8. 8 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular themes vg-theme css-based two-way binding @2fdevs http://twofuckingdevelopers.com <!DOCTYPE html> <html ng-app=”MyApp”> <head> <link rel=”stylesheet” href=”themes/default/videogular.css”> </head> <body> <!-- more code... --> <div videogular vg-width=”data.width” vg-height=”data.height” vg-theme=”theme.url” vg-autoplay=”data.autoPlay”> <video class=’videoPlayer’ preload=’metadata’> <source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”> <source src=”assets/videos/oceans-clip.webm” type=”video/webm”> <source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”> </video> </div> <!-- more code... --> </body> </html> when vg-theme is updated it removes previous theme and injects the new one.
  • 9. 9 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular bindable properties $watch directive dispatch event @2fdevs http://twofuckingdevelopers.com videogular.directive(”vgTheme”, function(VG_EVENTS) { return { restrict: “A”, link: function (scope, elem, attrs) { function updateTheme(value) { //Inject theme and dispatch event } // More code... if (attrs.vgTheme) { if (attrs.vgTheme.indexOf(”.css”) < 0) { scope.$watch(attrs.vgTheme, function(value) { updateTheme(value); }); } else { updateTheme(attrs.vgTheme); } } } } } ); we check if it’s a variable or a value to $watch or update.
  • 10. 10 /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com w h y p lu g in s ? HTML5 poster attribute is cool!
  • 11. 11 /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com
  • 12. 12 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular adding a plugin directives bindable properties core independant @2fdevs http://twofuckingdevelopers.com <div videogular vg-width=”data.width” vg-height=”data.height” vg-theme=”theme.url” vg-autoplay=”data.autoPlay”> <div vg-overlayPlay></div> <video class=’videoPlayer’ preload=’metadata’> <source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”> <source src=”assets/videos/oceans-clip.webm” type=”video/webm”> <source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”> </video> </div> <script src=”js/vg/videogular.js” type=”text/javascript”></script> <script src=”js/vg/plugins/overlayplay.js” type=”text/javascript”></script> var videogularApp = angular.module(”videogularApp”, [ “MyAppController”, “com.2fdevs.videogular”, “com.2fdevs.videogular.plugins.overlayplay” ] ); to add a plugin you only need to write it inside your videogular tag, add the .js file and import the plugin.
  • 13. 13 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular components inside plugins directives bindable properties plugin dependant @2fdevs http://twofuckingdevelopers.com <div videogular vg-width=”data.width” vg-height=”data.height” vg-theme=”theme.url” vg-autoplay=”data.autoPlay”> <div vg-controls vg-autohide=”data.autoHide” style=”height: 50px;”> <div vg-playpauseButton></div> <div vg-timeDisplay>{{ currentTime }}</div> <div vg-scrubBar> <div vg-scrubbarcurrenttime></div> </div> <div vg-timeDisplay>{{ totalTime }}</div> <div vg-volume> <div vg-mutebutton></div> <div vg-volumebar></div> </div> <div vg-fullscreenButton></div> </div> <video class=’videoPlayer’ preload=’metadata’> <source src=”assets/videos/oceans-clip.mp4” type=”video/mp4”> <source src=”assets/videos/oceans-clip.webm” type=”video/webm”> <source src=”assets/videos/oceans-clip.ogv” type=”video/ogg”> </video> </div> you could write components inside plugins and they will be encapsulated inside the plugin.
  • 14. 14 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular plugins API event-based dependency injected extendable @2fdevs http://twofuckingdevelopers.com overLayPlay.directive(”vgOverlayplay”, function(VG_EVENTS){ .... function onClickOverlayPlay($event) { scope.$emit(VG_EVENTS.ON_PLAY_PAUSE); } function onComplete(target, params) { //Show plugin } elem.bind(”click”, onClickOverlayPlay); scope.$on(VG_EVENTS.ON_COMPLETE, onComplete); ... } Videogular uses an event-based API to create plugins. with $emit you can dispatch events to make others react to your actions. with $on you can react to events launched by other plugins or by Videogular.
  • 15. 15 /18 Videogular: an AngularJS video player TwoFuckingDevelopers videogular API events list @2fdevs ON_PLAY ON_PAUSE ON_PLAY_PAUSE ON_START_PLAYING ON_COMPLETE ON_SET_STATE ON_SET_VOLUME ON_TOGGLE_FULLSCREEN ON_ENTER_FULLSCREEN ON_EXIT_FULLSCREEN ON_BUFFERING ON_UPDATE_TIME ON_SEEK_TIME ON_UPDATE_SIZE ON_UPDATE_THEME ON_PLAYER_READY ON_LOAD_POSTER http://twofuckingdevelopers.com
  • 16. 16 /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com videogular fullscreen support... http://caniuse.com/fullscreen fullscreen desktop support for Chrome, Firefox and Safari. support desktop mobile unsupported mobile support for Chrome/Firefox for Android and iOS fullscreen API. future support for unsupported browsers like IE and Android stock browser. http://youtube.com/html5 for now we just can detect if it has fullscreen support with a custom polyfill if (!window.fullScreenAPI) { var fullScreenButton = angular.element(elem[0]); fullScreenButton.css(”display”, “none”); }
  • 17. 17 /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs http://twofuckingdevelopers.com videogular Videogular running on mobile devices mobile · remove vg-width and vg-height to enter in responsive mode!! NEW! support mobile detection fullscreen controls · only video object will be in fullscreen. · hide volume controls, it doesn’t work on mobile. · util function to detect if we’re in a mobile if (VG_UTILS.isMobileDevice()) // do stuff... this.isMobileDevice = function() { return (typeof window.orientation !== “undefined”); };
  • 18. /18 Videogular: an AngularJS video player TwoFuckingDevelopers @2fdevs Fin :-) Thanks! Questions? @2fdevs www.twofuckingdevelopers.com git.com github.com/2fdevs git.com coderwall.com/2fdevs http://twofuckingdevelopers.com