public TalkPersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache) { var storageAccount = CloudStorageAccount.Parse(blobStorageConfig.BlobStorageConnectionString); cloudBlobClient = storageAccount.CreateCloudBlobClient(); this.cache = cache; }
public override void Load(ref Sprite parent) { Frames = new List <Rectangle>(); Animations = new List <Rectangle> [5]; for (int i = 0; i < Animations.Length; i++) { Animations[i] = new List <Rectangle>(); } MediaCache.LoadTexture(parent.TexturePath, out parent.Texture); Texture2D tex = MediaCache.GetTexture(parent.Texture); int j = 0; for (int i = 0; i < tex.Width; i += parent.Width) { Frames.Add(new Rectangle(i, j, parent.Width, parent.Height)); if (i == tex.Width - parent.Width && j == tex.Height - parent.Height) { break; } if (i == tex.Width - parent.Width) { j += parent.Height; i = 0; } } }
public TalkController(Dictionary <string, Conference> conferences, MediaCache cache, TalkService talkService, ContentService contentService) : base(conferences) { this.cache = cache; this.talkService = talkService; this.contentService = contentService; }
private void Play() { if (_playingTrack == null) { if (Stack.IsEmpty()) { return; } _playingTrack = Stack.First(); var task = MediaCache.FetchAsync(_playingTrack.MediaId); task.Wait(); var reader = new MediaFoundationReader(task.Result); _waveOut.Init(reader); _waveOut.Play(); } else { switch (_waveOut.PlaybackState) { case PlaybackState.Paused: _waveOut.Resume(); break; case PlaybackState.Playing: _waveOut.Pause(); break; } } }
private bool TryGetResult(HttpRequestBase request, IFormatInfo outputFormat, bool transformMedia, IMediaTransformer mediaTransformer, out IResult result) { var path = GetRequestPath(request); var originalPath = GetOriginalPath(request, mediaTransformer); if (MediaCache.TryServeRequestFromCache(transformMedia ? path : originalPath, outputFormat, out result)) { return(true); } IStorageFile storageFile; if (!StorageBackend.TryGetStorageFile(originalPath, out storageFile)) { return(false); } if (!transformMedia && !CacheOriginals) { result = storageFile; return(true); } if (transformMedia) { result = TransformMedia(storageFile.GetStream(), outputFormat, path, mediaTransformer); return(true); } result = ServeOriginal(originalPath, storageFile, outputFormat); return(true); }
public override void OnInitialize() { MediaCache.LoadTexture(Image, out string key); Texture2D temp = MediaCache.GetTexture(key); MinWidth.Set(temp.Width, 0f); MinHeight.Set(temp.Height, 0f); Image = key; }
private void InitDefaultMedia() { Texture2D tex = new Texture2D(GraphicsDevice, 1, 1) { Name = "pixel" }; tex.SetData(new Color[] { Color.White }); MediaCache.AddTexture(tex); }
public override void OnActivate() { if (BorderTexture == null) { MediaCache.LoadTexture("UI/PanelBorder", out BorderTexture); } if (BackgroundTexture == null) { MediaCache.LoadTexture("UI/PanelBackground", out BackgroundTexture); } }
private IResult ServeOriginal(string path, IStorageFile storageFile, IFormatInfo outputFormat) { var stream = storageFile.GetStream(); IAddToCacheResult cacheResult; if (MediaCache.TryAddToCache(path, stream, outputFormat, out cacheResult)) { return(new CopyToOutputStreamResult(cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream)); } return(storageFile); }
private void InitMediaCache() { if (media != null) { return; } StorageFolder media_dir = null; Task.Run(async() => { media_dir = await ApplicationData.Current.LocalFolder.CreateFolderAsync("MediaCache", CreationCollisionOption.OpenIfExists); }).Wait(); media = new MediaCache(media_dir, "MediaCache"); }
public override void Draw(SpriteBatch batch, ref Sprite parent) { #if DEBUG Color HitboxColor = Color.FromNonPremultiplied(96, 196, 255, 255); Texture2D pixel = MediaCache.GetTexture("pixel"); foreach (Queue <Point> qu in Collisions.Values) { foreach (Point point in qu) { batch.Draw(pixel, new Rectangle(point.X * 32, point.Y * 32, 32, 1), HitboxColor); batch.Draw(pixel, new Rectangle(point.X * 32, point.Y * 32, 1, 32), HitboxColor); batch.Draw(pixel, new Rectangle(point.X * 32, (point.Y + 1) * 32, 33, 1), HitboxColor); batch.Draw(pixel, new Rectangle((point.X + 1) * 32, point.Y * 32, 1, 32), HitboxColor); } } #endif }
private IResult TransformMedia(Stream original, IFormatInfo outputFormat, string path, IMediaTransformer mediaTransformer) { Stream stream; var transformResult = mediaTransformer.TransformStream(original, out stream); original.Dispose(); if (transformResult == MediaTransformResult.Success) { IAddToCacheResult cacheResult; if (MediaCache.TryAddToCache(path, stream, outputFormat, out cacheResult)) { return(new CopyToOutputStreamResult(cacheResult.LastModified, cacheResult.ETag, stream.Length, stream)); } } return(new CopyToOutputStreamResult(null, null, stream.Length, stream)); }
private void DrawPanel(SpriteBatch batch, string texture, Color color) { Rectangle dim = Dimensions.AsRectangle; Point rightside = new Point(dim.X + dim.Width - CORNER_SIZE, dim.Y + dim.Height - CORNER_SIZE / 2); int width = rightside.X - dim.X - CORNER_SIZE; int height = rightside.Y - dim.Y - CORNER_SIZE; Texture2D tex = MediaCache.GetTexture(texture); // Corners batch.Draw(tex, new Rectangle(dim.X, dim.Y, CORNER_SIZE, CORNER_SIZE), new Rectangle?(new Rectangle(0, 0, CORNER_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(rightside.X, dim.Y, CORNER_SIZE, CORNER_SIZE), new Rectangle?(new Rectangle(CORNER_SIZE + BAR_SIZE, 0, CORNER_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(dim.X, rightside.Y, CORNER_SIZE, CORNER_SIZE), new Rectangle?(new Rectangle(0, CORNER_SIZE + BAR_SIZE, CORNER_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(rightside.X, rightside.Y, CORNER_SIZE, CORNER_SIZE), new Rectangle?(new Rectangle(CORNER_SIZE + BAR_SIZE, CORNER_SIZE + BAR_SIZE, CORNER_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(dim.X + CORNER_SIZE, dim.Y, width, CORNER_SIZE), new Rectangle?(new Rectangle(CORNER_SIZE, 0, BAR_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(dim.X + CORNER_SIZE, rightside.Y, width, CORNER_SIZE), new Rectangle?(new Rectangle(CORNER_SIZE, CORNER_SIZE + BAR_SIZE, BAR_SIZE, CORNER_SIZE)), color); batch.Draw(tex, new Rectangle(dim.X, dim.Y + CORNER_SIZE, CORNER_SIZE, height), new Rectangle?(new Rectangle(0, CORNER_SIZE, CORNER_SIZE, BAR_SIZE)), color); batch.Draw(tex, new Rectangle(rightside.X, dim.Y + CORNER_SIZE, CORNER_SIZE, height), new Rectangle?(new Rectangle(CORNER_SIZE + BAR_SIZE, CORNER_SIZE, CORNER_SIZE, BAR_SIZE)), color); batch.Draw(tex, new Rectangle(dim.X + CORNER_SIZE, dim.Y + CORNER_SIZE, width, height), new Rectangle?(new Rectangle(CORNER_SIZE, CORNER_SIZE, BAR_SIZE, BAR_SIZE)), color); }
protected override void Initialize() { try { RootTag = BitIO.FromFile("ff.dat", false); } catch (Exception e) { string message = e.Message; BitIO.ToFile(new SharpTag(), "ff.dat", false); RootTag = BitIO.FromFile("ff.dat", false); } this.IsFixedTimeStep = true; if (RootTag.ContainsKey("SETTINGS")) { Settings.Load(RootTag.GetSharpTag("SETTINGS")); } else { Settings.Init(); } Graphics.PreferredBackBufferWidth = (int)(Settings.WindowWidth * Settings.WindowScale); Graphics.PreferredBackBufferHeight = (int)(Settings.WindowHeight * Settings.WindowScale); Graphics.ApplyChanges(); #if DEBUG Window.Title = "(DEBUG) Final Fantasy: Dawn of Souls"; #else Window.Title = "Final Fantasy: Dawn of Souls"; #endif Window.AllowUserResizing = false; Window.AllowAltF4 = false; MediaCache.Init(GraphicsDevice); InitDefaultMedia(); InitVariables(); base.Initialize(); }
public void Dispose() { ContentCache?.Dispose(); MediaCache?.Dispose(); MemberCache?.Dispose(); }
public ConferencePersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache) : base(blobStorageConfig, cache) { }
protected override void DrawSelf(SpriteBatch batch) { batch.Draw(MediaCache.GetTexture(Image), Dimensions.Position, null, new Color(1f, 1f, 1f, Alpha), 0f, Vector2.Zero, Scale, default, 0f);
public ThumbnailPersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache) : base(blobStorageConfig, cache) { }
public override void Draw(SpriteBatch batch, ref Sprite parent) { batch.Draw(MediaCache.GetTexture(parent.Texture), new Rectangle((int)parent.Position.X, (int)parent.Position.Y, parent.Width, parent.Height), Color.White); }
public override void Activate(ref Sprite parent) { MediaCache.LoadTexture(parent.TexturePath, out parent.Texture); }
protected override void UnloadContent() { RootTag.Add("SETTINGS", Settings.Save()); BitIO.ToFile(RootTag, "ff.dat", false); MediaCache.UnloadAll(); }
public override void Draw(SpriteBatch batch, ref Sprite parent) { Rectangle?rect = new Rectangle?(Animations[Direction][CurrentFrame]); batch.Draw(MediaCache.GetTexture(parent.Texture), parent.Position, rect, Color.White); }
public ConferenceController(Dictionary <string, Conference> conferences, MediaCache cache, ConferenceService conferenceService) : base(conferences) { this.cache = cache; this.conferenceService = conferenceService; }
public void PushToStack(TrackRow row) { Stack.Insert(0, row); MediaCache.FetchAsync(row.MediaId); RaisePropertyChanged("Stack"); }
public SpeakerController(Dictionary <string, Conference> conferences, MediaCache talkCache, SpeakerService speakerService) : base(conferences) { this.talkCache = talkCache; this.speakerService = speakerService; }
public override void Deactivate(ref Sprite parent) { MediaCache.UnloadTexture(parent.Texture); }
public ThumbnailController(Dictionary <string, Conference> conferences, ThumbnailService thumbnailService, MediaCache cache) : base(conferences) { this.thumbnailService = thumbnailService; this.cache = cache; }
public ThumbnailService(IFileProvider fileProvider, MediaCache cache, ThumbnailPersistence thumbnailPersistence) { this.fileProvider = fileProvider; this.cache = cache; this.thumbnailPersistence = thumbnailPersistence; }