allow elisa to open external files, scan them and enqueue them
ClosedPublic

Authored by mgallien on Dec 20 2017, 10:29 PM.

Details

Summary

add tests for enqueuing files and fix one issue

Test Plan

one can open a file by using "open with" or in a terminal by doing elisa musicFiles.ogg

Diff Detail

Repository
R255 Elisa
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mgallien requested review of this revision.Dec 20 2017, 10:29 PM
mgallien created this revision.
mgallien updated this revision to Diff 24194.Dec 20 2017, 10:47 PM
  • add missing files

I found two issues during testing:

when opening on command line with e.g. "elisa xxx.ogg", it can correctly read the metadata, but the entry becomes invalid when trying to start playback. with the absolute path e.g. "elisa /home/user/xxx.ogg" it works. Some handling of relative path is required.

playback is not started when the file is added, and elisa should probably jump to the added file in the playlist. but maybe that is something for later

mgallien updated this revision to Diff 24519.Dec 31 2017, 2:59 PM
  • add debug info to better understand cases where it may fail
  • if the file exists, play list entry is valid immediately
  • when adding tracks from command line arguments, immediately play them

try to fix comments and problems seen by astippich

mgallien updated this revision to Diff 24560.Jan 1 2018, 11:28 PM
  • add missing files
  • add debug info to better understand cases where it may fail
  • if the file exists, play list entry is valid immediately
  • when adding tracks from command line arguments, immediately play them
  • finish modification for display of play list entry from a random file

Still unchanged behavior, but I think I've found the problem. The setArguments method for elisaapplication needs the same treatment for relative paths as activateRequested. I assume that the first is used for command line arguments while the latter is used for DBus signals, am I correct? I hacked up a working solution for me, which you find inline.

src/MediaServer.qml
186

I changed that to

var previousTrackNumber = playListModelItem.tracksCount
enqueue(elisa.arguments)
switchTo(previousTrackNumber)
manageAudioPlayer.ensurePlay()

to ensure playback of the added title similar to the enqueue signal.

src/elisaapplication.cpp
139

Based on the activateRequested signal I quickly hacked:

void ElisaApplication::setArguments(const QStringList &newArguments)
{

QStringList filesToOpen;
QString workingDirectory = QDir::currentPath();
qDebug() << "ElisaApplication::activateRequested" << newArguments << workingDirectory;
for (const auto &oneFile : newArguments) {

    auto newFile = QFileInfo(oneFile);

    if (newFile.isRelative()) {
        newFile = QFileInfo(workingDirectory + QStringLiteral("/") + oneFile);
    }

    if (newFile.exists()) {
        filesToOpen.push_back(newFile.canonicalFilePath());
    }
}

if (d->mArguments == filesToOpen) {
    return;
}

qDebug() << "ElisaApplication::activateRequested" << filesToOpen;

d->mArguments = filesToOpen;

Q_EMIT argumentsChanged();

}

astippich requested changes to this revision.Jan 5 2018, 5:53 PM
This revision now requires changes to proceed.Jan 5 2018, 5:53 PM

Still unchanged behavior, but I think I've found the problem. The setArguments method for elisaapplication needs the same treatment for relative paths as activateRequested. I assume that the first is used for command line arguments while the latter is used for DBus signals, am I correct? I hacked up a working solution for me, which you find inline.

Thanks for the analysis. I had not understood the case that was failing.
I will update the review including automatic tests for ElisaApplication class.

mgallien planned changes to this revision.Jan 7 2018, 8:02 PM
mgallien updated this revision to Diff 24901.Jan 7 2018, 9:01 PM
  • always transform the music file names to aboslute ones in ElisaApplication
  • when launching elisa with arguments, enqueue and play them immediately

Thanks a lot for your inputs and analysis work.

astippich accepted this revision.Jan 8 2018, 7:05 PM
This revision is now accepted and ready to land.Jan 8 2018, 7:05 PM
This revision was automatically updated to reflect the committed changes.