本文整理汇总了Java中org.bff.javampd.objects.MPDSong类的典型用法代码示例。如果您正苦于以下问题:Java MPDSong类的具体用法?Java MPDSong怎么用?Java MPDSong使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MPDSong类属于org.bff.javampd.objects包,在下文中一共展示了MPDSong类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playlist
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Display the paginated list of playlist entries.
* @param page Current page number (starts from 0)
* @return an action result
*/
public static Result playlist(int page)
{
try
{
MPD mpd = MpdMonitor.getInstance().getMPD();
MPDPlayer player = mpd.getMPDPlayer();
Page<MPDSong> songs = Playlist.getSongs(page, 10);
return ok(playlist.render(player, songs));
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Command failed! " + e.getMessage());
return ok(playlist.render(null, new EmptyPage<MPDSong>()));
}
}
示例2: playlistContent
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Return all songs of a given playlist
* @return the rendered html content
*/
public static Result playlistContent(String id)
{
try
{
MPD mpd = MpdMonitor.getInstance().getMPD();
List<MPDSong> songs = mpd.getMPDDatabase().listPlaylistSongs(id);
return ok(Json.toJson(songs));
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Command failed! " + e.getMessage());
return ok(playlists.render(Collections.<MPDSavedPlaylist>emptyList()));
}
}
示例3: addDbEntry
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Performs POST /addDbEntry
* @return an action result
*/
public static Result addDbEntry(String path)
{
try
{
Logger.info("Adding db entry to playlist: " + path);
MPD mpd = MpdMonitor.getInstance().getMPD();
MPDSong song = new MPDSong();
song.setFile(path);
mpd.getMPDPlaylist().addSong(song);
return ok(path);
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Command failed! " + e.getMessage());
return notFound(path);
}
}
示例4: selectSong
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Performs POST /selectsong/:pos
* @return an action result
*/
public static Result selectSong(int pos)
{
Logger.info("Play Song " + pos);
try
{
MPD mpd = MpdMonitor.getInstance().getMPD();
MPDSong song = mpd.getMPDPlaylist().getSongList().get(pos);
mpd.getMPDPlayer().playId(song);
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Changing song failed! " + e.getMessage());
}
return ok("");
}
示例5: remove
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Remove entry from playlist
* @param id the playlist entry pos
* @return an action result
*/
public static Result remove(int id)
{
Logger.info("Removing entry from playlist: " + id);
try
{
MPD mpd = MpdMonitor.getInstance().getMPD();
MPDPlaylist mpdPlaylist = mpd.getMPDPlaylist();
MPDSong song = mpdPlaylist.getSongList().get(id);
mpdPlaylist.removeSong(song);
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Removing entry from playlist failed! " + e.getMessage());
}
return ok("");
}
示例6: determineSongChange
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
private void determineSongChange(String playerId) {
MPD daemon = findMPDInstance(playerId);
if (daemon == null) {
// we give that player another chance -> try to reconnect
reconnect(playerId);
}
if (daemon != null) {
try {
MPDPlayer player = daemon.getMPDPlayer();
// get the song object here
MPDSong curSong = player.getCurrentSong();
MPDSong curSongCache = songInfoCache.get(playerId);
if (curSongCache != null) {
// we have some info
if (curSong.getId() != curSongCache.getId()) {
songInfoCache.put(playerId, curSong);
songChanged(playerId, curSong);
} else {
// nothing, same song
// detect play state
}
} else {
// no info about player's playback state
songInfoCache.put(playerId, curSong);
// action the song change¬ification
songChanged(playerId, curSong);
}
}
catch (MPDPlayerException pe) {
logger.error("error while updating player status: {}" + pe.getMessage(), playerId);
} catch (Exception e) {
logger.warn("Failed to communicate with '{}'", playerId);
}
}
else {
logger.warn("didn't find player configuration instance for playerId '{}'", playerId);
}
}
示例7: determineSongChange
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
private void determineSongChange(String playerId) {
MPD daemon = findMPDInstance(playerId);
if (daemon == null) {
// we give that player another chance -> try to reconnect
reconnect(playerId);
}
if (daemon != null) {
try {
MPDPlayer player = daemon.getMPDPlayer();
// get the song object here
MPDSong curSong = player.getCurrentSong();
MPDSong curSongCache = songInfoCache.get(playerId);
if (!songsEqual(curSong, curSongCache)) {
// song is different (or not in cache), update cache
songInfoCache.put(playerId, curSong);
// action the song change¬ification
songChanged(playerId, curSong);
}
} catch (MPDPlayerException pe) {
logger.error("Error while updating player status for player '{}': {}", playerId, pe.getMessage());
} catch (Exception e) {
logger.warn("Failed to communicate with player '{}'", playerId);
}
} else {
logger.warn("Player '{}' was not found or is not connected", playerId);
}
}
示例8: songsEqual
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
private boolean songsEqual(MPDSong song1, MPDSong song2) {
if (!StringUtils.equals(getTitle(song1), getTitle(song2))) {
return false;
}
return StringUtils.equals(getArtist(song1), getArtist(song2));
}
示例9: getTitle
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
private String getTitle(MPDSong song) {
if (song == null || song.getTitle() == null) {
return "";
}
return song.getTitle().toString();
}
示例10: getArtist
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
private String getArtist(MPDSong song) {
if (song == null || song.getArtist() == null) {
return "";
}
return song.getArtist().toString();
}
示例11: browseDb
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Display the paginated list of computers.
* @param page Current page number (starts from 0)
* @param sortBy Column to be sorted
* @param order Sort order (either asc or desc)
* @param filter Filter applied on computer names
* @return an action result
*/
public static Result browseDb(int page, String sortBy, String order, String filter)
{
Page<MPDSong> songs = null;
List<String> playlistfiles = new ArrayList<>();
try
{
MPD mpd = MpdMonitor.getInstance().getMPD();
List<MPDSong> playlist = mpd.getMPDPlaylist().getSongList();
for (MPDSong song : playlist)
{
playlistfiles.add(song.getFile());
}
songs = Database.getSongs(page, 10, sortBy, order, filter);
}
catch (MPDException e)
{
Logger.error("MPD error", e);
flash("error", "Command failed! " + e.getMessage());
songs = new EmptyPage<>();
}
return ok(database.render(songs, playlistfiles, sortBy, order, filter));
}
示例12: getSongs
import org.bff.javampd.objects.MPDSong; //导入依赖的package包/类
/**
* Returns a page of the current playlist
* @param page Page to display
* @param pageSize Number of computers per page
* @return a page with all relevant entries
* @throws MPDException if MPD reports an error
*/
public static Page<MPDSong> getSongs(int page, final int pageSize) throws MPDException
{
MPD mpd = MpdMonitor.getInstance().getMPD();
MPDPlaylist playlist = mpd.getMPDPlaylist();
List<MPDSong> songs = playlist.getSongList();
DefaultPagingList<MPDSong> pagingList = new DefaultPagingList<>(songs, pageSize);
return pagingList.getPage(page);
}