本文整理汇总了C#中MediaItem类的典型用法代码示例。如果您正苦于以下问题:C# MediaItem类的具体用法?C# MediaItem怎么用?C# MediaItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaItem类属于命名空间,在下文中一共展示了MediaItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RenderParallaxMediaAttributes
public static HtmlString RenderParallaxMediaAttributes(this Item item)
{
var targetItem = item.TargetItem(Templates.HasParallaxBackground.Fields.BackgroundMedia);
var targetMedia = new MediaItem(targetItem);
var attributeDictionary = new Dictionary<string, string>();
var mimeType = targetMedia.MimeType.Split('/');
var mediaType = mimeType[0];
var mediaFormat = mimeType[1];
attributeDictionary["type"] = mediaType;
if (mediaType == "video")
attributeDictionary["format"] = mediaFormat;
attributeDictionary[mediaType == "video" ? $"url-{mediaFormat}" : "url"] = item.MediaUrl(Templates.HasParallaxBackground.Fields.BackgroundMedia);
var checkboxField = (Sitecore.Data.Fields.CheckboxField)item.Fields[Templates.HasParallaxBackground.Fields.IsParallaxEnabled];
attributeDictionary["attachment"] = checkboxField.Checked ? "parallax" : "static";
if (checkboxField.Checked)
{
attributeDictionary["parallaxspeed"] = item.Fields[Templates.HasParallaxBackground.Fields.ParallaxSpeed].Value;
}
var attributes = attributeDictionary.Select(x => $"data-multibackground-layer-0-{x.Key}='{x.Value}'").ToList();
attributes.Add("data-multibackground");
return new HtmlString(string.Join(" ", attributes));
}
开发者ID:robearlam,项目名称:Habitat,代码行数:26,代码来源:Extensions.cs
示例2: Process
public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
{
changeType = ContentDirectoryMessaging.MediaItemChangeType.None;
var rl = mediaItem.GetResourceLocator();
using (var ra = rl.CreateAccessor())
{
var rad = ra as IResourceDeletor;
if (rad == null)
return false;
// First try to delete the file from storage.
if (rad.Delete())
{
changeType = ContentDirectoryMessaging.MediaItemChangeType.Deleted;
// If the MediaItem was loaded from ML, remove it there as well.
if (IsManagedByMediaLibrary(mediaItem))
{
IContentDirectory cd = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
if (cd == null)
return true;
cd.DeleteMediaItemOrPath(rl.NativeSystemId, rl.NativeResourcePath, true);
return true;
}
}
}
return false;
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:30,代码来源:DeleteFromStorage.cs
示例3: ConfigureProfile
private static string ConfigureProfile(DlnaForthField dlnaField, MediaItem item, string mediaType)
{
//TODO: much better type resolution
switch(mediaType)
{
case MediaLibraryHelper.MIMETYPE_AUDIO:
dlnaField.ProfileParameter.ProfileName = DlnaProfiles.Mp3;
dlnaField.FlagsParameter.StreamingMode = true;
dlnaField.FlagsParameter.InteractiveMode = false;
dlnaField.FlagsParameter.BackgroundMode = true;
break;
case MediaLibraryHelper.MIMETYPE_VIDEO:
dlnaField.ProfileParameter.ProfileName = DlnaProfiles.MpegPsPal;
dlnaField.FlagsParameter.StreamingMode = true;
dlnaField.FlagsParameter.InteractiveMode = false;
dlnaField.FlagsParameter.BackgroundMode = true;
break;
case MediaLibraryHelper.MIMETYPE_IMAGE:
dlnaField.ProfileParameter.ProfileName = DlnaProfiles.JpegLarge;
dlnaField.FlagsParameter.StreamingMode = false;
dlnaField.FlagsParameter.InteractiveMode = true;
dlnaField.FlagsParameter.BackgroundMode = true;
break;
}
return null;
}
开发者ID:FreakyJ,项目名称:MediaServer-fo-MP2,代码行数:26,代码来源:DlnaProtocolInfoFactory.cs
示例4: getKey
protected override String getKey(MediaItem item)
{
String key = "";
if (item.Metadata != null)
{
if (item.Metadata.IsImported)
{
key += '0';
}
if (!item.Metadata.SupportsXMPMetadata)
{
key += '1';
}
}
if (item.HasTags)
{
key += '2';
}
if (item.HasGeoTag)
{
key += '3';
}
if (item.IsReadOnly)
{
key += '4';
}
return (key);
}
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:34,代码来源:MediaFileInfoIconsCache.cs
示例5: GetMediaUrl
/// <summary>
/// Gets a media URL.
/// </summary>
/// <param name="item">The media item.</param>
/// <param name="options">The query string.</param>
/// <returns>
/// The media URL.
/// </returns>
public override string GetMediaUrl(MediaItem item, MediaUrlOptions options)
{
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNull(options, "options");
var flag = options.Thumbnail || HasMediaContent(item);
if (!flag && item.InnerItem["path"].Length > 0)
{
if (!options.LowercaseUrls)
return item.InnerItem["path"];
return item.InnerItem["path"].ToLowerInvariant();
}
if (options.UseDefaultIcon && !flag)
{
return !options.LowercaseUrls ? Themes.MapTheme(Settings.DefaultIcon) : Themes.MapTheme(Settings.DefaultIcon).ToLowerInvariant();
}
Assert.IsTrue(Config.MediaPrefixes[0].Length > 0, "media prefixes are not configured properly.");
var str1 = MediaLinkPrefix;
if (options.AbsolutePath)
str1 = options.VirtualFolder + str1;
else if (str1.StartsWith("/", StringComparison.InvariantCulture))
str1 = StringUtil.Mid(str1, 1);
var part2 = MainUtil.EncodePath(str1, '/');
if (options.AlwaysIncludeServerUrl)
part2 = FileUtil.MakePath(string.IsNullOrEmpty(options.MediaLinkServerUrl) ? WebUtil.GetServerUrl() : options.MediaLinkServerUrl, part2, '/');
var str2 = StringUtil.EnsurePrefix('.', StringUtil.GetString(options.RequestExtension, item.Extension, "ashx"));
var str3 = options.ToString();
if (str3.Length > 0)
str2 = str2 + "?" + str3;
const string str4 = "/sitecore/media library/";
var path = item.InnerItem.Paths.Path;
var str5 = MainUtil.EncodePath(!options.UseItemPath || !path.StartsWith(str4, StringComparison.OrdinalIgnoreCase) ? item.ID.ToShortID().ToString() : StringUtil.Mid(path, str4.Length), '/');
var str6 = part2 + str5 + (options.IncludeExtension ? str2 : string.Empty);
return !options.LowercaseUrls ? str6 : str6.ToLowerInvariant();
}
开发者ID:rangler2,项目名称:JCore.SitecoreModules.ImageCropping,代码行数:42,代码来源:CustomMediaProvider.cs
示例6: GetPlayer
public IPlayer GetPlayer(MediaItem mediaItem)
{
string mimeType;
string title;
if (!mediaItem.GetPlayData(out mimeType, out title))
return null;
IResourceLocator locator = mediaItem.GetResourceLocator();
if (!ImagePlayer.CanPlay(locator, mimeType))
return null;
ImagePlayer player = new ImagePlayer();
try
{
if (!player.NextItem(mediaItem, StartTime.AtOnce))
{
player.Dispose();
return null;
}
}
catch (Exception e)
{
ServiceRegistration.Get<ILogger>().Warn("ImagePlayerBuilder: Error playing media item '{0}'", e, locator);
player.Dispose();
return null;
}
return player;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:26,代码来源:ImagePlayerBuilder.cs
示例7: Compare
public override int Compare(MediaItem item1, MediaItem item2)
{
MediaItemAspect seriesAspectX;
MediaItemAspect seriesAspectY;
if (item1.Aspects.TryGetValue(SeriesAspect.ASPECT_ID, out seriesAspectX) && item2.Aspects.TryGetValue(SeriesAspect.ASPECT_ID, out seriesAspectY))
{
int seasonX = (int) (seriesAspectX.GetAttributeValue(SeriesAspect.ATTR_SEASON) ?? 0);
int seasonY = (int) (seriesAspectY.GetAttributeValue(SeriesAspect.ATTR_SEASON) ?? 0);
int seasonRes = seasonX.CompareTo(seasonY);
if (seasonRes != 0)
return seasonRes;
IEnumerable<int> episodesX = seriesAspectX.GetCollectionAttribute<int>(SeriesAspect.ATTR_EPISODE);
IEnumerable<int> episodesY = seriesAspectY.GetCollectionAttribute<int>(SeriesAspect.ATTR_EPISODE);
int episodeX = 0;
int episodeY = 0;
if (episodesX != null)
episodeX = episodesX.FirstOrDefault();
if (episodesY != null)
episodeY = episodesY.FirstOrDefault();
int episodeRes = episodeX.CompareTo(episodeY);
if (episodeRes != 0)
return episodeRes;
}
return base.Compare(item1, item2);
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:28,代码来源:SeriesSortByEpisode.cs
示例8: GetPosts
public List<WpPost> GetPosts(WpImportOptions options)
{
Item mediaInnerItem = _db.GetItem(_mediaItemId);
if (mediaInnerItem == null)
{
Logger.Error(String.Format("Media item for import could not be found (id: {0}, db: {1})", _mediaItemId, _db.Name));
return new List<WpPost>(0);
}
MediaItem mediaItem = new MediaItem(mediaInnerItem);
XmlDocument xmdDoc = new XmlDocument();
var mediaStream = MediaManager.GetMedia(mediaItem).GetStream();
if (mediaStream == null || mediaStream.MimeType != "text/xml")
{
Logger.Error(String.Format("MediaStream for imported item is null or uploaded file has is incorrect format (id: {0}, db: {1})", _mediaItemId, _db.Name));
return new List<WpPost>(0);
}
xmdDoc.Load(mediaStream.Stream);
using (var nodeReader = new XmlNodeReader(xmdDoc))
{
nodeReader.MoveToContent();
var xDocument = XDocument.Load(nodeReader);
var posts = (from item in xDocument.Descendants("item")
select new WpPost(item, options)).ToList();
return posts;
}
}
开发者ID:WeTeam,项目名称:WeBlog,代码行数:29,代码来源:MediaItemBasedProvider.cs
示例9: ConvertWave2Wma
public static bool ConvertWave2Wma(string waveFilePath, string artist, string title, string genre, int year, out string exceptionMessage)
{
//encode
MediaItem albumItem;
try
{
string jobFilePath = waveFilePath.Replace(".wav", "-job.xej");
StreamReader reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("AudioConverter.ExpressionEncoderJob.xej"));
File.WriteAllText(jobFilePath, reader.ReadToEnd());
reader.Close();
Job job = Job.LoadJob(jobFilePath);
string presetFilePath = waveFilePath.Replace(".wav", "-presets.xml");
WritePresetFile(presetFilePath, artist, title, genre, year);
job.MediaItems.Clear();
albumItem = new MediaItem(waveFilePath);
job.MediaItems.Add(albumItem);
job.ApplyPreset(Preset.FromFile(presetFilePath));
job.Encode();
exceptionMessage = null;
return true;
}
catch (Exception ex)
{
exceptionMessage = ex.Message;
return false;
}
}
开发者ID:jmeijrink,项目名称:Personal-projects,代码行数:30,代码来源:Wave2Wma.cs
示例10: EncodeVideo
public static void EncodeVideo(FileInfo inputFile, FileInfo outputFile)
{
DirectoryInfo outDir = outputFile.Directory;
if (!outDir.Exists)
{
outDir.Create();
}
MediaItem mediaItem = new MediaItem(inputFile.FullName);
int bitrate = GetBitrate(mediaItem);
using (Job job = new Job())
{
job.OutputDirectory = outDir.FullName;
job.CreateSubfolder = false;
job.MediaItems.Add(mediaItem);
SetProfile(mediaItem);
// We can also use some of the presets. In that case comment the SetProfile line above for something like the one below:
// //H264VimeoSD preset settings: Output Format: MP4. Container: MP4. Video Codec: H.264 - Main.
// //Video size: 640, 480. Video Bitrate: 2500 Kbps. Video Encoding: CBR SinglePass.
// //Audio Codec: AAC. Audio Channels: Stereo. Audio Bitrate: 128 Kbps. Audio Encoding: CBR Single Pass
// job.ApplyPreset(Presets.H264VimeoSD);
job.Encode();
}
if (!outputFile.FullName.Equals(mediaItem.ActualOutputFileFullPath, StringComparison.InvariantCultureIgnoreCase))
{
throw new Exception(String.Format("The output file specified: '{0}' does not match the actual output file '{1}'", outputFile.FullName, mediaItem.ActualOutputFileFullPath));
}
}
开发者ID:TellagoDevLabs,项目名称:CloudPoint,代码行数:32,代码来源:VideoProcessor.cs
示例11: GetMediaUrl
/// <summary>
/// Gets the media URL.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="mediaUrlOptions">The media URL options.</param>
/// <returns></returns>
public override string GetMediaUrl(MediaItem item, MediaUrlOptions mediaUrlOptions)
{
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNull(mediaUrlOptions, "mediaUrlOptions");
//Return the standard image if any of the following conditions are met
if (!IsImage(item) || Context.Database == null || Context.Site.Name == "shell" || !Context.PageMode.IsNormal || !((Item)item).HasChildren)
return base.GetMediaUrl(item, mediaUrlOptions);
double pixelDensity = GetCookiePixelDensity();
if (pixelDensity <= 1)
return base.GetMediaUrl(item, mediaUrlOptions);
//Get the first child of the media item (It should be the retina version of the image)
Item retinaItem = ((Item)item).Children.FirstOrDefault();
//Return the standard image if width and height are not set on the retina media items
if (retinaItem == null || String.IsNullOrEmpty(retinaItem["Width"]) || String.IsNullOrEmpty(retinaItem["Height"]))
return base.GetMediaUrl(item, mediaUrlOptions);
int retinaWidth = System.Convert.ToInt32(retinaItem["Width"]);
int retinaHeight = System.Convert.ToInt32(retinaItem["Height"]);
if (mediaUrlOptions.Width > 0 && mediaUrlOptions.Height > 0
&& retinaWidth >= (mediaUrlOptions.Width * pixelDensity) && retinaHeight >= (mediaUrlOptions.Height * pixelDensity))
{
mediaUrlOptions.Width = System.Convert.ToInt32(mediaUrlOptions.Width * pixelDensity);
mediaUrlOptions.Height = System.Convert.ToInt32(mediaUrlOptions.Height * pixelDensity);
//Return the retina version with width and height parameters adjusted accordingly
return base.GetMediaUrl(retinaItem, mediaUrlOptions);
}
//Return the retina version
return base.GetMediaUrl(retinaItem, mediaUrlOptions);
}
开发者ID:ostat,项目名称:SitecoreRetinaImages,代码行数:37,代码来源:RetinaImageLinkProvider.cs
示例12: Prepare
/// <summary>
/// We require the command line parameters for the web browser host
/// Util should be an implementation of IBrowserSiteUtil
/// </summary>
/// <param name="mediaItem"></param>
public void Prepare(MediaItem mediaItem)
{
bool useIE = false;
string siteName;
SiteUtilBase util;
if (!MediaItemAspect.TryGetAttribute(mediaItem.Aspects, OnlineVideosAspect.ATTR_SITEUTIL, out siteName) || !OnlineVideoSettings.Instance.SiteUtilsList.TryGetValue(siteName, out util))
{
throw new ArgumentException("Could not determine used site util, can't start playback!");
}
var browserConfig = util as IBrowserSiteUtil;
if (browserConfig != null)
{
_automationType = browserConfig.ConnectorEntityTypeName;
_username = browserConfig.UserName;
_password = browserConfig.Password;
}
var emulationSite = util as IBrowserVersionEmulation;
if (emulationSite != null)
{
_emulationLevel = emulationSite.EmulatedVersion;
useIE = _emulationLevel > 10000;
}
_lastError = string.Empty;
_callback.OnBrowserClosing += _callback_OnBrowserHostClosing;
_callback.OnBrowserKeyPress += _callback_OnBrowserKeyPress;
var processName = useIE ? HOST_PROCESS_NAME_IE : HOST_PROCESS_NAME;
_processPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), processName + ".exe");
GetRunningProcess(processName);
}
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:40,代码来源:WebBrowserVideoPlayer.cs
示例13: GetFromXml
private static File GetFromXml(XmlNode node)
{
var mediaId = GetAttribute(node, "mediaid");
var src = GetAttribute(node, "src");
var file = new File
{
MediaId = mediaId,
Source = src
};
if (string.IsNullOrEmpty(file.MediaId))
{
return file;
}
var mediaItemFromMediaId = DatabaseRepository.GetActiveDatabase().GetItem(file.MediaId);
if (mediaItemFromMediaId == null)
{
return file;
}
var mediaItem = new MediaItem(mediaItemFromMediaId);
file.Title = string.IsNullOrEmpty(mediaItem.Title)
? mediaItem.DisplayName
: mediaItem.Title;
file.Extension = mediaItem.Extension;
file.FileSize = mediaItem.Size;
return file;
}
开发者ID:Brad-Christie,项目名称:Habitat,代码行数:28,代码来源:FileRepository.cs
示例14: IsValidVideo
public static bool IsValidVideo(MediaItem mediaItem)
{
if (mediaItem == null)
return false;
string mimeType;
return MediaItemAspect.TryGetAttribute(mediaItem.Aspects, MediaAspect.ATTR_MIME_TYPE, out mimeType) && mimeType.StartsWith("video/");
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:7,代码来源:MediaItemHelper.cs
示例15: CreateThumbnailImageSource
/// <summary>
/// Constructs a <see cref="BinaryTextureImageSource"/> for thumbnails of the given size from MediaItems.
/// </summary>
/// <param name="mediaItem">MediaItem to create thumbnail for.</param>
/// <param name="thumbnailSize">Requested thumbnail size.</param>
public static BinaryTextureImageSource CreateThumbnailImageSource(MediaItem mediaItem, int thumbnailSize)
{
Guid id = mediaItem.MediaItemId;
// Local media items don't have an item id
string key = (id == Guid.Empty ? Guid.NewGuid() : id).ToString();
byte[] textureData = null;
// Each resolution is cached separately. If we read cache only and our favourite resolution is not yet in cache,
// we try to find any other existing.
if (thumbnailSize <= 96)
{
if (mediaItem.Aspects.ContainsKey(ThumbnailSmallAspect.ASPECT_ID))
textureData = (byte[]) mediaItem.Aspects[ThumbnailSmallAspect.ASPECT_ID].GetAttributeValue(ThumbnailSmallAspect.ATTR_THUMBNAIL);
if (textureData == null && mediaItem.Aspects.ContainsKey(ThumbnailLargeAspect.ASPECT_ID))
textureData = (byte[]) mediaItem.Aspects[ThumbnailLargeAspect.ASPECT_ID].GetAttributeValue(ThumbnailLargeAspect.ATTR_THUMBNAIL);
}
else
{
if (mediaItem.Aspects.ContainsKey(ThumbnailLargeAspect.ASPECT_ID))
textureData = (byte[]) mediaItem.Aspects[ThumbnailLargeAspect.ASPECT_ID].GetAttributeValue(ThumbnailLargeAspect.ATTR_THUMBNAIL);
if (textureData == null && mediaItem.Aspects.ContainsKey(ThumbnailSmallAspect.ASPECT_ID))
textureData = (byte[]) mediaItem.Aspects[ThumbnailSmallAspect.ASPECT_ID].GetAttributeValue(ThumbnailSmallAspect.ATTR_THUMBNAIL);
}
ImageRotation miRotation;
bool flipX;
bool flipY;
ImageAspect.GetOrientationMetadata(mediaItem, out miRotation, out flipX, out flipY);
RightAngledRotation rotation = RotationTranslator.TranslateToRightAngledRotation(miRotation);
return new BinaryTextureImageSource(textureData, rotation, key);
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:37,代码来源:MediaItemsHelper.cs
示例16: AutoRotateThumb
private static byte[] AutoRotateThumb(MediaItem mediaItem, byte[] textureData)
{
ImageRotation miRotation;
bool flipX;
bool flipY;
if (ImageAspect.GetOrientationMetadata(mediaItem, out miRotation, out flipX, out flipY) && (miRotation != ImageRotation.Rot_0))
{
try
{
using (MemoryStream rotatedStream = new MemoryStream())
using (MemoryStream inputStream = new MemoryStream(textureData))
using (Image bitmap = Image.FromStream(inputStream))
{
if (miRotation == ImageRotation.Rot_180)
bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
if (miRotation == ImageRotation.Rot_90)
bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
if (miRotation == ImageRotation.Rot_270)
bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
bitmap.Save(rotatedStream, ImageFormat.Jpeg);
textureData = rotatedStream.ToArray();
}
}
catch (Exception)
{
}
}
return textureData;
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:29,代码来源:MediaItemThumbs.cs
示例17: UploadMediaItemToAlbum
private MediaItem UploadMediaItemToAlbum(MediaItem mediaItem, string albumPath)
{
string relativeUploadUrl = GenerateRelativeUploadUrl( albumPath );
QueryParameterList paramaters = new QueryParameterList();
paramaters.Add( new QueryParameter( _format, "xml" ) );
paramaters.Add( new QueryParameter( _type, mediaItem.Type ) );
if (string.IsNullOrEmpty( mediaItem.Description ) == false)
{
paramaters.Add( new QueryParameter( _description, OAuth.UrlEncode(mediaItem.Description) ) );
}
if (string.IsNullOrEmpty( mediaItem.Title ) == false)
{
paramaters.Add( new QueryParameter( _title, OAuth.UrlEncode(mediaItem.Title) ) );
}
QueryParameterList mediaParamaters = OAuth.GenerateOAuthParamaters( relativeUploadUrl, _uploadMediaMethod, Token, paramaters );
string uploadMediaItemUrl = ApiUrl + relativeUploadUrl + "?format=xml";
XmlResponseMessage uploadMediaItemResponse = GetResponseForUploadMediaItem( uploadMediaItemUrl, mediaItem, mediaParamaters );
MediaItem newMediaItem = new MediaItem( uploadMediaItemResponse.ResponseXml );
_currentUser.MediaList.Add(newMediaItem);
return newMediaItem;
}
开发者ID:darocha,项目名称:Photobucket.NET,代码行数:26,代码来源:PhotobucketUploadMediaMethod.cs
示例18: getKey
protected override String getKey(MediaItem item)
{
String key = "";
if (item is YoutubeVideoItem)
{
YoutubeVideoItem videoItem = item as YoutubeVideoItem;
YoutubeItemMetadata metadata = item.Metadata as YoutubeItemMetadata;
if (metadata.Height >= 2160)
{
key += "4";
}
else if (metadata.Height >= 1080)
{
key += "0";
}
if (videoItem.IsEmbeddedOnly || !videoItem.HasPlayableStreams)
{
key += "1";
}
}
else if (item is YoutubeChannelItem)
{
key += "2";
}
else if (item is YoutubePlaylistItem)
{
key += "3";
}
return key;
}
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:35,代码来源:YoutubeItemInfoIconsCache.cs
示例19: GenerateThumbnail
public static void GenerateThumbnail(FileInfo mediaFile, string thumbnailFilePath, int width, int height)
{
int thumbWidth = width;
int thumbHeight = height;
var video = new MediaItem(mediaFile.FullName);
var videoSize = video.MainMediaFile.VideoStreams[0].VideoSize;
if (videoSize.Width > videoSize.Height)
{
thumbHeight = Decimal.ToInt32(((Decimal)videoSize.Height / videoSize.Width) * thumbWidth);
if (thumbHeight > height)
{
thumbHeight = height;
}
}
else
{
thumbWidth = Decimal.ToInt32(((Decimal)videoSize.Width / videoSize.Height) * thumbHeight);
if (thumbWidth > width)
{
thumbWidth = width;
}
}
using (var bitmap = video.MainMediaFile.GetThumbnail(
new TimeSpan(0, 0, 5),
new System.Drawing.Size(thumbWidth, thumbHeight)))
{
bitmap.Save(thumbnailFilePath,ImageFormat.Jpeg);
}
}
开发者ID:TellagoDevLabs,项目名称:CloudPoint,代码行数:31,代码来源:VideoProcessor.cs
示例20: GetMediaUrl
public override string GetMediaUrl(MediaItem item, MediaUrlOptions options)
{
string mediaUrl = base.GetMediaUrl(item, options);
if (string.IsNullOrEmpty(mediaUrl)) return mediaUrl;
int versionNumber = item.InnerItem.Version.Number;
string langIsoCode = item.InnerItem.Language.CultureInfo.TwoLetterISOLanguageName;
string updatedDate = item.InnerItem.Statistics.Updated.ToString("s");
NameValueCollection parameters = new NameValueCollection
{
{"v", versionNumber.ToString()},
{"lang", langIsoCode},
{"modified", updatedDate}
};
if (options.AlwaysIncludeServerUrl)
{
UriBuilder uriBuilder = new UriBuilder(mediaUrl);
NameValueCollection queryString = HttpUtility.ParseQueryString(uriBuilder.Query);
queryString.Add(parameters);
uriBuilder.Query = ToQueryString(queryString);
return uriBuilder.ToString();
}
StringBuilder sb = new StringBuilder(mediaUrl);
string seperator = "?";
if (mediaUrl.Contains(seperator)) seperator = "&";
foreach (string key in parameters.Keys)
{
sb.AppendFormat("{0}{1}={2}", seperator, key, parameters[key]);
seperator = "&";
}
return sb.ToString();
}
开发者ID:cloud-explorer,项目名称:SitecoreAzureCDNManager,代码行数:32,代码来源:CDNUrlMediaProvider.cs
注:本文中的MediaItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论