Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Added playlist type to Playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Brandhorst committed Feb 8, 2014
1 parent 1d01fab commit cfcec55
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion SpotiFire.LibSpotify/Playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ static __forceinline DateTime TIMESTAMP(int timestamp) {
return dt.AddSeconds(timestamp).ToLocalTime();
}

Playlist::Playlist(SpotiFire::Session ^session, sp_playlist *ptr) {
Playlist::Playlist(SpotiFire::Session ^session, sp_playlist *ptr, SpotiFire::PlaylistType type) {
SPLock lock;
_ptr = ptr;
_session = session;
_type = type;
sp_playlist_add_ref(_ptr);
sp_playlist_add_callbacks(_ptr, &_callbacks, new gcroot<Playlist ^>(this));
}

Playlist::Playlist(SpotiFire::Session ^session, sp_playlist *ptr) : Playlist::Playlist(session, ptr, SpotiFire::PlaylistType::Playlist) {}

Playlist::~Playlist() {
this->!Playlist();
}
Expand All @@ -65,6 +68,10 @@ Playlist::!Playlist() {
_ptr = NULL;
}

PlaylistType Playlist::Type::get() {
return _type;
}

Session ^Playlist::Session::get() {
return _session;
}
Expand Down
9 changes: 9 additions & 0 deletions SpotiFire.LibSpotify/Playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ namespace SpotiFire {
internal:
Session ^_session;
sp_playlist *_ptr;
PlaylistType _type;
ObservableSPList<Track ^> ^_tracks;

static Logger ^logger = LogManager::GetCurrentClassLogger();

Playlist(Session ^session, sp_playlist *ptr);
Playlist(Session ^session, sp_playlist *ptr, PlaylistType type);
!Playlist(); // finalizer
~Playlist(); // destructor

Expand All @@ -57,6 +59,13 @@ namespace SpotiFire {

public:

///-------------------------------------------------------------------------------------------------
/// <summary> Gets the type of the playlist. </summary>
///
/// <value> The connection type. <see cref="SpotiFire::PlaylistType" /> for possible values. </value>
///-------------------------------------------------------------------------------------------------
virtual property PlaylistType Type { SpotiFire::PlaylistType get() sealed; }

///-------------------------------------------------------------------------------------------------
/// <summary> Gets the session. </summary>
///
Expand Down
4 changes: 2 additions & 2 deletions SpotiFire.LibSpotify/Playlistcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ref class $PlaylistContainer$PlaylistList sealed : ObservableSPList<Playlist ^>

virtual Playlist ^DoFetch(int index) override sealed {
SPLock lock;
return gcnew Playlist(_pc->_session, sp_playlistcontainer_playlist(_pc->_ptr, index));
return gcnew Playlist(_pc->_session, sp_playlistcontainer_playlist(_pc->_ptr, index), _pc->GetPlaylistType(index));
}

virtual void DoInsert(int index, Playlist ^item) override sealed {
Expand Down Expand Up @@ -134,7 +134,7 @@ void SP_CALLCONV playlist_added(sp_playlistcontainer *pc, sp_playlist *playlist,

void SP_CALLCONV playlist_removed(sp_playlistcontainer *pc, sp_playlist *playlist, int position, void *userdata) {
PlaylistContainer^ plc = SP_DATA(PlaylistContainer, userdata);
TP2(Playlist^, int, plc, PlaylistContainer::playlist_removed, gcnew SpotiFire::Playlist(plc->Session, playlist), position);
TP2(Playlist^, int, plc, PlaylistContainer::playlist_removed, gcnew SpotiFire::Playlist(plc->Session, playlist, SpotiFire::PlaylistType::Placeholder), position);
}

void SP_CALLCONV playlist_moved(sp_playlistcontainer *pc, sp_playlist *playlist, int position, int new_position, void *userdata) {
Expand Down

0 comments on commit cfcec55

Please sign in to comment.