/* vim: set noexpandtab tabstop=4 shiftwidth=4 nowrap textwidth=100
*
* Echo Media Player
* Copyright (C) 2008 Shane O'Connell
*
* [ The original file includes a copyright header in this location describing
* the file as being released under the terms of the GNU General Public
* License. It has been removed in order to display the file as part of the
* archive. ]
*/
using Echo.Interfaces;
public class Echo.Database.Track : GLib.Object, ITrack, IRateableTrack
{
private string _title;
public string title { get { return _title; } }
private string _artist;
public string artist { get { return _artist; } }
private string _album;
public string album { get { return _album; } }
private int _track_number;
public int track_number { get { return _track_number; } }
private int _release_year;
public int release_year { get { return _release_year; } }
private int _release_month;
public int release_month { get { return _release_month; } }
private int _release_day;
public int release_day { get { return _release_day; } }
private string _uri;
public string uri { get { return _uri; } }
private int _rating;
public int rating { get { return _rating; } set { set_rating(value); } }
/*public string title { get; private set; }
public string artist { get; private set; }
public string album { get; private set; }
public int track_number { get; private set; }
public GLib.Date release_date { get; private set; }
public string uri { get; private set; }*/
public IPlaySource source { get { return _library; } }
private weak Library _library;
private int64 _id;
public Track(Library library, int64 id, string title, string artist, string album,
int track_number, int release_year, int release_month, int release_day, string uri,
int rating)
{
_library = library;
_id = id;
_title = title;
_artist = artist;
_album = album;
_track_number = track_number;
_release_year = release_year;
_release_month = release_month;
_release_day = release_day;
_uri = uri;
_rating = rating;
}
public int index
{
get {
return _library.get_index_from_track_id(_id);
}
}
public ITrack? get_next()
{
int i = this.index + 1;
if (i >= 0 && i < _library.get_num_tracks())
return _library.get_track(i);
else
return null;
}
public ITrack? get_prev()
{
int i = this.index - 1;
if (i >= 0 && i < _library.get_num_tracks())
return _library.get_track(i);
else
return null;
}
public bool valid
{
get { return true; } // TODO figure out when a database track is invalid
}
private void set_rating(int value)
{
_rating = value;
debug("Track: set id %lld to %d", _id, value);
_library.set_rating(_id, value);
}
}