本文整理汇总了Java中de.umass.lastfm.scrobble.ScrobbleResult类的典型用法代码示例。如果您正苦于以下问题:Java ScrobbleResult类的具体用法?Java ScrobbleResult怎么用?Java ScrobbleResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScrobbleResult类属于de.umass.lastfm.scrobble包,在下文中一共展示了ScrobbleResult类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public static ScrobbleResult scrobble(ScrobbleData scrobbleData, Session session) {
Map<String, String> params = new HashMap<String, String>();
// required params
params.put("artist", scrobbleData.getArtist());
params.put("track", scrobbleData.getTrack());
params.put("timestamp", String.valueOf(scrobbleData.getTimestamp()));
// optional params
MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
params.put("chosenByUser", StringUtilities.convertFromBoolean(scrobbleData.isChosenByUser()));
Result result = Caller.getInstance().call("track.scrobble", session, params);
return convertToScrobbleResults(result, ScrobbleResultType.SINGLE_SCROBBLE).get(0);
}
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:19,代码来源:Track.java
示例2: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
File file = new File(cacheDir, SUBMISSIONS_FILE);
List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
if (file.exists()) {
BufferedReader r = new BufferedReader(new FileReader(file));
List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
String line;
while ((line = r.readLine()) != null) {
ScrobbleData d = decodeScrobbleData(line);
list.add(d);
if (list.size() == 50) {
result.addAll(Track.scrobble(list, session));
list.clear();
}
}
if (list.size() > 0)
result.addAll(Track.scrobble(list, session));
r.close();
FileWriter w = new FileWriter(file);
w.close();
}
return result;
}
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:24,代码来源:FileSystemCache.java
示例3: onPostExecute
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
@Override
protected void onPostExecute(ScrobbleResult scrobbleResult) {
if (scrobbleResult != null && scrobbleResult.isSuccessful()) {
Log.d(TAG, "Now playing status updated");
} else {
Log.d(TAG, String.format("Failed to update now playing status: %s", scrobbleResult));
}
Result result = Result.error(ERROR_UNKNOWN);
if (scrobbleResult != null) {
if (scrobbleResult.isSuccessful()) {
result = Result.success();
} else {
int errorCode = scrobbleResult.getErrorCode();
result = Result.error(errorCode >= 0 ? errorCode : ERROR_UNKNOWN);
}
}
Message message = Message.obtain();
message.obj = result;
callback.handleMessage(message);
}
开发者ID:peterjosling,项目名称:scroball,代码行数:23,代码来源:LastfmClient.java
示例4: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public static ScrobbleResult scrobble(ScrobbleData scrobbleData, Session session) {
Map<String, String> params = new HashMap<String, String>();
// required params
params.put("artist", scrobbleData.getArtist());
params.put("track", scrobbleData.getTrack());
params.put("timestamp", String.valueOf(scrobbleData.getTimestamp()));
// optional params
MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
params.put("chosenByUser", StringUtilities.convertFromBoolean(scrobbleData.isChosenByUser()));
Result result = Caller.getInstance().call("track.scrobble", session, params);
return convertToScrobbleResults(result, ScrobbleResultType.SINGLE_SCROBBLE).get(0);
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:19,代码来源:Track.java
示例5: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
File file = new File(cacheDir, SUBMISSIONS_FILE);
List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
if (file.exists()) {
BufferedReader r = new BufferedReader(new FileReader(file));
List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
String line;
while ((line = r.readLine()) != null) {
ScrobbleData d = decodeScrobbleData(line);
list.add(d);
if (list.size() == 50) {
result.addAll(Track.scrobble(list, session));
list.clear();
}
}
if (list.size() > 0)
result.addAll(Track.scrobble(list, session));
r.close();
FileWriter w = new FileWriter(file);
w.close();
}
return result;
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:24,代码来源:FileSystemCache.java
示例6: parseIntoScrobbleResult
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
/**
* Parses a DomElement containing scrobble or now playing response data into the passed ScrobbleResult.
*
* @param scrobbleElement DomElement containing scrobble or now playing response data.
* @param scrobbleResult ScrobbleResult to add the response data to.
*/
private static void parseIntoScrobbleResult(DomElement scrobbleElement, ScrobbleResult scrobbleResult) {
DomElement trackElement = scrobbleElement.getChild("track");
scrobbleResult.setTrack(trackElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(trackElement.getAttribute("corrected")));
DomElement artistElement = scrobbleElement.getChild("artist");
scrobbleResult.setArtist(artistElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(artistElement.getAttribute("corrected")));
DomElement albumElement = scrobbleElement.getChild("album");
scrobbleResult.setAlbum(albumElement.getText());
scrobbleResult.setAlbumCorrected(StringUtilities.convertToBoolean(albumElement.getAttribute("corrected")));
DomElement albumArtistElement = scrobbleElement.getChild("albumArtist");
scrobbleResult.setAlbumArtist(albumArtistElement.getText());
scrobbleResult.setAlbumArtistCorrected(StringUtilities.convertToBoolean(albumArtistElement.getAttribute("corrected")));
String timeString = scrobbleElement.getChildText("timestamp");
if (timeString != null) {
// will be non-null for scrobble results only
scrobbleResult.setTimestamp(Integer.parseInt(timeString));
}
DomElement ignoredMessageElement = scrobbleElement.getChild("ignoredMessage");
int ignoredMessageCode = Integer.parseInt(ignoredMessageElement.getAttribute("code"));
if (ignoredMessageCode > 0) {
scrobbleResult.setIgnored(true);
scrobbleResult.setIgnoredMessageCode(IgnoredMessageCode.valueOfCode(ignoredMessageCode));
scrobbleResult.setIgnoredMessage(ignoredMessageElement.getText());
}
}
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:38,代码来源:Track.java
示例7: updateNowPlaying
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public static ScrobbleResult updateNowPlaying(ScrobbleData scrobbleData, Session session) {
Map<String, String> params = new HashMap<String, String>();
// required params
params.put("artist", scrobbleData.getArtist());
params.put("track", scrobbleData.getTrack());
// optional params
MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
Result result = Caller.getInstance().call("track.updateNowPlaying", session, params);
return convertToScrobbleResults(result, ScrobbleResultType.NOW_PLAYING).get(0);
}
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:16,代码来源:Track.java
示例8: doInBackground
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
@Override
protected ScrobbleResult doInBackground(com.peterjosling.scroball.Track... params) {
com.peterjosling.scroball.Track track = params[0];
try {
return api.updateNowPlaying(track.artist(), track.track(), session);
} catch (CallException e) {
Log.d(TAG, "Failed to update now playing status", e);
}
return null;
}
开发者ID:peterjosling,项目名称:scroball,代码行数:11,代码来源:LastfmClient.java
示例9: parseIntoScrobbleResult
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
/**
* Parses a DomElement containing scrobble or now playing response data into the passed ScrobbleResult.
*
* @param scrobbleElement DomElement containing scrobble or now playing response data.
* @param scrobbleResult ScrobbleResult to add the response data to.
*/
private static void parseIntoScrobbleResult(DomElement scrobbleElement, ScrobbleResult scrobbleResult) {
DomElement trackElement = scrobbleElement.getChild("track");
scrobbleResult.setTrack(trackElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(trackElement.getAttribute("corrected")));
DomElement artistElement = scrobbleElement.getChild("artist");
scrobbleResult.setArtist(artistElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(artistElement.getAttribute("corrected")));
DomElement albumElement = scrobbleElement.getChild("album");
scrobbleResult.setAlbum(albumElement.getText());
scrobbleResult.setAlbumCorrected(StringUtilities.convertToBoolean(albumElement.getAttribute("corrected")));
DomElement albumArtistElement = scrobbleElement.getChild("albumArtist");
scrobbleResult.setAlbumArtist(albumArtistElement.getText());
scrobbleResult.setAlbumArtistCorrected(StringUtilities.convertToBoolean(albumArtistElement.getAttribute("corrected")));
String timeString = scrobbleElement.getChildText("timestamp");
if (timeString != null) {
// will be non-null for scrobble results only
scrobbleResult.setTimestamp(Integer.parseInt(timeString));
}
DomElement ignoredMessageElement = scrobbleElement.getChild("ignoredMessage");
int ignoredMessageCode = Integer.parseInt(ignoredMessageElement.getAttribute("code"));
if (ignoredMessageCode > 0) {
scrobbleResult.setIgnored(true);
scrobbleResult.setIgnoredMessageCode(IgnoredMessageCode.valueOfCode(ignoredMessageCode));
scrobbleResult.setIgnoredMessage(ignoredMessageElement.getText());
}
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:38,代码来源:Track.java
示例10: updateNowPlaying
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public static ScrobbleResult updateNowPlaying(ScrobbleData scrobbleData, Session session) {
Map<String, String> params = new HashMap<String, String>();
// required params
params.put("artist", scrobbleData.getArtist());
params.put("track", scrobbleData.getTrack());
// optional params
MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
Result result = Caller.getInstance().call("track.updateNowPlaying", session, params);
return convertToScrobbleResults(result, ScrobbleResultType.NOW_PLAYING).get(0);
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:16,代码来源:Track.java
示例11: call
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
@Override
public ActionResult call() throws Exception {
ScrobbleResult result = lastFMTrackHelper.scrobble(metadata.getArtist(), metadata.getTitle(), metadataMap.get(metadata).intValue(), session);
if (result.isSuccessful() && !result.isIgnored()) {
log.debug(metadata.getArtist() + " - " + metadata.getTitle() + " scrobbling to Last.fm was Successful");
return ActionResult.Sent;
} else {
log.error("Submitting track " + metadata.getTitle() + " to Last.fm failed: " + result);
return ActionResult.Error;
}
}
开发者ID:josdem,项目名称:jmetadata,代码行数:12,代码来源:ScrobblerHelper.java
示例12: shouldFailWhenSubmitScrobbler
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
@Test
public void shouldFailWhenSubmitScrobbler() throws Exception {
ScrobbleResult result = mock(ScrobbleResult.class);
when(metadataMap.get(metadata)).thenReturn(100L);
setExpectations();
setMetadataTrackExpectations();
when(result.isSuccessful()).thenReturn(false);
when(lastFMTrackHelper.scrobble(metadata.getArtist(), metadata.getTitle(), metadataMap.get(metadata).intValue(), currentUser.getSession())).thenReturn(result);
assertEquals(ActionResult.Sessionless, helperScrobbler.send(metadata));
}
开发者ID:josdem,项目名称:jmetadata,代码行数:12,代码来源:TestScrobblerHelper.java
示例13: shouldSendAnScrobbler
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
@Test
public void shouldSendAnScrobbler() throws Exception {
ScrobbleResult result = mock(ScrobbleResult.class);
when(metadataMap.get(metadata)).thenReturn(100L);
when(currentUser.getSession()).thenReturn(session);
setExpectations();
setMetadataTrackExpectations();
when(result.isSuccessful()).thenReturn(true);
when(lastFMTrackHelper.scrobble(metadata.getArtist(), metadata.getTitle(), metadataMap.get(metadata).intValue(), currentUser.getSession())).thenReturn(result);
assertEquals(ActionResult.Sent, helperScrobbler.send(metadata));
}
开发者ID:josdem,项目名称:jmetadata,代码行数:13,代码来源:TestScrobblerHelper.java
示例14: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
/**
* @see Track#scrobble(List, Session)
*/
public List<ScrobbleResult> scrobble(List<ScrobbleData> scrobbleData, Session session) {
return Track.scrobble(scrobbleData, session);
}
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java
示例15: updateNowPlaying
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
/**
* @see Track#updateNowPlaying(String, String, Session)
*/
public ScrobbleResult updateNowPlaying(String artistName, String trackName, Session session) {
return Track.updateNowPlaying(artistName, trackName, session);
}
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java
示例16: updateScrobbling
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
private void updateScrobbling() {
if(musicPlayer.isActive() == false) {
return;
}
if(!preference.getBoolean(getString(R.string.pref_lastfm_scrobbling), false))
return;
checkState(musicPlayer.getCurrentTrack() != null);
Thread t = new Thread(new Runnable(){
Track track = musicPlayer.getCurrentTrack();
public void run() {
Session session = null;
try {
session = Authenticator.getMobileSession(
preference.getString(getString(R.string.pref_lastfm_username), ""),
preference.getString(getString(R.string.pref_lastfm_pwd), ""),
lastFM_key, lastFM_secret);
} catch (de.umass.lastfm.CallException ex) {
LOGGER.warn("de.umass.lastfm.CallException: {}", ex.getMessage());
}
if(session == null)
{
// LOGGER.debug("Could not log in");
Looper.prepare();
Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.could_not_log_in), Toast.LENGTH_SHORT).show();
Looper.loop();
return;
}
try {
Thread.sleep(30000);
} catch (InterruptedException e1) {
LOGGER.debug("Could not sleep");
}
if(track == musicPlayer.getCurrentTrack() && musicPlayer.isPlaying())
{
int now = (int)(System.currentTimeMillis()/1000);
try{
ScrobbleResult result = de.umass.lastfm.Track.scrobble(
track.getArtistName(), track.getName(), now, session);
if(result.isSuccessful() && !result.isIgnored())
{
Looper.prepare();
Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.current_song_scrobbled) , Toast.LENGTH_SHORT).show();
Looper.loop();
}}
catch(Exception e){
Looper.prepare();
LOGGER.error(e.getMessage());
Toast.makeText(getBaseContext(), SonarflowApplication.getAppContext().getString(R.string.problem_with_scrobbling) , Toast.LENGTH_SHORT).show();
Looper.loop();
}
}
}
});
t.start();
}
开发者ID:spectralmind,项目名称:sonarflow-android,代码行数:61,代码来源:PlayerService.java
示例17: scrobble
import de.umass.lastfm.scrobble.ScrobbleResult; //导入依赖的package包/类
public ScrobbleResult scrobble(String artist, String title, int time, Session session) {
return Track.scrobble(artist, title, time, session);
}
开发者ID:josdem,项目名称:jmetadata,代码行数:4,代码来源:LastFMTrackHelper.java
注:本文中的de.umass.lastfm.scrobble.ScrobbleResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论