Commit 5cf62660 authored by Kevin Whitaker's avatar Kevin Whitaker

Rework how some data is piped in MPRIS interface. Have youtube-dl not output...

Rework how some data is piped in MPRIS interface. Have youtube-dl not output warnings which could interfere with process.
parent de8a550f
......@@ -148,7 +148,7 @@ QUrl MiniMediaPlayer::getStreamUrlFromUrl(QUrl mediaUrl)
{
//Run youtube-dl on Url and return Url given back.
QProcess youtubedl;
youtubedl.start("youtube-dl -f bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio[acodec=mp3] -g "+mediaUrl.toString());
youtubedl.start("youtube-dl --no-warnings -f bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio[acodec=mp3] -g "+mediaUrl.toString());
if(youtubedl.waitForFinished(-1))
{
QByteArray out = youtubedl.readAllStandardOutput();
......@@ -210,7 +210,7 @@ QList<QPair<QString,QUrl>> MiniMediaPlayer::getStreamTitlesAndUrlsFromUrl(QUrl m
QList<QPair<QString,QUrl>> tracks;
//Run youtube-dl on Url and return json given back.
QProcess youtubedl;
youtubedl.start("youtube-dl -f bestaudio -j "+mediaUrl.toString());
youtubedl.start("youtube-dl --no-warnings -f bestaudio -j "+mediaUrl.toString());
if(youtubedl.waitForFinished(-1))
{
//If there is anything in error output, error must have occured.
......
......@@ -76,9 +76,9 @@ void MPRISPlayerInterface::dbusUpdate(QVariantMap changed)
void MPRISPlayerInterface::mediaPositionChanged(qint64 position)
{
emit positionChanged(Position());
emit positionChanged(position * 1000); //milliseconds to microseconds
QVariantMap map;
map.insert("Position",Position());
map.insert("Position",position * 1000);
dbusUpdate(map);
}
......@@ -92,9 +92,9 @@ void MPRISPlayerInterface::mediaStateChanged(bool isPlaying)
void MPRISPlayerInterface::mediaVolumeChanged(int volume)
{
emit volumeChanged(Volume());
emit volumeChanged(volumeFromMediaPlayer(volume));
QVariantMap map;
map.insert("Volume",Volume());
map.insert("Volume",volumeFromMediaPlayer(volume));
dbusUpdate(map);
}
......@@ -203,8 +203,13 @@ double MPRISPlayerInterface::Rate()
double MPRISPlayerInterface::Volume()
{
if(player->getVolume() == 0) return 0;
else return player->getVolume()/100;
return volumeFromMediaPlayer(player->getVolume());
}
double MPRISPlayerInterface::volumeFromMediaPlayer(int volume)
{
if(volume== 0) return 0;
else return volume/100;
}
void MPRISPlayerInterface::setVolume(double volume)
......
......@@ -108,6 +108,7 @@ private slots:
private:
MiniMediaPlayer *player;
void dbusUpdate(QVariantMap changed);
double volumeFromMediaPlayer(int volume);
};
#endif // MPRISINTERFACE_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment