libvlc_video_set_subtitle_file 不工作

libvlc_video_set_subtitle_file 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));

设置具体文件前后字幕索引和计数相同,函数returns1(int a).

但是,使用 libvlc_video_set_spu 设置字幕是可行的。

我正在使用 VLC 2.2.1

如果您在 Windows,QDir::toNativeSeparators 将有帮助:

const QString selectedFile = QFileDialog::getOpenFileName(this, "Open");
const QString nativePath = QDir::toNativeSeparators(selectedFile);
libvlc_video_set_subtitle_file(player, nativePath.toUtf8().constData());