mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-17 16:37:46 +02:00
spotify stream
This commit is contained in:
parent
50a4380616
commit
e0d9de5904
4 changed files with 80 additions and 32 deletions
|
@ -17,6 +17,8 @@
|
|||
***/
|
||||
|
||||
#include "spotifyStream.h"
|
||||
#include "common/snapException.h"
|
||||
#include "common/log.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
@ -26,6 +28,12 @@ using namespace std;
|
|||
|
||||
SpotifyStream::SpotifyStream(PcmListener* pcmListener, const StreamUri& uri) : ProcessStream(pcmListener, uri)
|
||||
{
|
||||
sampleFormat_ = SampleFormat("44100:16:2");
|
||||
string username = uri_.getQuery("username", "");
|
||||
string password = uri_.getQuery("password", "");
|
||||
string bitrate = uri_.getQuery("bitrate", "320");
|
||||
params = "--name \"" + name_ + "\" --username \"" + username + "\" --password \"" + password + "\" --bitrate " + bitrate + " --backend stdout";
|
||||
logO << "params: " << params << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,3 +41,30 @@ SpotifyStream::~SpotifyStream()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
void SpotifyStream::initExeAndPath(const std::string& filename)
|
||||
{
|
||||
exe = findExe(filename);
|
||||
if (!fileExists(exe) || (exe == "/"))
|
||||
{
|
||||
exe = findExe("librespot");
|
||||
if (!fileExists(exe))
|
||||
throw SnapException("librespot not found");
|
||||
}
|
||||
|
||||
if (exe.find("/") != string::npos)
|
||||
path = exe.substr(0, exe.find_last_of("/"));
|
||||
}
|
||||
|
||||
|
||||
void SpotifyStream::onStderrMsg(const char* buffer, size_t n)
|
||||
{
|
||||
string logmsg(buffer, n);
|
||||
if ((logmsg.find("allocated stream") == string::npos) &&
|
||||
(logmsg.find("Got channel") == string::npos) &&
|
||||
(logmsg.size() > 4))
|
||||
{
|
||||
logO << logmsg;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue