我正在寻找一个在Ionic 2环境中运行的Videogular 2工作示例,甚至是在Angular 2环境中。我尝试了许多不同的在线示例,但感觉文档过时或者完全不准确。例如,文档明确说明可以��过以下方式生成基本播放器:
这让我出现了错误:
我尝试使用
所有组件也都在我的
我的完整控制器:
<videogular vg-theme="config.theme">
<vg-media vg-src="config.sources"
vg-tracks="config.tracks">
</vg-media>
<vg-overlay-play></vg-overlay-play>
</videogular>
我正在使用Typescript加载:
import { VgAPI } from 'videogular2/core';
import { VgCoreModule } from 'videogular2/core';
import { VgControlsModule } from 'videogular2/controls';
import { VgOverlayPlayModule } from 'videogular2/overlay-play';
这让我出现了错误:
Error: Uncaught (in promise): Error: Template parse errors:
'vg-media' is not a known element
我尝试使用
vg-player
元素代替videogular
,然后在其中使用video
标签,这样可以工作,但只会给我本地播放器。任何尝试在其中使用Videogular标签的都会给我类似上面的错误。所有组件也都在我的
app.module.ts
文件的imports
区域中。我的完整控制器:
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) {
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/videogular@2.1.2/dist/themes/default/videogular.css"
},
plugins: {
poster: "http://www.videogular.com/assets/images/videogular.png"
}
};
}
// Play
onPlayerReady(api: VgAPI) {
this.api = api;
this.api.play();
}
}
我的完整HTML代码:
<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>
非常感谢您提供任何帮助。目前我正在考虑其他视频选项,但很想继续使用Videogular,因为它似乎是一个很好的解决方案,只要我能让它正常工作。