Android Open Source - swazam Song






From Project

Back to project page swazam.

License

The source code is released under:

MIT License

If you think the Android project swazam listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package at.ac.tuwien.swa13.swazam.library.impl;
// ww  w  .  j a v  a2s.  c  om
import ac.at.tuwien.infosys.swa.audio.Fingerprint;

import at.ac.tuwien.swa13.swazam.fingerprint.impl.FingerPrintCreator;
import at.ac.tuwien.swa13.swazam.library.ISong;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;

public final class Song implements ISong
{
  private final String filePath;
  private Fingerprint fingerprint;
  private Tag metadata;

  public Song(String filePath)
  {
      // Read metadata
      this.filePath = filePath;
      
      this.extractMetadata();
      this.createFingerprint();
  }
  
  private void extractMetadata()
  {
      try {
          File songFile = new File(filePath);
          AudioFile f = AudioFileIO.read(songFile);
          metadata = f.getTag();
      } catch (CannotReadException ex) {
          Logger.getLogger(Song.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IOException ex) {
          Logger.getLogger(Song.class.getName()).log(Level.SEVERE, null, ex);
      } catch (TagException ex) {
          Logger.getLogger(Song.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ReadOnlyFileException ex) {
          Logger.getLogger(Song.class.getName()).log(Level.SEVERE, null, ex);
      } catch (InvalidAudioFrameException ex) {
          Logger.getLogger(Song.class.getName()).log(Level.SEVERE, null, ex);
      }
  }

  @Override
  public void createFingerprint()
  {
    FingerPrintCreator fpc = new FingerPrintCreator();
    this.fingerprint = fpc.createFingerprintFromFilePath(this.filePath);
  }

  @Override
  public boolean matchFingerprint(Fingerprint fingerprint)
  {
    if (this.fingerprint == null)
      return false;

    return this.fingerprint.match(fingerprint) != -1;
  }

  @Override
  public String toString()
  {
    return this.getArtist() + " - " + this.getAlbum() + " - " + this.getTitle();
  }
  
  @Override
  public String getAlbum()
  {
      return this.metadata.getFirst(FieldKey.ALBUM);
  }
  
  @Override
  public String getArtist()
  {
      return this.metadata.getFirst(FieldKey.ALBUM);
  }
  
  @Override
  public String getTitle()
  {
      return this.metadata.getFirst(FieldKey.TITLE);
  }
}




Java Source Code List

ac.tuwien.sa13.beans.HibernateAwareObjectMapper.java
ac.tuwien.sa13.controller.HomeController.java
ac.tuwien.sa13.controller.LoginController.java
ac.tuwien.sa13.controller.RequestController.java
ac.tuwien.sa13.controller.TransactionController.java
ac.tuwien.sa13.controller.api.UserRestController.java
ac.tuwien.sa13.dao.HibernateDAO.java
ac.tuwien.sa13.dao.IGenericDAO.java
ac.tuwien.sa13.dao.IRequestDAO.java
ac.tuwien.sa13.dao.ITransactionDAO.java
ac.tuwien.sa13.dao.IUserDAO.java
ac.tuwien.sa13.dao.RequestDAO.java
ac.tuwien.sa13.dao.TransactionDAO.java
ac.tuwien.sa13.dao.UserDAO.java
ac.tuwien.sa13.entity.Request.java
ac.tuwien.sa13.entity.Transaction.java
ac.tuwien.sa13.entity.User.java
ac.tuwien.sa13.service.IGenericService.java
ac.tuwien.sa13.service.IRequestService.java
ac.tuwien.sa13.service.ITransactionService.java
ac.tuwien.sa13.service.IUserService.java
ac.tuwien.sa13.service.PeerManager.java
ac.tuwien.sa13.service.RequestService.java
ac.tuwien.sa13.service.TransactionService.java
ac.tuwien.sa13.service.UserService.java
ac.tuwien.sa13.utilities.SessionIdentifierGenerator.java
ac.tuwien.sa13.utilities.Token.java
ac.tuwien.sa13.validator.LoginValidator.java
at.ac.tuwien.swa13.swazam.NetworkConnection.java
at.ac.tuwien.swa13.swazam.Peer.java
at.ac.tuwien.swa13.swazam.fingerprint.IFingerPrintCreator.java
at.ac.tuwien.swa13.swazam.fingerprint.impl.FingerPrintCreator.java
at.ac.tuwien.swa13.swazam.library.ILibraryManager.java
at.ac.tuwien.swa13.swazam.library.ISong.java
at.ac.tuwien.swa13.swazam.library.impl.LibraryManager.java
at.ac.tuwien.swa13.swazam.library.impl.Song.java
at.ac.tuwien.swa13.swazam.p2p.PeerConnector.java
at.saws2013.szazam.App.java
at.saws2013.szazam.BaseActivity.java
at.saws2013.szazam.HistoryActivity.java
at.saws2013.szazam.LoginActivity.java
at.saws2013.szazam.RecognitionActivity.java
at.saws2013.szazam.SettingsActivity.java
at.saws2013.szazam.entities.IListItem.java
at.saws2013.szazam.entities.ListItemTypes.java
at.saws2013.szazam.entities.Request.java
at.saws2013.szazam.entities.Transaction.java
at.saws2013.szazam.fingerprint.IFingerPrintSystem.java
at.saws2013.szazam.fingerprint.impl.FingerPrintCreator.java
at.saws2013.szazam.fragments.SettingsFragment.java
at.saws2013.szazam.media.IAudioFilePicker.java
at.saws2013.szazam.media.IAudioRecorder.java
at.saws2013.szazam.media.impl.AudioFilePicker.java
at.saws2013.szazam.media.impl.AudioRecorder.java
at.saws2013.szazam.store.IAuthStore.java
at.saws2013.szazam.store.IRequestStore.java
at.saws2013.szazam.store.ITransactionStore.java
at.saws2013.szazam.store.impl.AuthStore.java
at.saws2013.szazam.store.impl.RequestStore.java
at.saws2013.szazam.store.impl.TransactionStore.java
at.saws2013.szazam.ui.CustomListAdapter.java
at.saws2013.szazam.ui.ViewTools.java
at.saws2013.szazam.volley.CustomVolleyStringRequest.java
de.passsy.holocircularprogressbar.HoloCircularProgressBar.java