Custom Media Player

Custom Media Player

This guide provides instructions for integrating a custom media player into your Android application. The media player includes functionality for showing notifications with media controls such as Play, Pause, and Stop.

The custom media player allows you to start, pause, and stop media playback, with notifications displaying the current status and controls. This enhances user experience by providing easy access to media controls from the notification panel.

2. Starting Media Playback

To start media playback with a notification, use the playMedia function. This function also supports displaying a custom image in the notification.

2.1. Parameters

  • url: (String) The URL of the media you want to play.
  • image: (Optional String) A custom image URL to be shown in the notification. If not provided, a default image will be used.

Plain JavaScript (ES5)

window.WTN.MediaPlayer.playMedia({
  url: "Your Media URL",
  image: "Custom Image URL" // Optional
});

ES6+ Module Import

import { playMedia } from "webtonative/MediaPlayer";
 
playMedia({
  url: "Your Media URL",
  image: "Custom Image URL" // Optional
});

3. Pausing Media Playback

To pause the media playback, use the pauseMedia function. This will update the notification controls to reflect the paused state.

Plain JavaScript (ES5)

window.WTN.MediaPlayer.pauseMedia();

ES6+ Module Import

import { pauseMedia } from "webtonative/MediaPlayer";
 
pauseMedia();

4. Stopping Media Playback

To stop the media playback completely and remove the notification, use the stopMedia function.

Plain JavaScript (ES5)

window.WTN.MediaPlayer.stopMedia();

ES6+ Module Import

import { stopMedia } from "webtonative/MediaPlayer";
 
stopMedia();

5. Summary

By following these instructions, you can integrate a custom media player into your Android application, providing users with convenient media controls through notifications. The playMedia, pauseMedia, and stopMedia functions cover the essential operations needed for media playback.


media-icon
media-icon
media-icon
media-icon

â“’2024 Orufy Technologies All Rights Reserved.