How to use the vendors/freesound.setToken function in vendors

To help you get started, we’ve selected a few vendors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ffont / freesound-explorer / src / containers / Search / utils.js View on Github external
function search(query = randomQuery(), filter = '', maxResults = DEFAULT_MAX_RESULTS, sorting = DEFAULT_SORTING) {
  // Search sounds and start loading them
  let pageCounter = 0;
  const freesoundMaxPageSize = 150;
  const pagesToGet = Math.ceil(maxResults / freesoundMaxPageSize);
  const extraDescriptors = [
    'lowlevel.mfcc.mean',
    'sfx.tristimulus.mean',
    'tonal.hpcp.mean',
  ];
  const promises = [];
  while (pageCounter < pagesToGet) {
    const maxPageResults = (pageCounter + 1 !== pagesToGet) ?
      Math.min(maxResults, freesoundMaxPageSize) :
      maxResults - (pageCounter * freesoundMaxPageSize);
    freesound.setToken(sessionStorage.getItem('appToken'));
    promises.push(freesound.textSearch(query, {
      page: pageCounter + 1,
      page_size: maxPageResults,
      group_by_pack: 0,
      filter,
      fields: 'id,previews,name,analysis,url,username,duration,tags,license,download,similar_sounds',
      descriptors: extraDescriptors.join(),
      sort: sorting,
    }));
    pageCounter += 1;
  }
  return Promise.all(promises);
}
github ffont / freesound-explorer / src / containers / SoundInfo / actions.js View on Github external
export const bookmarkSound = sound => (dispatch) => {
  freesound.setToken(sessionStorage.getItem('accessToken'), 'oauth');
  sound.bookmark(
    sound.name,  // Use sound name
    'Freesound Explorer' // Category
  ).then(() => {
    dispatch(displaySystemMessage('Sound bookmarked!', MESSAGE_STATUS.SUCCESS));
  },
  () => dispatch(displaySystemMessage('Error bookmarking sound', MESSAGE_STATUS.ERROR)));
};
github ffont / freesound-explorer / src / containers / Search / utils.js View on Github external
export function miniSearch(query, maxDuration) {
  const pageSize = 1;
  const promises = [];
  freesound.setToken(sessionStorage.getItem('appToken'));
  promises.push(freesound.textSearch(query, {
    page_size: pageSize,
    filter: `duration:[0%20TO%20${maxDuration}]`,
  }));
  return Promise.all(promises);
}