I'm using the following code to set the subtitle file, but for some reason it's not working.
QString selectedFile = QFileDialog::getOpenFileName(this, "Open");
if(selectedFile == NULL) {
return;
}
qDebug("Before %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player));
//int a = libvlc_video_set_subtitle_file(player, selectedFile.toStdString().c_str());
int a = libvlc_video_set_subtitle_file(player, selectedFile.toLatin1().data());
qDebug("A = %d",a);
qDebug("After %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player));
Subtitle index and count are the same before and after setting the specific file, and the function returns 1 (int a).
However, setting the subtitle with libvlc_video_set_spu
works.
I'm using VLC 2.2.1
If you are on Windows,QDir::toNativeSeparators
will help:
const QString selectedFile = QFileDialog::getOpenFileName(this, "Open");
const QString nativePath = QDir::toNativeSeparators(selectedFile);
libvlc_video_set_subtitle_file(player, nativePath.toUtf8().constData());