mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Added the ability to seek and get the song duration and position from
IPlaybackService.
This commit is contained in:
parent
f30686333e
commit
e1e609dd56
@ -62,6 +62,10 @@ namespace musik { namespace core { namespace sdk {
|
||||
virtual double GetVolume() = 0;
|
||||
virtual void SetVolume(double volume) = 0;
|
||||
|
||||
virtual double GetPosition() = 0;
|
||||
virtual void SetPosition(double seconds) = 0;
|
||||
virtual double GetDuration() = 0;
|
||||
|
||||
virtual bool IsMuted() = 0;
|
||||
virtual void ToggleMute() = 0;
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <core/library/LocalLibraryConstants.h>
|
||||
#include <core/plugin/PluginFactory.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using musik::core::TrackPtr;
|
||||
using musik::core::LibraryPtr;
|
||||
using musik::core::audio::ITransport;
|
||||
@ -51,7 +53,7 @@ using musik::core::audio::ITransport;
|
||||
using cursespp::IMessageTarget;
|
||||
using cursespp::IMessage;
|
||||
|
||||
using namespace musik::core::library::constants;
|
||||
using namespace musik::core::library;
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::sdk;
|
||||
using namespace musik::box;
|
||||
@ -243,10 +245,8 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
void PlaybackService::OnTrackChanged(size_t pos, TrackPtr track) {
|
||||
this->TrackChanged(this->index, track);
|
||||
|
||||
if (track) {
|
||||
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
||||
(*it)->OnTrackChanged(track.get());
|
||||
}
|
||||
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
||||
(*it)->OnTrackChanged(track.get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,6 +376,34 @@ void PlaybackService::SetVolume(double vol) {
|
||||
transport.SetVolume(vol);
|
||||
}
|
||||
|
||||
double PlaybackService::GetPosition() {
|
||||
return transport.Position();
|
||||
}
|
||||
|
||||
void PlaybackService::SetPosition(double seconds) {
|
||||
transport.SetPosition(seconds);
|
||||
}
|
||||
|
||||
double PlaybackService::GetDuration() {
|
||||
TrackPtr track;
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(this->playlistMutex);
|
||||
|
||||
size_t index = this->index;
|
||||
if (index < this->playlist.Count()) {
|
||||
track = this->playlist.Get(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (track) {
|
||||
return boost::lexical_cast<double>(
|
||||
track->GetValue(constants::Track::DURATION));
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
TrackPtr PlaybackService::GetTrackAtIndex(size_t index) {
|
||||
boost::recursive_mutex::scoped_lock lock(this->playlistMutex);
|
||||
return this->playlist.Get(index);
|
||||
|
@ -86,6 +86,9 @@ namespace musik {
|
||||
virtual void PauseOrResume();
|
||||
virtual bool IsMuted();
|
||||
virtual void ToggleMute();
|
||||
virtual double GetPosition();
|
||||
virtual void SetPosition(double seconds);
|
||||
virtual double GetDuration();
|
||||
|
||||
/* app-specific implementation */
|
||||
musik::core::audio::ITransport& GetTransport() { return this->transport; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user