I'm in need of a functional example showcasing Videogular 2 within an Ionic 2 setup or perhaps even in a plain Angular 2 environment.
Despite trying various online examples, it appears that the documentation is either outdated or completely inaccurate.
For instance, the documentation claims that a basic player can be created with:
<videogular vg-theme="config.theme">
<vg-media vg-src="config.sources"
vg-tracks="config.tracks">
</vg-media>
<vg-overlay-play></vg-overlay-play>
</videogular>
This results in an error when implemented in Typescript:
Error: Uncaught (in promise): Error: Template parse errors:
'vg-media' is not a known element
I have managed some success by using a vg-player
element instead of videogular
along with a video
tag inside. Although this approach works, it only displays the native player. Whenever I try to use Videogular tags within, it throws a similar error as mentioned above.
All components are correctly included in my app.module.ts
file under the imports
section.
Here's my complete controller code:
import { Component } from '@angular/core';
import { NavController, NavParams, ToastController, LoadingController } from 'ionic-angular';
import { VgAPI } from 'videogular2/core';
import { VgCoreModule } from 'videogular2/core';
import { VgControlsModule } from 'videogular2/controls';
import { VgOverlayPlayModule } from 'videogular2/overlay-play';
import { Level } from '../../providers/level';
@Component({
selector: 'page-programme-overview',
templateUrl: 'programme_overview.html'
})
export class ProgrammeOverviewPage {
api: VgAPI;
videos: any;
config: any;
constructor(
public navCtrl: NavController,
public toastCtrl: ToastController,
private navParams: NavParams) {
// Video sources
this.videos = [
{
sources: [
{src: "http://static.videogular.com/assets/videos/videogular.mp4", type: "video/mp4"},
{src: "http://static.videogular.com/assets/videos/videogular.webm", type: "video/webm"},
{src: "http://static.videogular.com/assets/videos/videogular.ogg", type: "video/ogg"}
]
},
{
sources: [
{src: "http://static.videogular.com/assets/videos/big_buck_bunny_720p_h264.mov", type: "video/mp4"},
{src: "http://static.videogular.com/assets/videos/big_buck_bunny_720p_stereo.ogg", type: "video/ogg"}
]
}
];
this.config = {
preload: "none",
autoHide: false,
autoHideTime: 3000,
autoPlay: false,
sources: this.videos[0].sources,
theme: {
url: "https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9dfc0cdcc...">[email protected]</a>/dist/themes/default/videogular.css"
},
plugins: {
poster: "http://www.videogular.com/assets/images/videogular.png"
}
};
}
// Play function
onPlayerReady(api: VgAPI) {
this.api = api;
this.api.play();
}
}
And here's my full HTML code:
<ion-header>
<ion-navbar>
<ion-title>Video</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<videogular vg-theme="config.theme">
<vg-media vg-src="config.sources"
vg-tracks="config.tracks">
</vg-media>
<vg-overlay-play></vg-overlay-play>
</videogular>
</ion-content>
Any assistance would be highly appreciated. At this stage, I'm contemplating alternative video solutions, although I prefer to continue working with Videogular since it seems like a promising solution once operational.