Android Open Source - SimpleMusicPlayer Song






From Project

Back to project page SimpleMusicPlayer.

License

The source code is released under:

Copyright 2011 Micha? Kazior. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project SimpleMusicPlayer 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 com.michalkazior.simplemusicplayer;
//from   w ww.java  2s . c om
import android.os.Parcel;
import android.os.Parcelable;

public class Song implements Parcelable {
  private static int nextId = 0;
  private int id;
  private String path;
  private String title; // todo

  public static final Parcelable.Creator<Song> CREATOR = new Creator<Song>() {
    @Override
    public Song createFromParcel(Parcel source) {
      return new Song(source);
    }

    @Override
    public Song[] newArray(int size) {
      return new Song[size];
    }
  };

  public Song() {
  }

  public Song(String path, String title) {
    this.id = nextId++;
    this.path = path;
    this.title = title;
  }

  private Song(Parcel in) {
    id = in.readInt();
    path = in.readString();
    title = in.readString();
  }

  public Song(Song song) {
    id = song.id;
    path = song.path;
    title = song.title;
  }

  public Song spawn() {
    Song song = new Song();
    song.id = nextId++;
    song.path = this.path;
    song.title = this.title;
    return song;
  }

  public int getId() {
    return id;
  }

  public String getPath() {
    return path;
  }

  public String getTitle() {
    return title;
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(id);
    dest.writeString(path);
    dest.writeString(title);
  }

  @Override
  public boolean equals(Object o) {
    return (o instanceof Song) && ((Song) o).id == this.id;
  }

  public static boolean equals(Song a, Song b) {
    return a != null && b != null && a.getId() == b.getId();
  }
}




Java Source Code List

com.michalkazior.simplemusicplayer.Player.java
com.michalkazior.simplemusicplayer.SongAdapter.java
com.michalkazior.simplemusicplayer.SongList.java
com.michalkazior.simplemusicplayer.SongQueue.java
com.michalkazior.simplemusicplayer.Song.java