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

Streaming Media

Improve this doc

This plugin allows you to stream audio and video in a fullscreen, native player on iOS and Android.

Repo: https://github.com/nchutchind/cordova-plugin-streaming-media

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-streaming-media
    $ npm install --save @ionic-native/streaming-media@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { StreamingMedia, StreamingVideoOptions } from '@ionic-native/streaming-media';

constructor(private streamingMedia: StreamingMedia) { }

let options: StreamingVideoOptions = {
  successCallback: () => { console.log('Video played') },
  errorCallback: (e) => { console.log('Error streaming') },
  orientation: 'landscape',
  shouldAutoClose: true,
  controls: false
};

this.streamingMedia.playVideo('https://path/to/video/stream', options);

Instance Members

playVideo(videoUrl, options)

Streams a video

Param Type Details
videoUrl string

The URL of the video

options StreamingVideoOptions

Options

playAudio(audioUrl, options)

Streams an audio

Param Type Details
audioUrl string

The URL of the audio stream

options StreamingAudioOptions

Options

stopAudio()

Stops streaming audio

pauseAudio()

Platforms:iOS 

Pauses streaming audio

resumeAudio()

Platforms:iOS 

Resumes streaming audio

StreamingVideoOptions

Param Type Details
successCallback Function

Executes after success playing audio.

(optional)
errorCallback Function

Executes after error playing video.

(optional)
orientation string

Force one orientation for playing video.

(optional)
shouldAutoClose boolean

Should the video close after it's over. Defaults to true.

(optional)
controls boolean

Should the video have controls. Defaults to true. Android only.

(optional)

StreamingAudioOptions

Param Type Details
bgColor string

Background color for audio player.

(optional)
bgImage string

Background image for audio player.

(optional)
bgImageScale string

Background image scale for audio player. Valid values are: fit stretch aspectStretch.

(optional)
initFullscreen boolean

Start audio player in full screen. iOS only.

(optional)
keepAwake boolean

Keeps the screen lit and stops it from locking while audio is playing. Android only.

(optional)
successCallback Function

Executes after success playing audio.

(optional)
errorCallback Function

Executes after error playing audio.

(optional)

API

Native

General