/// <summary> /// Sets the media item for the new image to be played. /// </summary> /// <param name="mediaItem">MediaItem to-be-played item.</param> public bool SetMediaItem(MediaItem mediaItem) { string mimeType; string title; if (!mediaItem.GetPlayData(out mimeType, out title)) { return(false); } IResourceLocator locator = mediaItem.GetResourceLocator(); if (locator == null) { return(false); } if (!CanPlay(locator, mimeType)) { return(false); } RightAngledRotation rotation = RightAngledRotation.Zero; bool flipX = false; bool flipY = false; SetMediaItemData(locator, title, rotation, flipX, flipY); return(true); }
public bool NextItem(MediaItem mediaItem, StartTime startTime) { string mimeType; string title; if (!mediaItem.GetPlayData(out mimeType, out title)) { return(false); } IResourceLocator locator = mediaItem.GetResourceLocator(); if (locator == null) { return(false); } if (!CanPlay(locator, mimeType)) { return(false); } RightAngledRotation rotation = RightAngledRotation.Zero; bool flipX = false; bool flipY = false; MediaItemAspect imageAspect = mediaItem[ImageAspect.ASPECT_ID]; if (imageAspect != null) { int orientationInfo = (int)imageAspect[ImageAspect.ATTR_ORIENTATION]; ImageRotation imageRotation; ImageAspect.OrientationToRotation(orientationInfo, out imageRotation); rotation = PlayerRotationTranslator.TranslateToRightAngledRotation(imageRotation); ImageAspect.OrientationToFlip(orientationInfo, out flipX, out flipY); } SetMediaItemData(locator, title, rotation, flipX, flipY); return(true); }
/// <summary> /// Sets the data of the new image to be played. /// </summary> /// <param name="locator">Resource locator of the image item.</param> /// <param name="mediaItemTitle">Title of the image item.</param> /// <param name="rotation">Rotation of the image.</param> /// <param name="flipX">Flipping in horizontal direction.</param> /// <param name="flipY">Flipping in vertical direction.</param> public void SetMediaItemData(IResourceLocator locator, string mediaItemTitle, RightAngledRotation rotation, bool flipX, bool flipY) { if (locator == null) { lock (_syncObj) { DisposeTexture(); _currentLocator = null; return; } } Texture texture; ImageInformation imageInformation; using (IResourceAccessor ra = locator.CreateAccessor()) { IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor; if (fsra == null) { return; } using (Stream stream = fsra.OpenRead()) using (Stream tmpImageStream = ImageUtilities.ResizeImage(stream, ImageFormat.MemoryBmp, MAX_TEXTURE_DIMENSION, MAX_TEXTURE_DIMENSION)) texture = Texture.FromStream(SkinContext.Device, tmpImageStream, (int)tmpImageStream.Length, 0, 0, 1, Usage.None, Format.A8R8G8B8, Pool.Default, Filter.None, Filter.None, 0, out imageInformation); } lock (_syncObj) { ReloadSettings(); _state = PlayerState.Active; DisposeTexture(); _currentLocator = locator; _mediaItemTitle = mediaItemTitle; _texture = texture; _rotation = rotation; _flipX = flipX; _flipY = flipY; SurfaceDescription desc = _texture.GetLevelDescription(0); _textureMaxUV = new SizeF(imageInformation.Width / (float)desc.Width, imageInformation.Height / (float)desc.Height); // Reset animation _animator.Initialize(); if (_slideShowTimer != null) { _slideShowTimer.Change(_slideShowImageDuration, TS_INFINITE); } else { CheckTimer(); } _playbackStartTime = DateTime.Now; if (_pauseTime.HasValue) { _pauseTime = _playbackStartTime; } } }
public bool NextItem(MediaItem mediaItem, StartTime startTime) { string mimeType; string title; if (!mediaItem.GetPlayData(out mimeType, out title)) { return(false); } IResourceLocator locator = mediaItem.GetResourceLocator(); if (locator == null) { return(false); } if (!CanPlay(locator, mimeType)) { return(false); } RightAngledRotation rotation = RightAngledRotation.Zero; bool flipX = false; bool flipY = false; SetMediaItemData(locator, title, rotation, flipX, flipY); IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>(); IContentDirectory cd = scm.ContentDirectory; if (cd != null) { IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>(); if (userProfileDataManagement.IsValidUser) { cd.NotifyUserPlaybackAsync(userProfileDataManagement.CurrentUser.ProfileId, mediaItem.MediaItemId, 100, true); } else { cd.NotifyPlaybackAsync(mediaItem.MediaItemId, true); } } return(true); }
/// <summary> /// Sets the data of the new image to be played. /// </summary> /// <param name="locator">Resource locator of the image item.</param> /// <param name="mediaItemTitle">Title of the image item.</param> /// <param name="rotation">Rotation of the image.</param> /// <param name="flipX">Flipping in horizontal direction.</param> /// <param name="flipY">Flipping in vertical direction.</param> public void SetMediaItemData(IResourceLocator locator, string mediaItemTitle, RightAngledRotation rotation, bool flipX, bool flipY) { if (locator == null) { lock (_syncObj) { _currentLocator = null; return; } } using (IResourceAccessor ra = locator.CreateAccessor()) { IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor; if (fsra == null) { return; } using (Stream stream = fsra.OpenRead()) { string key = fsra.CanonicalLocalResourcePath.Serialize(); _texture = ContentManager.Instance.GetTexture(stream, key, true); if (_texture == null) { return; } if (!_texture.IsAllocated) { _texture.Allocate(); } if (!_texture.IsAllocated) { return; } } } lock (_syncObj) { ReloadSettings(); _state = PlayerState.Active; _currentLocator = locator; _mediaItemTitle = mediaItemTitle; _rotation = rotation; _flipX = flipX; _flipY = flipY; SurfaceDescription desc = _texture.Texture.GetLevelDescription(0); _textureMaxUV = new SizeF(_texture.Width / (float)desc.Width, _texture.Height / (float)desc.Height); // Reset animation _animator.Initialize(); if (_slideShowTimer != null) { _slideShowTimer.Change(_slideShowImageDuration, TS_INFINITE); } else { CheckTimer(); } _playbackStartTime = DateTime.Now; if (_pauseTime.HasValue) { _pauseTime = _playbackStartTime; } } }
/// <summary> /// Sets the data of the new image to be played. /// </summary> /// <param name="locator">Resource locator of the image item.</param> /// <param name="mediaItemTitle">Title of the image item.</param> /// <param name="rotation">Rotation of the image.</param> /// <param name="flipX">Flipping in horizontal direction.</param> /// <param name="flipY">Flipping in vertical direction.</param> public void SetMediaItemData(IResourceLocator locator, string mediaItemTitle, RightAngledRotation rotation, bool flipX, bool flipY) { if (locator == null) lock (_syncObj) { _currentLocator = null; return; } using (IResourceAccessor ra = locator.CreateAccessor()) { IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor; if (fsra == null) return; using (Stream stream = fsra.OpenRead()) { string key = fsra.CanonicalLocalResourcePath.Serialize(); _texture = ContentManager.Instance.GetTexture(stream, key, true); if (_texture == null) return; if (!_texture.IsAllocated) _texture.Allocate(); if (!_texture.IsAllocated) return; } } lock (_syncObj) { ReloadSettings(); _state = PlayerState.Active; _currentLocator = locator; _mediaItemTitle = mediaItemTitle; _rotation = rotation; _flipX = flipX; _flipY = flipY; SurfaceDescription desc = _texture.Texture.GetLevelDescription(0); _textureMaxUV = new SizeF(_texture.Width / (float) desc.Width, _texture.Height / (float) desc.Height); // Reset animation _animator.Initialize(); if (_slideShowTimer != null) _slideShowTimer.Change(_slideShowImageDuration, TS_INFINITE); else CheckTimer(); _playbackStartTime = DateTime.Now; if (_pauseTime.HasValue) _pauseTime = _playbackStartTime; } }
/// <summary> /// Sets the data of the new image to be played. /// </summary> /// <param name="locator">Resource locator of the image item.</param> /// <param name="mediaItemTitle">Title of the image item.</param> /// <param name="rotation">Rotation of the image.</param> /// <param name="flipX">Flipping in horizontal direction.</param> /// <param name="flipY">Flipping in vertical direction.</param> public void SetMediaItemData(IResourceLocator locator, string mediaItemTitle, RightAngledRotation rotation, bool flipX, bool flipY) { if (locator == null) lock (_syncObj) { DisposeTexture(); _currentLocator = null; return; } Texture texture; ImageInformation imageInformation; using (IResourceAccessor ra = locator.CreateAccessor()) using (Stream stream = ra.OpenRead()) texture = Texture.FromStream(SkinContext.Device, stream, (int) stream.Length, 0, 0, 1, Usage.None, Format.A8R8G8B8, Pool.Default, Filter.None, Filter.None, 0, out imageInformation); lock (_syncObj) { ReloadSettings(); _state = PlayerState.Active; DisposeTexture(); _currentLocator = locator; _mediaItemTitle = mediaItemTitle; _texture = texture; _rotation = rotation; _flipX = flipX; _flipY = flipY; SurfaceDescription desc = _texture.GetLevelDescription(0); _textureMaxUV = new SizeF(imageInformation.Width / (float) desc.Width, imageInformation.Height / (float) desc.Height); // Reset animation _animator.Initialize(); if (_slideShowTimer != null) _slideShowTimer.Change(_slideShowImageDuration, TS_INFINITE); else CheckTimer(); _playbackStartTime = DateTime.Now; if (_pauseTime.HasValue) _pauseTime = _playbackStartTime; } }