[UI+Backend] Moved to a Enum based command API for backend commands.
This commit is contained in:
parent
8738be39f1
commit
32f1007fd5
|
@ -239,10 +239,32 @@ MpvPlayerBackend::updateDiscord()
|
||||||
Discord_UpdatePresence(&discordPresence);
|
Discord_UpdatePresence(&discordPresence);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
QVariant
|
||||||
|
MpvPlayerBackend::playerCommand(const Enums::Commands& cmd)
|
||||||
|
{
|
||||||
|
return playerCommand(cmd, QVariant("NoArgProvided"));
|
||||||
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
MpvPlayerBackend::getaudioDevices() const
|
MpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
||||||
|
const QVariant& args)
|
||||||
{
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case Enums::Commands::TogglePlayPause: {
|
||||||
|
command(QVariantList() << "cycle"
|
||||||
|
<< "pause");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::ToggleMute: {
|
||||||
|
command(QVariantList() << "cycle"
|
||||||
|
<< "mute");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::SetAudioDevice: {
|
||||||
|
setProperty("audio-device", args.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::GetAudioDevices: {
|
||||||
QVariant drivers = getProperty("audio-device-list");
|
QVariant drivers = getProperty("audio-device-list");
|
||||||
QVariant currentDevice = getProperty("audio-device");
|
QVariant currentDevice = getProperty("audio-device");
|
||||||
|
|
||||||
|
@ -260,115 +282,145 @@ MpvPlayerBackend::getaudioDevices() const
|
||||||
pulseItem["selected"] = currentDevice == "pulse";
|
pulseItem["selected"] = currentDevice == "pulse";
|
||||||
newDrivers[pulseItem["description"].toString()] = pulseItem;
|
newDrivers[pulseItem["description"].toString()] = pulseItem;
|
||||||
return QVariant(newDrivers);
|
return QVariant(newDrivers);
|
||||||
}
|
}
|
||||||
|
case Enums::Commands::SetVolume: {
|
||||||
|
command(QVariantList() << "set"
|
||||||
|
<< "volume" << args);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
case Enums::Commands::AddVolume: {
|
||||||
MpvPlayerBackend::setAudioDevice(const QString& name)
|
|
||||||
{
|
|
||||||
setProperty("audio-device", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
command(QVariantList() << "add"
|
||||||
MpvPlayerBackend::togglePlayPause()
|
<< "volume" << args);
|
||||||
{
|
break;
|
||||||
command(QVariantList() << "cycle"
|
}
|
||||||
<< "pause");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
case Enums::Commands::AddSpeed: {
|
||||||
MpvPlayerBackend::toggleMute()
|
|
||||||
{
|
QString speedString =
|
||||||
command(QVariantList() << "cycle"
|
QString::number(getProperty("speed").toDouble() + args.toDouble());
|
||||||
<< "mute");
|
QVariant newSpeed =
|
||||||
}
|
QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
||||||
|
|
||||||
|
playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Enums::Commands::SubtractSpeed: {
|
||||||
|
|
||||||
|
QString speedString =
|
||||||
|
QString::number(getProperty("speed").toDouble() - args.toDouble());
|
||||||
|
QVariant newSpeed =
|
||||||
|
QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
||||||
|
playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Enums::Commands::ChangeSpeed: {
|
||||||
|
|
||||||
|
playerCommand(
|
||||||
|
Enums::Commands::SetSpeed,
|
||||||
|
QVariant(getProperty("speed").toDouble() * args.toDouble()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Enums::Commands::SetSpeed: {
|
||||||
|
|
||||||
|
command(QVariantList() << "set"
|
||||||
|
<< "speed" << args.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::ToggleStats: {
|
||||||
|
|
||||||
|
command(QVariantList() << "script-binding"
|
||||||
|
<< "stats/display-stats-toggle");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::NextAudioTrack: {
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::nextAudioTrack()
|
|
||||||
{
|
|
||||||
command(QVariantList() << "cycle"
|
command(QVariantList() << "cycle"
|
||||||
<< "audio");
|
<< "audio");
|
||||||
}
|
break;
|
||||||
void
|
}
|
||||||
MpvPlayerBackend::nextSubtitleTrack()
|
case Enums::Commands::NextSubtitleTrack: {
|
||||||
{
|
|
||||||
command(QVariantList() << "cycle"
|
command(QVariantList() << "cycle"
|
||||||
<< "sub");
|
<< "sub");
|
||||||
}
|
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::nextVideoTrack()
|
}
|
||||||
{
|
case Enums::Commands::NextVideoTrack: {
|
||||||
command(QVariantList() << "cycle"
|
command(QVariantList() << "cycle"
|
||||||
<< "video");
|
<< "video");
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::PreviousPlaylistItem: {
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::prevPlaylistItem()
|
|
||||||
{
|
|
||||||
command(QVariantList() << "playlist-prev");
|
command(QVariantList() << "playlist-prev");
|
||||||
}
|
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::nextPlaylistItem()
|
}
|
||||||
{
|
case Enums::Commands::NextPlaylistItem: {
|
||||||
|
|
||||||
command(QVariantList() << "playlist-next"
|
command(QVariantList() << "playlist-next"
|
||||||
<< "force");
|
<< "force");
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
case Enums::Commands::LoadFile: {
|
||||||
|
command(QVariantList() << "loadfile" << args);
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::loadFile(const QVariant& filename)
|
}
|
||||||
{
|
case Enums::Commands::AppendFile: {
|
||||||
command(QVariantList() << "loadfile" << filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
command(QVariantList() << "loadfile" << args << "append-play");
|
||||||
MpvPlayerBackend::appendFile(const QVariant& filename)
|
break;
|
||||||
{
|
}
|
||||||
command(QVariantList() << "loadfile" << filename << "append-play");
|
case Enums::Commands::Seek: {
|
||||||
}
|
|
||||||
|
|
||||||
void
|
command(QVariantList() << "seek" << args);
|
||||||
MpvPlayerBackend::setVolume(const QVariant& volume)
|
|
||||||
{
|
|
||||||
command(QVariantList() << "set"
|
|
||||||
<< "volume" << volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::addVolume(const QVariant& volume)
|
}
|
||||||
{
|
case Enums::Commands::SeekAbsolute: {
|
||||||
command(QVariantList() << "add"
|
|
||||||
<< "volume" << volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
command(QVariantList() << "seek" << args << "absolute");
|
||||||
MpvPlayerBackend::seekAbsolute(const QVariant& seekTime)
|
|
||||||
{
|
|
||||||
command(QVariantList() << "seek" << seekTime << "absolute");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::seek(const QVariant& seekTime)
|
}
|
||||||
{
|
case Enums::Commands::GetTracks: {
|
||||||
command(QVariantList() << "seek" << seekTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant
|
|
||||||
MpvPlayerBackend::getTracks() const
|
|
||||||
{
|
|
||||||
return mpv::qt::get_property_variant(mpv, "track-list");
|
return mpv::qt::get_property_variant(mpv, "track-list");
|
||||||
}
|
|
||||||
|
|
||||||
void
|
break;
|
||||||
MpvPlayerBackend::setTrack(const QVariant& track, const QVariant& id)
|
}
|
||||||
{
|
case Enums::Commands::ForwardFrame: {
|
||||||
command(QVariantList() << "set" << track << id);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant
|
command(QVariantList() << "frame-step");
|
||||||
MpvPlayerBackend::getTrack(const QString& track)
|
|
||||||
{
|
break;
|
||||||
return mpv::qt::get_property_variant(mpv, track);
|
}
|
||||||
|
case Enums::Commands::BackwardFrame: {
|
||||||
|
|
||||||
|
command(QVariantList() << "frame-back-step");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Enums::Commands::SetTrack: {
|
||||||
|
|
||||||
|
command(QVariantList() << "set" << args.toList()[0] << args.toList()[1]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
qDebug() << "Command not found: " << cmd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant("NoOutput");
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
|
@ -394,44 +446,6 @@ MpvPlayerBackend::toggleOnTop()
|
||||||
AlwaysOnTop(window()->winId(), onTop);
|
AlwaysOnTop(window()->winId(), onTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::toggleStats()
|
|
||||||
{
|
|
||||||
command(QVariantList() << "script-binding"
|
|
||||||
<< "stats/display-stats-toggle");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::addSpeed(const QVariant& speed)
|
|
||||||
{
|
|
||||||
QString speedString =
|
|
||||||
QString::number(getProperty("speed").toDouble() + speed.toDouble());
|
|
||||||
speedString = speedString.left(speedString.lastIndexOf('.') + 2);
|
|
||||||
setSpeed(QVariant(speedString));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::subtractSpeed(const QVariant& speed)
|
|
||||||
{
|
|
||||||
QString speedString =
|
|
||||||
QString::number(getProperty("speed").toDouble() - speed.toDouble());
|
|
||||||
speedString = speedString.left(speedString.lastIndexOf('.') + 2);
|
|
||||||
setSpeed(QVariant(speedString));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::changeSpeed(const QVariant& speedFactor)
|
|
||||||
{
|
|
||||||
setSpeed(QVariant(getProperty("speed").toDouble() * speedFactor.toDouble()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MpvPlayerBackend::setSpeed(const QVariant& speed)
|
|
||||||
{
|
|
||||||
command(QVariantList() << "set"
|
|
||||||
<< "speed" << speed.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MpvPlayerBackend::on_mpv_events()
|
MpvPlayerBackend::on_mpv_events()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,43 +30,23 @@ public:
|
||||||
virtual Renderer* createRenderer() const;
|
virtual Renderer* createRenderer() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
// All 4 required for Player API
|
||||||
|
QVariant playerCommand(const Enums::Commands& command, const QVariant& args);
|
||||||
|
QVariant playerCommand(const Enums::Commands& command);
|
||||||
void launchAboutQt();
|
void launchAboutQt();
|
||||||
#ifdef DISCORD
|
|
||||||
void updateDiscord();
|
|
||||||
#endif
|
|
||||||
void togglePlayPause();
|
|
||||||
void toggleMute();
|
|
||||||
void nextAudioTrack();
|
|
||||||
void nextVideoTrack();
|
|
||||||
void nextSubtitleTrack();
|
|
||||||
void prevPlaylistItem();
|
|
||||||
void nextPlaylistItem();
|
|
||||||
void toggleOnTop();
|
void toggleOnTop();
|
||||||
void toggleStats();
|
// Optional but handy for MPV or custom backend settings.
|
||||||
QVariant getTracks() const;
|
|
||||||
QVariant getaudioDevices() const;
|
|
||||||
void setAudioDevice(const QString& name);
|
|
||||||
void addSpeed(const QVariant& speed);
|
|
||||||
void subtractSpeed(const QVariant& speed);
|
|
||||||
void changeSpeed(const QVariant& speedFactor);
|
|
||||||
void setSpeed(const QVariant& speed);
|
|
||||||
QVariant getTrack(const QString& track);
|
|
||||||
void setTrack(const QVariant& track, const QVariant& id);
|
|
||||||
void setVolume(const QVariant& volume);
|
|
||||||
void addVolume(const QVariant& volume);
|
|
||||||
void loadFile(const QVariant& filename);
|
|
||||||
void appendFile(const QVariant& filename);
|
|
||||||
void seek(const QVariant& seekTime);
|
|
||||||
void seekAbsolute(const QVariant& seekTime);
|
|
||||||
void command(const QVariant& params);
|
void command(const QVariant& params);
|
||||||
void setProperty(const QString& name, const QVariant& value);
|
void setProperty(const QString& name, const QVariant& value);
|
||||||
void setOption(const QString& name, const QVariant& value);
|
void setOption(const QString& name, const QVariant& value);
|
||||||
QVariant getProperty(const QString& name) const;
|
QVariant getProperty(const QString& name) const;
|
||||||
|
// Misc function.
|
||||||
QVariant createTimestamp(const QVariant& seconds) const;
|
QVariant createTimestamp(const QVariant& seconds) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onUpdate();
|
void onUpdate();
|
||||||
void mpv_events();
|
void mpv_events();
|
||||||
|
// All below required for Player API
|
||||||
void playStatusChanged(const Enums::PlayStatus& status);
|
void playStatusChanged(const Enums::PlayStatus& status);
|
||||||
void volumeStatusChanged(const Enums::VolumeStatus& status);
|
void volumeStatusChanged(const Enums::VolumeStatus& status);
|
||||||
void volumeChanged(const int& volume);
|
void volumeChanged(const int& volume);
|
||||||
|
@ -87,6 +67,9 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handle_mpv_event(mpv_event* event);
|
void handle_mpv_event(mpv_event* event);
|
||||||
|
#ifdef DISCORD
|
||||||
|
void updateDiscord();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,34 @@ enum class VolumeStatus : int
|
||||||
Normal = 2
|
Normal = 2
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(VolumeStatus)
|
Q_ENUM_NS(VolumeStatus)
|
||||||
|
enum class Commands : int
|
||||||
|
{
|
||||||
|
TogglePlayPause = 0,
|
||||||
|
ToggleMute = 1,
|
||||||
|
SetAudioDevice = 2,
|
||||||
|
GetAudioDevices = 3,
|
||||||
|
AddVolume = 4,
|
||||||
|
SetVolume = 5,
|
||||||
|
AddSpeed = 6,
|
||||||
|
SubtractSpeed = 7,
|
||||||
|
ChangeSpeed = 8,
|
||||||
|
SetSpeed = 9,
|
||||||
|
ToggleStats = 10,
|
||||||
|
NextAudioTrack = 11,
|
||||||
|
NextVideoTrack = 12,
|
||||||
|
NextSubtitleTrack = 13,
|
||||||
|
PreviousPlaylistItem = 14,
|
||||||
|
NextPlaylistItem = 15,
|
||||||
|
LoadFile = 16,
|
||||||
|
AppendFile = 17,
|
||||||
|
Seek = 18,
|
||||||
|
SeekAbsolute = 19,
|
||||||
|
GetTracks = 20,
|
||||||
|
ForwardFrame = 21,
|
||||||
|
BackwardFrame = 22,
|
||||||
|
SetTrack = 23
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(Commands)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -122,6 +122,7 @@ main(int argc, char* argv[])
|
||||||
);
|
);
|
||||||
qRegisterMetaType<Enums::PlayStatus>("Enums.PlayStatus");
|
qRegisterMetaType<Enums::PlayStatus>("Enums.PlayStatus");
|
||||||
qRegisterMetaType<Enums::VolumeStatus>("Enums.VolumeStatus");
|
qRegisterMetaType<Enums::VolumeStatus>("Enums.VolumeStatus");
|
||||||
|
qRegisterMetaType<Enums::Commands>("Enums.Commands");
|
||||||
|
|
||||||
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
||||||
std::setlocale(LC_NUMERIC, "C");
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.11
|
import QtQuick 2.11
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
|
import player 1.0
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
id: audioDeviceItem
|
id: audioDeviceItem
|
||||||
|
@ -9,6 +10,6 @@ Action {
|
||||||
checked: false
|
checked: false
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.setAudioDevice(deviceID)
|
player.playerCommand(Enums.Commands.SetAudioDevice, deviceID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import player 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
@ -129,7 +128,7 @@ Item {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onMoved: {
|
onMoved: {
|
||||||
player.seekAbsolute(progressBar.value)
|
player.playerCommand(Enums.Commands.SeekAbsolute, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProgressBarHeight(nyan, isMouse) {
|
function getProgressBarHeight(nyan, isMouse) {
|
||||||
|
@ -227,7 +226,7 @@ Item {
|
||||||
visible: false
|
visible: false
|
||||||
width: visible ? playPauseButton.width : 0
|
width: visible ? playPauseButton.width : 0
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.prevPlaylistItem()
|
player.playerCommand(Enums.Commands.PreviousPlaylistItem)
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -252,7 +251,7 @@ Item {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: playlistPrevButton.right
|
anchors.left: playlistPrevButton.right
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.togglePlayPause()
|
player.playerCommand(Enums.Commands.TogglePlayPause)
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -278,7 +277,7 @@ Item {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: playPauseButton.right
|
anchors.left: playPauseButton.right
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.nextPlaylistItem()
|
player.playerCommand(Enums.Commands.NextPlaylistItem)
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -295,7 +294,7 @@ Item {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: playlistNextButton.right
|
anchors.left: playlistNextButton.right
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.toggleMute()
|
player.playerCommand(Enums.Commands.ToggleMute)
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -331,7 +330,7 @@ Item {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
onMoved: {
|
onMoved: {
|
||||||
player.setVolume(Math.round(volumeBar.value).toString())
|
player.playerCommand(Enums.Commands.SetVolume, Math.round(volumeBar.value).toString())
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
player.volumeChanged.connect(function(volume) {
|
player.volumeChanged.connect(function(volume) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ MenuBar {
|
||||||
subMenu.removeAction(subAction)
|
subMenu.removeAction(subAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var newTracks = player.getTracks()
|
var newTracks = player.playerCommand(Enums.Commands.GetTracks)
|
||||||
|
|
||||||
for (var i = 0, len = newTracks.length; i < len; i++) {
|
for (var i = 0, len = newTracks.length; i < len; i++) {
|
||||||
var track = newTracks[i]
|
var track = newTracks[i]
|
||||||
|
@ -111,7 +111,7 @@ MenuBar {
|
||||||
title: translate.getTranslation("OPEN_FILE", i18n.language)
|
title: translate.getTranslation("OPEN_FILE", i18n.language)
|
||||||
nameFilters: ["All files (*)"]
|
nameFilters: ["All files (*)"]
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
player.loadFile(String(fileDialog.file))
|
player.playerCommand(Enums.Commands.LoadFile, String(fileDialog.file))
|
||||||
fileDialog.close()
|
fileDialog.close()
|
||||||
}
|
}
|
||||||
onRejected: {
|
onRejected: {
|
||||||
|
@ -124,7 +124,7 @@ MenuBar {
|
||||||
title: translate.getTranslation("URL_FILE_PATH", i18n.language)
|
title: translate.getTranslation("URL_FILE_PATH", i18n.language)
|
||||||
standardButtons: StandardButton.Cancel | StandardButton.Open
|
standardButtons: StandardButton.Cancel | StandardButton.Open
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
player.loadFile(pathText.text)
|
player.playerCommand(Enums.Commands.LoadFile, pathText.text)
|
||||||
pathText.text = ""
|
pathText.text = ""
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
|
@ -225,35 +225,35 @@ MenuBar {
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("PLAY_PAUSE", i18n.language)
|
text: translate.getTranslation("PLAY_PAUSE", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.togglePlayPause()
|
player.playerCommand(Enums.Commands.TogglePlayPause)
|
||||||
}
|
}
|
||||||
shortcut: String(keybinds.playPause)
|
shortcut: String(keybinds.playPause)
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("REWIND_10S", i18n.language)
|
text: translate.getTranslation("REWIND_10S", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.seek("-10")
|
player.playerCommand(Enums.Commands.Seek, "-10")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.rewind10
|
shortcut: keybinds.rewind10
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("FORWARD_10S", i18n.language)
|
text: translate.getTranslation("FORWARD_10S", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.seek("10")
|
player.playerCommand(Enums.Commands.Seek, "10")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.forward10
|
shortcut: keybinds.forward10
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("FORWARD_5S", i18n.language)
|
text: translate.getTranslation("FORWARD_5S", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.seek("-5")
|
player.playerCommand(Enums.Commands.Seek, "-5")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.rewind5
|
shortcut: keybinds.rewind5
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("FORWARD_5S", i18n.language)
|
text: translate.getTranslation("FORWARD_5S", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.seek("5")
|
player.playerCommand(Enums.Commands.Seek, "5")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.forward5
|
shortcut: keybinds.forward5
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ MenuBar {
|
||||||
text: translate.getTranslation("SPEED_DECREASE_POINT_ONE",
|
text: translate.getTranslation("SPEED_DECREASE_POINT_ONE",
|
||||||
i18n.language)
|
i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.subtractSpeed(0.1)
|
player.playerCommand(Enums.Commands.SubtractSpeed, 0.1)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.decreaseSpeedByPointOne
|
shortcut: keybinds.decreaseSpeedByPointOne
|
||||||
}
|
}
|
||||||
|
@ -269,35 +269,35 @@ MenuBar {
|
||||||
text: translate.getTranslation("SPEED_INCREASE_POINT_ONE",
|
text: translate.getTranslation("SPEED_INCREASE_POINT_ONE",
|
||||||
i18n.language)
|
i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.addSpeed(0.1)
|
player.playerCommand(Enums.Commands.AddSpeed, 0.1)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.increaseSpeedByPointOne
|
shortcut: keybinds.increaseSpeedByPointOne
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("HALVE_SPEED", i18n.language)
|
text: translate.getTranslation("HALVE_SPEED", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.changeSpeed(0.5)
|
player.playerCommand(Enums.Commands.ChangeSpeed, 0.5)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.halveSpeed
|
shortcut: keybinds.halveSpeed
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("DOUBLE_SPEED", i18n.language)
|
text: translate.getTranslation("DOUBLE_SPEED", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.changeSpeed(2)
|
player.playerCommand(Enums.Commands.ChangeSpeed, 2)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.doubleSpeed
|
shortcut: keybinds.doubleSpeed
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("FORWARD_FRAME", i18n.language)
|
text: translate.getTranslation("FORWARD_FRAME", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.command(["frame-step"])
|
player.playerCommand(Enums.Commands.ForwardFrame)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.forwardFrame
|
shortcut: keybinds.forwardFrame
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("BACKWARD_FRAME", i18n.language)
|
text: translate.getTranslation("BACKWARD_FRAME", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.command(["frame-back-step"])
|
player.playerCommand(Enums.Commands.BackwardFrame)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.backwardFrame
|
shortcut: keybinds.backwardFrame
|
||||||
}
|
}
|
||||||
|
@ -309,28 +309,28 @@ MenuBar {
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("CYCLE_AUDIO_TRACK", i18n.language)
|
text: translate.getTranslation("CYCLE_AUDIO_TRACK", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.nextAudioTrack()
|
player.playerCommand(Enums.Commands.NextAudioTrack)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.cycleAudio
|
shortcut: keybinds.cycleAudio
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("INCREASE_VOLUME", i18n.language)
|
text: translate.getTranslation("INCREASE_VOLUME", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.addVolume("2")
|
player.playerCommand(Enums.Commands.AddVolume, "2")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.increaseVolume
|
shortcut: keybinds.increaseVolume
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("DECREASE_VOLUME", i18n.language)
|
text: translate.getTranslation("DECREASE_VOLUME", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.addVolume("-2")
|
player.playerCommand(Enums.Commands.AddVolume, "-2")
|
||||||
}
|
}
|
||||||
shortcut: keybinds.decreaseVolume
|
shortcut: keybinds.decreaseVolume
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("MUTE_VOLUME", i18n.language)
|
text: translate.getTranslation("MUTE_VOLUME", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.toggleMute()
|
player.playerCommand(Enums.Commands.ToggleMute)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.mute
|
shortcut: keybinds.mute
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ MenuBar {
|
||||||
player.audioDevicesChanged.connect(updateAudioDevices)
|
player.audioDevicesChanged.connect(updateAudioDevices)
|
||||||
}
|
}
|
||||||
function updateAudioDevices() {
|
function updateAudioDevices() {
|
||||||
var audioDevices = player.getaudioDevices()
|
var audioDevices = player.playerCommand(Enums.Commands.GetAudioDevices)
|
||||||
|
|
||||||
for (var i = 0, len = audioDeviceMenu.count; i < len; i++) {
|
for (var i = 0, len = audioDeviceMenu.count; i < len; i++) {
|
||||||
audioDeviceMenu.takeAction(0)
|
audioDeviceMenu.takeAction(0)
|
||||||
|
@ -468,7 +468,7 @@ MenuBar {
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("STATS", i18n.language)
|
text: translate.getTranslation("STATS", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.toggleStats()
|
player.playerCommand(Enums.Commands.ToggleStats)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.statsForNerds
|
shortcut: keybinds.statsForNerds
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.11
|
import QtQuick 2.11
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
|
import player 1.0
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
id: trackItem
|
id: trackItem
|
||||||
|
@ -10,7 +11,6 @@ Action {
|
||||||
checked: false
|
checked: false
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
checked = player.getTrack(trackType)
|
player.playerCommand(Enums.Commands.SetTrack, [trackType, trackID])
|
||||||
player.setTrack(trackType, trackID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.appendFile(argument)
|
player.playerCommand(Enums.Commands.AppendFile, argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ ApplicationWindow {
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
skipto = Math.floor(controlsBar.controls.progress.to / 9 * val)
|
skipto = Math.floor(controlsBar.controls.progress.to / 9 * val)
|
||||||
}
|
}
|
||||||
player.seekAbsolute(skipto)
|
player.playerCommand(Enums.Commands.SeekAbsolute, skipto)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAnyMenuOpen() {
|
function isAnyMenuOpen() {
|
||||||
|
@ -190,7 +190,7 @@ ApplicationWindow {
|
||||||
cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor
|
cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (appearance.clickToPause) {
|
if (appearance.clickToPause) {
|
||||||
player.togglePlayPause()
|
player.playerCommand(Enums.Commands.TogglePlayPause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
|
|
Loading…
Reference in a new issue