0

我目前正在使用 Angular 项目,制作一个观看视频的网站。我使用 Videogular 是一个开发视频应用程序的框架。我不知道如何默认全屏制作视频。

我的代码:

<vg-player (onPlayerReady)="onPlayerReady($event)" >
  <vg-overlay-play></vg-overlay-play>
  <vg-buffering></vg-buffering>

  <vg-scrub-bar>
    <vg-scrub-bar-current-time></vg-scrub-bar-current-time>
    <vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
  </vg-scrub-bar>

  <vg-controls>
    <vg-play-pause></vg-play-pause>
    <vg-playback-button></vg-playback-button>
  </vg-controls>
  <h1>{{id}}</h1>
  <video [vgMedia]="media" #media id="singleVideo" preload="auto" crossorigin>
    <source src="assets/skill/skill_{{id}}.mp4" type="video/mp4">
  </video>


</vg-player>

import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {VgAPI} from 'videogular2/compiled/src/core/services/vg-api';

@Component({
  selector: 'app-skill',
  templateUrl: './skill.component.html',
  styleUrls: ['./skill.component.css']
})
export class SkillComponent implements OnInit {
  id: string;
  constructor(private route: ActivatedRoute) {
    route.params.subscribe(params => {
        this.id = params['id'];
    });
  }

  ngOnInit() {
  }

  onPlayerReady(vgAPI: VgAPI) {
    vgAPI.play();
    vgAPI.fsAPI.toggleFullscreen();
  }
}

非常感谢!

4

1 回答 1

1

http://www.videogular.com/tutorials/videogular-api/

我在 Videogular 的 API 文档中找到了一个触发全屏的方法:

toggleFullScreen(): Toggles between fullscreen and normal mode.

你试过了吗?

于 2020-01-08T09:41:24.427 回答