diff --git a/src/core/PlaybackQueue.cpp b/src/core/PlaybackQueue.cpp new file mode 100644 index 000000000..b234439a8 --- /dev/null +++ b/src/core/PlaybackQueue.cpp @@ -0,0 +1,83 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright © 2007, mC2 team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// +#include "pch.hpp" +#include "PlaybackQueue.h" + +using namespace musik::core; + +////////////////////////////////////////////////////////////////////////////// + +PlaybackQueue PlaybackQueue::sInstance; + + +PlaybackQueue::PlaybackQueue(void) : + nowPlaying( new musik::core::tracklist::Standard() ) +{ +} + +PlaybackQueue::~PlaybackQueue(void) +{ +} + +tracklist::IRandomAccessPtr PlaybackQueue::NowPlayingTracklist(){ + return this->nowPlaying; +} + +void PlaybackQueue::Play(){ + + TrackPtr track(this->CurrentTrack()); + + if(track){ + // If current track exists + this->transport.Start(track->GetValue("path")); + } + +} + +TrackPtr PlaybackQueue::CurrentTrack(){ + if(!this->currentTrack){ + // If the current track is empty, get a track from the nowPlaying tracklist + this->SetCurrentTrack( this->nowPlaying->CurrentTrack() ); + } + return this->currentTrack; +} + +void PlaybackQueue::SetCurrentTrack(TrackPtr track){ + if(this->currentTrack!=track){ + this->currentTrack = track; + + // Call the signal if track updates + this->CurrentTrackChanged(track); + } +} + diff --git a/src/core/PlaybackQueue.h b/src/core/PlaybackQueue.h new file mode 100644 index 000000000..f73db5631 --- /dev/null +++ b/src/core/PlaybackQueue.h @@ -0,0 +1,85 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright © 2007, mC2 team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#pragma once + +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +////////////////////////////////////////////////////////////////////////////// + +namespace musik { namespace core { + +////////////////////////////////////////////////////////////////////////////// + +class PlaybackQueue{ + private: + PlaybackQueue(void); + static PlaybackQueue sInstance; + + audio::Transport transport; + tracklist::IRandomAccessPtr nowPlaying; + + public: + ~PlaybackQueue(void); + static PlaybackQueue& Instance(){ return sInstance; }; + + // Now Playing control + tracklist::IRandomAccessPtr NowPlayingTracklist(); + void Play(tracklist::IRandomAccess &tracklist); + void Append(tracklist::IRandomAccess &tracklist); + + // Playback Control + void Play(); + void Next(); + void Previos(); + void Stop(); + + musik::core::TrackPtr CurrentTrack(); + + // Public signals + sigslot::signal1 CurrentTrackChanged; + + private: + TrackPtr currentTrack; + void SetCurrentTrack(TrackPtr track); + +}; + +////////////////////////////////////////////////////////////////////////////// +} } // musik::core +////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/core.vcproj b/src/core/core.vcproj index 940e2e92c..f66ea1383 100644 --- a/src/core/core.vcproj +++ b/src/core/core.vcproj @@ -174,6 +174,14 @@ RelativePath=".\pch.hpp" > + + + + diff --git a/src/core/tracklist/IRandomAccess.h b/src/core/tracklist/IRandomAccess.h index 6d7f29a67..d27815eda 100644 --- a/src/core/tracklist/IRandomAccess.h +++ b/src/core/tracklist/IRandomAccess.h @@ -37,6 +37,7 @@ #pragma once #include "core/tracklist/IBase.h" +#include namespace musik{ namespace core{ namespace tracklist { @@ -49,6 +50,9 @@ namespace musik{ namespace core{ virtual void SetCurrentPosition(int position) = 0; virtual int CurrentPosition() = 0; }; + + typedef boost::shared_ptr IRandomAccessPtr; + } } }