简体   繁体   中英

libvlc_video_set_subtitle_file not working

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM