playerlauncher.cpp 961 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "playerlauncher.h"
  2. #include <QDebug>
  3. #include <QDesktopServices>
  4. #include <QDir>
  5. #include <QFile>
  6. #include <QTextStream>
  7. #include <QUrl>
  8. PlayerLauncher::PlayerLauncher(QObject *parent) :
  9. QObject(parent)
  10. {
  11. }
  12. void PlayerLauncher::launchPlayer(const QString &url)
  13. {
  14. qDebug() << "Given url: " << url;
  15. qDebug() << "temp path:" << QDir::tempPath();
  16. QString videoFilePath = QDir::tempPath() + "/" + "videostreamer.ram";
  17. qDebug() << "videofilepath:" << videoFilePath;
  18. QFile file(videoFilePath);
  19. if(file.exists()) {
  20. file.remove();
  21. }
  22. if(file.open(QIODevice::ReadWrite | QIODevice::Text)) {
  23. QTextStream out(&file);
  24. qDebug() << "Writing url to QTextStream!";
  25. out << url;
  26. }
  27. file.close();
  28. qDebug() << "File closed! Opening url:" << QUrl("file:///" + videoFilePath).toString();
  29. QDesktopServices::openUrl(QUrl("file:///" + videoFilePath));
  30. }