Skip to content

growthengineering/ionic-cordova-rtmp-hls-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ionic Cordova RTMP and HLS Plugin Header Image

Ionic Cordova RTMP and HLS Plugin

This Cordova plugin enables live broadcasting of the camera feed via RTMP and playback via HLS for both iOS and Android platforms within an Ionic Cordova application.

License

💡 Features

Broadcasting

  • 🎬 Request Permissions: Request the Camera and Microphone permissions.
  • 📷 Preview Camera Feed: Preview the camera feed.
  • 🔄 Swap Camera: Swap between different cameras (front/back).
  • 🚪 Close Camera Preview: Close the camera preview.
  • ▶️ Start RTMP Broadcasting: Start broadcasting the camera feed via RTMP.
  • ⏹️ Stop RTMP Broadcasting: Stop the RTMP broadcast.

Playback

  • 📺 View HLS Stream: Playback the HLS stream.
  • 🚫 Close HLS Stream: Close the HLS stream playback.

🚀 Sample Project

You can find a sample project demonstrating the usage of this plugin at: ionic-cordova-rtmp-hls-sample-project

🛣 Roadmap

  • Improve communication between native code and javascript (success/error callbacks)
  • Dynamic Camera Options for Broadcasting Video Settings
  • Transition from callbacks to Promises and Observables for a more modern API interface.
  • Ensure the Player and Camera Preview fully match the parent size without including headers and footers.
  • Plan migration from ExoPlayer to Media3 as per Android's latest best practices.
  • Incorporate Unit Testing for improved code reliability and maintenance.

📦 Installation

To install the plugin, simply add it to your Ionic project using the following command:

cordova plugin add https://github.com/growthengineering/ionic-cordova-rtmp-hls-plugin/

🔗 Dependencies

  • iOS HaishinKit: v1.5.6
  • iOS AVPlayer: From iOS Core Library (iOS Target SDK)
  • Android HaishinKit: v0.10.4
  • Android ExoPlayer: v2.19.1

🛠 Usage

Access to the cordova package in your Ionic app via window property:

const ionicRtmpHls = (<any>window).cordova.plugin.ionicrtmphls;

🎨 Styling

Include the following styles in your Ionic global stylesheet to ensure the player and camera have the correct background when active:

body.show-player,
body.show-camera {
  --ion-background-color: transparent;

  .nav-decor,
  ion-tabs,
  ion-app,
  ion-content {
    --ion-background-color: transparent;
    --background: transparent;
  }
}

📺 Broadcasting

Request necessary permissions before attempting to broadcast:

ionicRtmpHls.requestPermissions(successCallback, errorCallback);

To preview the camera feed:

ionicRtmpHls.previewCamera(CameraOpts, successCallback, errorCallback);

To swap the camera (front/back):

ionicRtmpHls.swapCamera(successCallback, errorCallback);

To close the camera preview:

ionicRtmpHls.closeCameraPreview(successCallback, errorCallback);

To start an RTMP broadcast:

ionicRtmpHls.startBroadcasting(RTMPUrl, RTMPKey, successCallback, errorCallback);

To stop the broadcast:

ionicRtmpHls.stopBroadcasting(successCallback, errorCallback);

🎬 Playback

To view an HLS stream:

ionicRtmpHls.viewLiveStream(HLSUrl, successCallback, errorCallback);

To close the stream playback:

ionicRtmpHls.closeLiveStream(successCallback, errorCallback);

📱 Support

This plugin supports:

  • Android 7.0 (Nougat) and above
  • iOS 12 and above
  • Cordova Android 10.0.1 and above
  • Cordova iOS 6.2.0 and above

🟡 If you are using a version of Cordova CLI <= 9.0.1 And/Or Cordova iOS <= 6.2.0 you should use the following branch: cordova-cli-9-and-below

🔒 License

MIT License

Copyright (c) 2023 Growth Engineering

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Ionic Cordova RTMP & HLS Plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published