A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at df22eb08f006cc55f4e454a905fb314660883ed9 79 lines 1.6 kB view raw
1// 2// Common stuff 3// ʕ•ᴥ•ʔ 4 5 6export const APP_INFO = { 7 creator: "icidasset", 8 name: "Diffuse" 9} 10 11 12export const WEBNATIVE_CONFIG = { 13 namespace: APP_INFO, 14 permissions: { 15 app: APP_INFO, 16 fs: { public: [ { directory: [ "Apps", APP_INFO.creator, APP_INFO.name ] } ] } 17 }, 18 debug: true, 19} 20 21 22 23// FUNCTIONS 24 25 26export const debounce = 27 (callback, time = 250, timeoutId) => 28 (...args) => 29 clearTimeout(timeoutId, timeoutId = setTimeout(callback, time, ...args)) 30 31 32export const throttle = 33 (callback, time = 250, wasCalledBefore, lastestArgs) => 34 (...args) => { 35 lastestArgs = args 36 if (wasCalledBefore) { return } else { wasCalledBefore = true } 37 setTimeout(() => { callback(...lastestArgs); wasCalledBefore = false }, time) 38 } 39 40 41export function identity(a) { 42 return a 43} 44 45 46export function fileExtension(mimeType) { 47 const audioId = mimeType.toLowerCase().split("/")[ 1 ] 48 49 switch (audioId) { 50 case "mp3": return "mp3"; 51 case "mpeg": return "mp3"; 52 53 case "mp4a-latm": return "m4a"; 54 case "mp4": return "m4a"; 55 case "x-m4a": return "m4a"; 56 57 case "flac": return "flac"; 58 case "x-flac": return "flac"; 59 case "ogg": return "ogg"; 60 61 case "wav": return "wav"; 62 case "wave": return "wav"; 63 64 case "webm": return "webm"; 65 } 66} 67 68 69export function mimeType(fileExt) { 70 switch (fileExt) { 71 case "mp3": return "audio/mpeg"; 72 case "mp4": return "audio/mp4"; 73 case "m4a": return "audio/mp4"; 74 case "flac": return "audio/flac"; 75 case "ogg": return "audio/ogg"; 76 case "wav": return "audio/wave"; 77 case "webm": return "audio/webm"; 78 } 79}