Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Video Player

Improve this doc

A Cordova plugin that simply allows you to immediately play a video in fullscreen mode.

Requires Cordova plugin: com.moust.cordova.videoplayer. For more info, please see the VideoPlayer plugin docs.

Repo: https://github.com/moust/cordova-plugin-videoplayer

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add https://github.com/moust/cordova-plugin-videoplayer.git
    $ npm install --save @ionic-native/video-player@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { VideoPlayer } from '@ionic-native/video-player';

constructor(private videoPlayer: VideoPlayer) { }

...

// Playing a video.
this.videoPlayer.play('file:///android_asset/www/movie.mp4').then(() => {
 console.log('video completed');
}).catch(err => {
 console.log(err);
});

Instance Members

play(fileUrl, options)

Plays the video from the passed url.

Param Type Details
fileUrl string

File url to the video.

options VideoOptions

Optional video playback settings. See options above.

Returns: Promise<any> Resolves promise when the video was played successfully.

close()

Stops the video playback immediatly.

VideoOptions

Param Type Details
volume number

Set the initial volume of the video playback, where 0.0 is 0% volume and 1.0 is 100%. For example: for a volume of 30% set the value to 0.3.

(optional)
scalingMode number

There are two options for the scaling mode. SCALE_TO_FIT which is default and SCALE_TO_FIT_WITH_CROPPING. These strings are the only ones which can be passed as option.

(optional)

API

Native

General