@mebtte/react-media-session
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],n):(e=e||self).ReactMediaSession=n(e.React,e.PropTypes)}(this,function(d,e){"use strict";var t="default"in d?d.default:d;function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e;function r(e){var n=e.title,t=e.artist,a=e.album,r=e.artwork,i=e.onPlay,o=e.onPause,s=e.onSeekBackward,u=e.onSeekForward,c=e.onPreviousTrack,l=e.onNextTrack;return d.useEffect(function(){return navigator.mediaSession.metadata=new MediaMetadata({title:n,artist:t,album:a,artwork:r}),function(){navigator.mediaSession.metadata=null}},[n,t,a,r]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("play",i),function(){navigator.mediaSession.setActionHandler("play",null)}},[i]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("pause",o),function(){navigator.mediaSession.setActionHandler("pause",null)}},[o]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("seekbackward",s),function(){navigator.mediaSession.setActionHandler("seekbackward",null)}},[s]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("seekforward",u),function(){navigator.mediaSession.setActionHandler("seekforward",null)}},[u]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("previoustrack",c),function(){navigator.mediaSession.setActionHandler("previoustrack",null)}},[c]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("nexttrack",l),function(){navigator.mediaSession.setActionHandler("nexttrack",null)}},[l]),null}var i=window&&window.navigator&&"mediaSeesion"in window.navigator&&"MediaMetadata"in window;r.propTypes={title:e.string,artist:e.string,album:e.string,artwork:e.arrayOf(e.shape({src:e.string.isRequired,sizes:e.string,type:e.string})),onPlay:e.func,onPause:e.func,onSeekBackward:e.func,onSeekForward:e.func,onPreviousTrack:e.func,onNextTrack:e.func},r.defaultProps={title:"",artist:"",album:"",artwork:[],onPlay:null,onPause:null,onSeekBackward:null,onSeekForward:null,onPreviousTrack:null,onNextTrack:null};return function(e){var n=a({},e);return i?null:t.createElement(r,n)}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],n):(e=e||self).ReactMediaSession=n(e.React,e.PropTypes)}(this,function(d,e){"use strict";var t="default"in d?d.default:d;function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e;function r(e){var n=e.title,t=e.artist,a=e.album,r=e.artwork,i=e.onPlay,o=e.onPause,s=e.onSeekBackward,u=e.onSeekForward,c=e.onPreviousTrack,l=e.onNextTrack;return d.useEffect(function(){return navigator.mediaSession.metadata=new MediaMetadata({title:n,artist:t,album:a,artwork:r}),function(){navigator.mediaSession.metadata=null}},[n,t,a,r]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("play",i),function(){navigator.mediaSession.setActionHandler("play",null)}},[i]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("pause",o),function(){navigator.mediaSession.setActionHandler("pause",null)}},[o]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("seekbackward",s),function(){navigator.mediaSession.setActionHandler("seekbackward",null)}},[s]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("seekforward",u),function(){navigator.mediaSession.setActionHandler("seekforward",null)}},[u]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("previoustrack",c),function(){navigator.mediaSession.setActionHandler("previoustrack",null)}},[c]),d.useEffect(function(){return navigator.mediaSession.setActionHandler("nexttrack",l),function(){navigator.mediaSession.setActionHandler("nexttrack",null)}},[l]),null}var i=window&&window.navigator&&"mediaSeesion"in window.navigator;r.propTypes={title:e.string,artist:e.string,album:e.string,artwork:e.arrayOf(e.shape({src:e.string.isRequired,sizes:e.string,type:e.string})),onPlay:e.func,onPause:e.func,onSeekBackward:e.func,onSeekForward:e.func,onPreviousTrack:e.func,onNextTrack:e.func},r.defaultProps={title:"",artist:"",album:"",artwork:[],onPlay:null,onPause:null,onSeekBackward:null,onSeekForward:null,onPreviousTrack:null,onNextTrack:null};return function(e){var n=a({},e);return i?t.createElement(r,n):null}}); |
{ | ||
"name": "@mebtte/react-media-session", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "The react component that wraps MediaSession.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
export const HAS_MEDIA_SESSION = | ||
window && | ||
window.navigator && | ||
'mediaSeesion' in window.navigator && | ||
'MediaMetadata' in window; | ||
window && window.navigator && 'mediaSeesion' in window.navigator; |
@@ -8,3 +8,3 @@ import React from 'react'; | ||
const Wrapper = ({ ...props }) => { | ||
if (HAS_MEDIA_SESSION) { | ||
if (!HAS_MEDIA_SESSION) { | ||
return null; | ||
@@ -11,0 +11,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8324
116