public boolean sameMainMetaData(Track t) { if (t == null) return false; return (compare(t.getTitle(), mTitle) && compare(t.getAlbumTitle(), mAlbumTitle) && compare(t.getArtistName(), mArtistName)); }
@Test public void getTracks() { mockUnauthorizedServer .expect( requestTo( "https://api.soundcloud.com/resolve?url=http://soundcloud.com/mattslip&client_id=someApiKey")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("testdata/resolveuser"), responseHeaders)); mockUnauthorizedServer .expect(requestTo("https://api.soundcloud.com/users/3510549?client_id=someApiKey")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("testdata/userprofile"), responseHeaders)); mockUnauthorizedServer .expect(requestTo("https://api.soundcloud.com/users/3510549/tracks?client_id=someApiKey")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("testdata/tracks"), responseHeaders)); Page<Track> tracksPage = unauthorizedSoundCloud.usersOperations().userOperations("mattslip").getTracks(); List<Track> tracks = tracksPage.getContent(); assertEquals(0, tracksPage.getNumber()); assertEquals(50, tracksPage.getTotalElements()); assertNotNull(tracks); assertEquals(50, tracks.size()); Track firstTrack = tracks.get(0); assertEquals("Kid Sister vs Daft Punk (Monsieur Adi Mashup)", firstTrack.getTitle()); assertEquals( "http://soundcloud.com/monsieuradi/kid-sister-vs-daft-punk", firstTrack.getPermalinkUrl()); assertEquals("39679670", firstTrack.getId()); }
@Test public void getFavoritesByUserId() { mockUnauthorizedServer .expect(requestTo("https://api.soundcloud.com/users/3510549?client_id=someApiKey")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("testdata/userprofile"), responseHeaders)); mockUnauthorizedServer .expect( requestTo("https://api.soundcloud.com/users/3510549/favorites?client_id=someApiKey")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("testdata/favorites"), responseHeaders)); Page<Track> tracksPage = unauthorizedSoundCloud.usersOperations().userOperations(3510549).getFavorites(); assertEquals(0, tracksPage.getNumber()); assertEquals(56, tracksPage.getTotalElements()); List<Track> tracks = tracksPage.getContent(); assertNotNull(tracks); assertEquals(50, tracks.size()); Track firstTrack = tracks.get(0); assertEquals("Sneaky Sound System - Big (Oliver Remix)", firstTrack.getTitle()); assertEquals( "http://soundcloud.com/weareoliver/sneaky-sound-system-big-oliver", firstTrack.getPermalinkUrl()); assertEquals("22905377", firstTrack.getId()); }
/** * añade un método a la clase MusicOrganizer llamado findInTitle que tome un único parámetro de * tipo String y muestre por pantalla la información de los tracks que contienen dicha cadena en * el título de la canción. ------------ 0052 */ public void findInTitle(String informaciónDeTracks) { for (Track datos : tracks) { // --------------------------------------------------------------------- 0052 if (datos.getTitle().contains(informaciónDeTracks)) { System.out.println(datos.getDetails()); } } }
public ConcreteTrack(Track t) { mId = t.getId(); mPlayUrl = t.getPlayUrl(null, 0); mTitle = t.getTitle(); mArtistId = t.getArtistId(); mArtistName = t.getArtistName(); mAlbumId = t.getAlbumId(); mAlbumTitle = t.getAlbumTitle(); }
/** * que permita eliminar del organizador los tracks que contengan una determinada cadena en el * título de la canción */ public void removeByTitle( String titulo) { // ------------------------------------------------- 0055 Iterator<Track> pistas = tracks.iterator(); while (pistas.hasNext()) { Track mostrarPistas = pistas.next(); if (mostrarPistas.getTitle().contains(titulo)) { pistas.remove(); } } }
/** * Play a track in the collection. * * @param index The index of the track to be played. */ public void playTrack(int index) { if (indexValid(index) && reproduciendose == false) { Track track = tracks.get(index); track .incrementaContadorReproduciones(); // ----------------------- 0052 para incrementar el nº // de reproducciones reproduciendose = true; // --------------------------------------- 0054 player.startPlaying(track.getFilename()); System.out.println("Now playing: " + track.getArtist() + " - " + track.getTitle()); } else { System.out.println("Error ya hay una reproducción en curso "); } }
protected void init() { String artist = mTrack.getArtist(); String title = mTrack.getTitle(); // We are using DuckDuck to search any search engines, with bang(!) notation mSearchDomain = "http://www.duckduckgo.com/?q="; if (mSearchEngine.equals("DuckDuckGo")) { mSearchQuery = artist + " - " + title + " lyrics"; } else if (mSearchEngine.equals("Google")) { mSearchQuery = "!g " + artist + " - " + title + " lyrics"; } else if (mSearchEngine.equals("Bing")) { mSearchQuery = "!b " + artist + " - " + title + " lyrics"; } else if (mSearchEngine.equals("Yahoo")) { mSearchQuery = "!y " + artist + " - " + title + " lyrics"; } else { mSearchQuery = artist + " - " + title + " lyrics"; } mSearchURL = mSearchDomain + enc(mSearchQuery); }