Ejemplo n.º 1
0
        public TalkPersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache)
        {
            var storageAccount = CloudStorageAccount.Parse(blobStorageConfig.BlobStorageConnectionString);

            cloudBlobClient = storageAccount.CreateCloudBlobClient();
            this.cache      = cache;
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
 public TalkController(Dictionary <string, Conference> conferences, MediaCache cache, TalkService talkService, ContentService contentService)
     : base(conferences)
 {
     this.cache          = cache;
     this.talkService    = talkService;
     this.contentService = contentService;
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        private void InitDefaultMedia()
        {
            Texture2D tex = new Texture2D(GraphicsDevice, 1, 1)
            {
                Name = "pixel"
            };

            tex.SetData(new Color[] { Color.White });
            MediaCache.AddTexture(tex);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 10
0
        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");
        }
Ejemplo n.º 11
0
        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
        }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 15
0
 public void Dispose()
 {
     ContentCache?.Dispose();
     MediaCache?.Dispose();
     MemberCache?.Dispose();
 }
Ejemplo n.º 16
0
 public ConferencePersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache)
     : base(blobStorageConfig, cache)
 {
 }
Ejemplo n.º 17
0
 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);
Ejemplo n.º 18
0
 public ThumbnailPersistence(IBlogStorageConfig blobStorageConfig, MediaCache cache)
     : base(blobStorageConfig, cache)
 {
 }
Ejemplo n.º 19
0
 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);
 }
Ejemplo n.º 20
0
 public override void Activate(ref Sprite parent)
 {
     MediaCache.LoadTexture(parent.TexturePath, out parent.Texture);
 }
Ejemplo n.º 21
0
 protected override void UnloadContent()
 {
     RootTag.Add("SETTINGS", Settings.Save());
     BitIO.ToFile(RootTag, "ff.dat", false);
     MediaCache.UnloadAll();
 }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
 public ConferenceController(Dictionary <string, Conference> conferences, MediaCache cache, ConferenceService conferenceService)
     : base(conferences)
 {
     this.cache             = cache;
     this.conferenceService = conferenceService;
 }
Ejemplo n.º 24
0
 public void PushToStack(TrackRow row)
 {
     Stack.Insert(0, row);
     MediaCache.FetchAsync(row.MediaId);
     RaisePropertyChanged("Stack");
 }
Ejemplo n.º 25
0
 public SpeakerController(Dictionary <string, Conference> conferences, MediaCache talkCache, SpeakerService speakerService)
     : base(conferences)
 {
     this.talkCache      = talkCache;
     this.speakerService = speakerService;
 }
Ejemplo n.º 26
0
 public override void Deactivate(ref Sprite parent)
 {
     MediaCache.UnloadTexture(parent.Texture);
 }
Ejemplo n.º 27
0
 public ThumbnailController(Dictionary <string, Conference> conferences, ThumbnailService thumbnailService, MediaCache cache)
     : base(conferences)
 {
     this.thumbnailService = thumbnailService;
     this.cache            = cache;
 }
Ejemplo n.º 28
0
 public ThumbnailService(IFileProvider fileProvider, MediaCache cache, ThumbnailPersistence thumbnailPersistence)
 {
     this.fileProvider         = fileProvider;
     this.cache                = cache;
     this.thumbnailPersistence = thumbnailPersistence;
 }