nchutchind / Vitamio-Cordova-Plugin

Cordova plugin for playing media using Vitamio on Android
MIT License
30 stars 17 forks source link

Cordova Vitamio plugin

Note: Google has been rejecting apps that include Vitamio versions < 5.0 for security vulnerabilities and rejecting apps that include Vitamio 5.0 for OpenSSL vulnerabilities. At this time, it seems like Vitamio is not a viable solution for Android.

for Android, by Nicholas Hutchind

  1. Description
  2. Usage

1. Description

This plugin allows you to stream audio and video in a fullscreen, native player using Vitamio software decoding on Android.

Android specifics

2. Usage

Adding the plugin to a cordova project, make sure to be in the project root directory before executing the following command cordova plugin add com.hutchind.cordova.plugins.vitamio

  var videoUrl = VIDEO_URL;

  // Just play a video
  window.plugins.vitamio.playVideo(videoUrl);

  // Play a pre-recorded video with callbacks
  var options = {
    isStreaming: false,
    successCallback: function(obj) {
      console.log("Video was closed without error at " + obj.pos + ".");
    },
    progressCallback: function(obj) {
      // obj.action may be "start", "stop", or "pause"
      // obj.pos is the current time in the clip (only available for non-continuous streams)
      //   and shows a format of "00:12:34"
      myAnalytics.track(obj.action, obj.pos);
    },
    errorCallback: function(obj) {
      console.log("Error! " + obj.message);
    }
  };
  window.plugins.vitamio.playVideo(videoUrl, options);

  var audioUrl = STREAMING_AUDIO_URL;

  // Simply play an audio file (not recommended, since the screen will be plain black)
  window.plugins.vitamio.playAudio(audioUrl);

  // Play an audio file with options (all options optional)
  var options = {
    isStreaming: true,
    bgColor: "#FFFFFF",
    bgImage: "<SWEET_BACKGROUND_IMAGE>",
    bgImageScale: "fit",
    successCallback: function() {
      console.log("Player closed without error.");
    },
    errorCallback: function(obj) {
      console.log("Error! " + obj.message);
    }
  };
  window.plugins.vitamio.playAudio(audioUrl, options);

3. Options

Common Options

Video-Only Options

There are no video-only options.

Audio-Only Options