0.1.11 • Published 11 months ago

@nomercy-entertainment/media-session v0.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

MediaSession for Capacitor and web

Installation

npm install @nomercy-entertainment/media-session

Usage

import { MediaSession } from '@nomercy-entertainment/media-session';

const mediaSession = new MediaSessionManager();

// Set metadata
mediaSession.setMetadata({
  title: 'Song Title',
  artist: 'Artist Name',
  album: 'Album Name',
  artwork: 'https://example.com/artwork.jpg'
});

// Set playback state
mediaSession.setPlaybackState('playing');
mediaSession.setPlaybackState('paused');
mediaSession.setPlaybackState('none');

const audioElement = document.createElement('audio');

// Set position state
mediaSession.setPositionState({
  duration: audioElement.duration,
  playbackRate: audioElement.playbackRate,
  position: audioElement.currentTime
});

// Set action handler
mediaSession?.setActionHandler({
    play: () => audioElement.play(),
    pause: () => audioElement.pause(),
    stop: () => {
        audioElement.pause();
        audioElement.currentTime = 0;
        audioElement.removeAttribute('src');
    },
	previous: () => {},
	next: () => {},
	seek: (time) => audioElement.currentTime = time,
	getPosition: () => audioElement.currentTime,
});

License

Apache 2.0

Contact

For further information or support, visit NoMercy.tv or contact our support team.

Made with ❤️ by NoMercy Entertainment

0.1.11

11 months ago

0.1.10

11 months ago

0.1.9

11 months ago

0.1.8

11 months ago

0.1.7

11 months ago

0.1.6

11 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago