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


C++ PlaylistItem::SetDuration方法代码示例

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


在下文中一共展示了PlaylistItem::SetDuration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _

// ValidateItemLayout
void
SlideShowPlaylist::ValidateItemLayout()
{
	int64 duration = Value(PROPERTY_DURATION, (int64)0);
	if (duration == 0)
		return;

	int64 transitionDuration
		= Value(PROPERTY_TRANSITION_DURATION, (int64)0);
	// TODO: transition mode...

	int32 count = CountItems();

	BList managedItems;

	int64 minDuration = 0;
	int64 minItemDuration = transitionDuration * 3;
	int64 fixedItemsDuration = 0;
	int64 maxDuration = 0;
	int32 variableItemCount = 0;
	for (int32 i = 0; i < count; i++) {
		PlaylistItem* item = ItemAtFast(i);
		if (item->Track() > 1)
			// not a "managed" item
			continue;

		managedItems.AddItem(item);

		if (item->HasMaxDuration()) {
			int64 maxItemDuration = item->MaxDuration();
			minDuration += maxItemDuration;
			fixedItemsDuration += maxItemDuration;
			if (minItemDuration > maxItemDuration)
				minItemDuration = maxItemDuration;
		} else {
			minDuration += 3 * transitionDuration;
			variableItemCount++;
		}

		maxDuration += item->MaxDuration();
	}

	count = managedItems.CountItems();
	if (count == 0)
		return;

	if (duration < minDuration)
		duration = minDuration;
	if (duration > maxDuration)
		duration = maxDuration;

	// limit transition duration to 1/3 of the minimum item duration
	int64 maxTransitionDuration = minItemDuration / 3;

	if (transitionDuration > maxTransitionDuration)
		transitionDuration = maxTransitionDuration;

	int64 variableItemsDuration = duration - fixedItemsDuration
			+ transitionDuration * (count - variableItemCount);

	int64 startFrame = 0;
	int64 lastVariableStartFrame = 0;
	int32 variableItemIndex = 0;
	for (int32 i = 0; i < count; i++) {
		PlaylistItem* item = (PlaylistItem*)managedItems.ItemAtFast(i);
		// overlapping items
		item->SetClipOffset(0);
		item->SetTrack(i & 1);

		int64 nextStartFrame;
		if (item->HasMaxDuration()) {
			nextStartFrame = startFrame + item->MaxDuration()
								- transitionDuration;
		} else {
			variableItemIndex++;
			int64 nextVariableStartFrame = (variableItemsDuration - transitionDuration)
								* variableItemIndex / variableItemCount;
			nextStartFrame = startFrame + nextVariableStartFrame - lastVariableStartFrame;
			lastVariableStartFrame = nextVariableStartFrame;
		}
		item->SetStartFrame(startFrame);
		item->SetDuration(nextStartFrame - startFrame + transitionDuration);
		startFrame = nextStartFrame;

		// transition
		PropertyAnimator* animator = item->AlphaAnimator();
		if (!animator)
			continue;

		AutoNotificationSuspender _(animator);

		// remove all keyframes to get a clean start
		animator->MakeEmpty();
		KeyFrame* first = animator->InsertKeyFrameAt(0LL);
		KeyFrame* last = animator->InsertKeyFrameAt(item->Duration() - 1);

		if (!first || !last)
			continue;

//.........这里部分代码省略.........
开发者ID:stippi,项目名称:Clockwerk,代码行数:101,代码来源:SlideShowPlaylist.cpp


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