<!DOCTYPE html>
<html>
<head>
<title>angular2 video</title>
<link rel="stylesheet" href="style.css" />
<script src="https://code.angularjs.org/2.0.0-beta.13/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="config.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.13/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.13/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.13/router.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.13/http.min.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
// Code goes here
/* Styles go here */
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
app: "./src"
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
}
}
});
//our root app component
import {ViewChild, ViewChildren, Component, QueryList, ElementRef} from 'angular2/core'
@Component({
selector: 'my-app',
template: `
<h2>Video</h2>
<video #video width="640" height="480" autoplay></video>
`
})
export class App {
@ViewChild('myname') input:ElementRef;
@ViewChild('video') video:ElementRef;
@ViewChildren('div1,div2,div3') divs:QueryList<ElementRef>;
ngAfterViewInit() {
let _video=this.video.nativeElement;
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => {
_video.src = window.URL.createObjectURL(stream);
_video.play();
})
}
}
}
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {provide} from 'angular2/core';
import {App} from './app';
import {ROUTER_PROVIDERS} from 'angular2/router'
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
bootstrap(App, [ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy}])
.catch(err => console.error(err));