Code: Select all
void playerVLC::refreshSubtitleDescriptions() {
QString text = "";
// Refresh the SUBTITLES
libvlc_exception_clear(&_vlcexcep);
_subd_head = libvlc_video_get_spu_description( _mp, &_vlcexcep );
//_subd_current = _subd_head;
raise(&_vlcexcep);
_count_spu = libvlc_video_get_spu_count( _mp, &_vlcexcep);
raise(&_vlcexcep);
_current_spu = libvlc_video_get_spu( _mp, &_vlcexcep);
raise(&_vlcexcep);
//INIT
if ( !_subd_current )
_subd_current = _subd_head;
libvlc_track_description_t *temp;
temp = _subd_head;
while ( temp->p_next ) {
text.append( QString("%1 ").arg(temp->i_id) );
text.append(temp->psz_name);
text.append( " -- " );
temp = temp->p_next;
}
ui.tmp->setText( text );
}
void playerVLC::on_pushButton_2_clicked(){
QString text = "";
ui.tmp->setText( text );
if ( !_subd_head )
refreshSubtitleDescriptions();
libvlc_exception_clear(&_vlcexcep);
if ( !_subd_current->p_next )
_subd_current = _subd_head;
else
_subd_current = _subd_current->p_next;
libvlc_video_set_spu( _mp, (_subd_current->i_id == -1) ? 0 : _subd_current->i_id, &_vlcexcep );
raise(&_vlcexcep);
text.append(QString("[%1] ").arg(_subd_current->i_id) );
text.append(_subd_current->psz_name);
}
-1 Disable -- 4 Track 1 - [Italiano] -- 5 Track 2 - [Italiano] -- 6 Track 3 - [English] -- 10 Track 4 -- 11 Track 5 -- 12 Track 6 --
Take this for example: -1 Disable the number is the i_id member and "Disable " is the psz_name member of libvlc_track_description_t
So in total I have 8 subtitles. The problem is that I think libvlc_video_set_spu accepts only values between 0 and ( libvlc_video_get_spu_count - 1 )
When I try to set the subtitle with i_id = -1 or >=8 the applications crashes.
Can you show me the best way to set the subtitles using libvlc_track_description_t ( I need to show to the user the psz_name member ) ?