本文整理汇总了C++中MediaSource::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource::getType方法的具体用法?C++ MediaSource::getType怎么用?C++ MediaSource::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaSource
的用法示例。
在下文中一共展示了MediaSource::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play
void VlcMediaWidget::play(const MediaSource &source)
{
addPendingUpdates(PlaybackStatus | DvdMenu);
QByteArray url = source.getUrl().toEncoded();
playingDvd = false;
switch (source.getType()) {
case MediaSource::Url:
if (url.endsWith(".iso")) {
playingDvd = true;
}
break;
case MediaSource::AudioCd:
if (url.size() >= 7) {
url.replace(0, 4, "cdda");
} else {
url = "cdda://";
}
break;
case MediaSource::VideoCd:
if (url.size() >= 7) {
url.replace(0, 4, "vcd");
} else {
url = "vcd://";
}
break;
case MediaSource::Dvd:
if (url.size() >= 7) {
url.replace(0, 4, "dvd");
} else {
url = "dvd://";
}
playingDvd = true;
break;
case MediaSource::Dvb:
break;
}
libvlc_media_t *vlcMedia = libvlc_media_new_location(vlcInstance, url.constData());
if (vlcMedia == NULL) {
libvlc_media_player_stop(vlcMediaPlayer);
Log("VlcMediaWidget::play: cannot create media") << source.getUrl().url();
return;
}
libvlc_event_manager_t *eventManager = libvlc_media_event_manager(vlcMedia);
libvlc_event_e eventTypes[] = { libvlc_MediaMetaChanged };
for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) {
if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHandler, this) != 0) {
Log("VlcMediaWidget::play: cannot attach event handler") << eventTypes[i];
}
}
libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
// FIXME!
// if (source.subtitleUrl.isValid()) {
// if (libvlc_video_set_subtitle_file(vlcMediaPlayer,
// source.subtitleUrl.toEncoded().constData()) == 0) {
// Log("VlcMediaWidget::play: cannot set subtitle file") <<
// source.subtitleUrl.prettyUrl();
// }
// }
if (libvlc_media_player_play(vlcMediaPlayer) != 0) {
Log("VlcMediaWidget::play: cannot play media") << source.getUrl().url();
}
}
示例2: play
void MPlayerMediaWidget::play(const MediaSource &source)
{
resetState();
QByteArray url = source.getUrl().toEncoded();
switch (source.getType()) {
case MediaSource::Url:
if (url.endsWith(".iso")) {
// FIXME use dvd://, dvdnav:// ?
updateDvdMenu(true);
}
if (source.getUrl().isLocalFile()) {
// mplayer can't deal with urls like "file:///tmp/te%20st.m2t"
url = QFile::encodeName(source.getUrl().toLocalFile());
url.replace(' ', "\\ ");
}
break;
case MediaSource::AudioCd:
if (url.size() >= 7) {
// e.g. cdda:////dev/sr0
url.replace(0, 5, "cdda:/");
} else {
url = "cdda://";
}
break;
case MediaSource::VideoCd:
if (url.size() >= 7) {
// e.g. vcd:////dev/sr0
url.replace(0, 5, "vcd:/");
} else {
url = "vcd://";
}
break;
case MediaSource::Dvd:
if (url.size() >= 7) {
// e.g. dvdnav:////dev/sr0
url.replace(0, 5, "dvdnav:/");
} else {
url = "dvdnav://";
}
updateDvdMenu(true);
break;
case MediaSource::Dvb:
if (source.getUrl().isLocalFile()) {
// mplayer can't deal with urls like "file:///tmp/te%20st.m2t"
url = QFile::encodeName(source.getUrl().toLocalFile());
url.replace(' ', "\\ ");
}
break;
}
updatePlaybackStatus(MediaWidget::Playing);
updateSeekable(true);
process.write("loadfile " + url + '\n');
process.write("pausing_keep_force get_property path\n");
sendCommand(SetDeinterlacing);
sendCommand(SetVolume);
timerId = startTimer(500);
}