function MusicOnDeviceCommonClient(e){function s(e,t,n,i){r&&r.clear();var s=this.getIpAndPortOfServerForUser(t.user),o=[e];i!==undefined&&$.each(i,function(e,t){o.push(t)});if(s==="")this.requestServerDetailsFromDevice(t,o,n);else{var u=[];u.push(t);for(var a=0;a<o.length;a++)u.push(o[a]);u.push(s),n.apply(this,u)}}function o(t,n,i){funcObj.devCon.sendMsg(funcObj.UIMain.getUID(),"sourceDiscoveryStatus","sourceDiscoveryStatus",{SOURCE:"LOCAL_MUSIC",SOURCEACCOUNT:t.user},null,null,null,null,function(s,o){if($(o).attr("ipAddr")===""||$(o).attr("port")==="")r.clear(),e.handleNavigateOrSearchFailure(e.errorDefines.getErrorCode("MUSIC_ON_DEVICE_SERVER_NOT_DISCOVERED"),"No IP or port for music on device server","MUSIC_ON_DEVICE_SERVER_NOT_DISCOVERED",t);else if(r&&r.cleared===!1){r.clear();var u=$(o).attr("ipAddr")+":"+$(o).attr("port"),a=[];a.push(t);for(var f=0;f<n.length;f++)a.push(n[f]);a.push(u),i.apply(this,a)}}),r=new g(function(){funcObj.browse.backtoRoot(),e.handleNavigateOrSearchFailure(e.errorDefines.getErrorCode("MUSIC_ON_DEVICE_SERVER_DISCOVERY_NO_RESPONSE"),"Music on device - no response to server discovery request","MUSIC_ON_DEVICE_SERVER_DISCOVERY_NO_RESPONSE",t),r.clear()},1e4)}function u(t,r,i,s){var o={header:undefined,requests:[]};o.header={metaData:t,source:i,responseMessageType:r},o.requests[0]={url:"http://"+s+"/"+n,method:"GET"},e.apiFetch(o)}function a(t,r,i,s,o){var u={header:undefined,requests:[]};u.header={metaData:t,source:s,responseMessageType:r,preceedingMenuItem:i};var a=i.url["#text"].replace("http://",""),f=a.split("/"+n);f[0]!==o&&(i.url["#text"]="http://"+o+"/"+n+f[1]);var l;i.url["#text"].indexOf("?")>-1?l="&":l="?",t.startIndex===0?u.requests[0]={url:i.url["#text"]+l+"page=1",method:"GET"}:u.requests[0]={url:i.url["#text"]+l+"page="+(t.startIndex/t.limit+1),method:"GET"},e.apiFetch(u)}function f(t,r,i,s,o,u){var a={header:undefined,requests:[]};a.header={metaData:t,source:o,responseMessageType:r,term:i,filter:s};switch(s){case"track":a.requests[0]={url:"http://"+u+"/"+n+"/search/tracks?query="+encodeURIComponent(i)+"&pageSize=100",method:"GET"};break;case"album":a.requests[0]={url:"http://"+u+"/"+n+"/search/albums?query="+encodeURIComponent(i)+"&pageSize=100",method:"GET"};break;case"artist":a.requests[0]={url:"http://"+u+"/"+n+"/search/artists?query="+encodeURIComponent(i)+"&pageSize=100",method:"GET"};break;case"composer":a.requests[0]={url:"http://"+u+"/"+n+"/search/composers?query="+encodeURIComponent(i)+"&pageSize=100",method:"GET"};break;default:}e.apiFetch(a)}function l(t,r,i,s,o){var u={header:undefined,requests:[]};u.header={metaData:t,source:s,responseMessageType:r},u.requests[0]={url:"http://"+o+"/"+n+"/tracks/"+i.trackid["#text"],method:"GET"},e.apiFetch(u)}function c(t,r,i,s,o){var u=i.replace("http://",""),a=u.split("/"+n);a[0]!==o&&(i="http://"+o+"/"+n+a[1]);var f={header:undefined,requests:[]};f.header={metaData:t,source:s,responseMessageType:r},t.startIndex===0?f.requests[0]={url:i+"/tracks",method:"GET"}:f.requests[0]={url:i+"/tracks?page="+(t.startIndex/t.limit+1),method:"GET"},e.apiFetch(f)}function h(t,r,i,s,o,u){var a={header:undefined,requests:[]};a.header={metaData:t,source:o,responseMessageType:r,albumArtistId:i,albumArtistName:s},t.startIndex===0?a.requests[0]={url:"http://"+u+"/"+n+"/artists/"+i+"/albums",method:"GET"}:a.requests[0]={url:"http://"+u+"/"+n+"/artists/"+i+"/albums?page="+(t.startIndex/t.limit+1),method:"GET"},e.apiFetch(a)}function p(t,r,i,s,o){var u={header:undefined,requests:[]};u.header={metaData:t,source:s,responseMessageType:r},u.requests[0]={url:"http://"+o+"/"+n+"/episodes/"+i.trackid["#text"],method:"GET"},e.apiFetch(u)}function d(t,r,i,s,o){var u=i.replace("http://",""),a=u.split("/"+n);a[0]!==o&&(i="http://"+o+"/"+n+a[1]);var f={header:undefined,requests:[]};f.header={metaData:t,source:s,responseMessageType:r},t.startIndex===0?f.requests[0]={url:i+"/episodes",method:"GET"}:f.requests[0]={url:i+"/episodes?page="+(t.startIndex/t.limit+1),method:"GET"},e.apiFetch(f)}function v(e){if(e.length===0)for(var n in t)t[n]="";else for(var r=0;r<e.length;r++)e[r].ip===""&&e[r].port===""?t[e[r].uID.toUpperCase()]="":t[e[r].uID.toUpperCase()]=e[r].ip+":"+e[r].port}function m(e){var n="";return t[e.toUpperCase()]!==undefined&&(n=t[e.toUpperCase()]),n}function g(e,t){var n=setTimeout(e,t);this.cleared=!1,this.clear=function(){this.cleared=!0,clearTimeout(n)}}this.resolveIpAndPortForUser=s,this.universalCall=a,this.search=f,this.setServers=v,this.getIpAndPortOfServerForUser=m,this.getTrackDetails=l,this.getAlbumTracksForViewAlbumPage=c,this.getArtistsAlbumsForViewArtistPage=h,this.getPodcastEpisodeDetails=p,this.getPodcastEpisodesForViewPodcastPage=d,this.rootMenuApiCall=u,this.customTimeout=g,this.requestServerDetailsFromDevice=o;var t={},n="v1",r,i=this};