当前位置: 首页>>代码示例>>C++>>正文


C++ MediaSource::getUrl方法代码示例

本文整理汇总了C++中MediaSource::getUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource::getUrl方法的具体用法?C++ MediaSource::getUrl怎么用?C++ MediaSource::getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaSource的用法示例。


在下文中一共展示了MediaSource::getUrl方法的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();
	}
}
开发者ID:hiroshiyui,项目名称:kaffeine,代码行数:76,代码来源:vlcmediawidget.cpp

示例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);
}
开发者ID:Brandhand,项目名称:kaffeine-vlc,代码行数:65,代码来源:mplayermediawidget.cpp


注:本文中的MediaSource::getUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。