0.1.11 • Published 1 year ago

@nomercy-entertainment/media-session v0.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago