mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-29 18:14:16 +00:00
Started a bit on a PlaybackQueue class.
This commit is contained in:
parent
526c098823
commit
c547063578
83
src/core/PlaybackQueue.cpp
Normal file
83
src/core/PlaybackQueue.cpp
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
|
85
src/core/PlaybackQueue.h
Normal file
85
src/core/PlaybackQueue.h
Normal file
@ -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 <core/audio/Transport.h>
|
||||
#include <core/tracklist/Standard.h>
|
||||
#include <core/Query/Tracks.h>
|
||||
#include <sigslot/sigslot.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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<musik::core::TrackPtr> CurrentTrackChanged;
|
||||
|
||||
private:
|
||||
TrackPtr currentTrack;
|
||||
void SetCurrentTrack(TrackPtr track);
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
} } // musik::core
|
||||
//////////////////////////////////////////////////////////////////////////////
|
@ -174,6 +174,14 @@
|
||||
RelativePath=".\pch.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PlaybackQueue.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PlaybackQueue.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="support"
|
||||
>
|
||||
|
@ -37,6 +37,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/tracklist/IBase.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
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<IRandomAccess> IRandomAccessPtr;
|
||||
|
||||
}
|
||||
} }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user