Intercepting of loading // Pehvat flash zagruzok

.NET Edition of the F-IN-BOX
vsesh02
Posts: 23
Joined: Mon Oct 12, 2009 7:51 am

Intercepting of loading // Pehvat flash zagruzok

Postby vsesh02 » Mon Oct 12, 2009 8:00 am

Dobryj den'! Vozmozhno li s pomow'ju f-in-box perehvatyvat' zagruzku vneshnih dannyh flashom (izobrazhenija, drugie flash)? To est' shema takaja - flash sozdaet obrawenie, programma perehvatyvaet jeto obrawenie, chitaet fajl i peredaet potok vo flash (to est' vneshnih dannyh tozhe bez vremennyh fajlov). Spasibo

Добрый день! Возможно ли с помощью f-in-box перехватывать загрузку внешних данных флешом (изображения, другие flash)? То есть схема такая - flash создает обращение, программа перехватывает это обращение, читает файл и передает поток во flash (то есть внешних данных тоже без временных файлов). Спасибо

---

translated by admin:

Good morning! Is it possible to intercept loading of external resources (images, another flash movies) with f-in-box? I.e. the scenario is the following: an application intercepts such loading, read a file and pass a stream to Flash (without temporary files). Thank you.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Oct 12, 2009 8:25 am

Thank you for your question.

Yes, for example, check sample Samples\C#\Sample06_ExternalResourcesEmbedding (download demo from http://f-in-box.com/download/FlashPlaye ... DotNet.zip ):

Code: Select all

      private void OnLoadExternalResourceByRelativePath(object sender, String strRelativePath, System.IO.Stream Stream, ref bool Handled)
      {
         System.IO.Stream FromStream = null;

         if (strRelativePath == "images/embedded_image1.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image1.jpg");
         if (strRelativePath == "images/embedded_image2.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image2.jpg");
         if (strRelativePath == "images/embedded_image3.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image3.jpg");
         if (strRelativePath == "images/embedded_image4.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image4.jpg");
         if (strRelativePath == "images/embedded_image5.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image5.jpg");
         if (strRelativePath == "images/external_image.jpg")
         {
            if (OpenJPEGFileDialog.ShowDialog() == DialogResult.OK)
               FromStream = OpenJPEGFileDialog.OpenFile();
         }

         if (FromStream != null)
         {
            const int size = 64 * 1024;
            byte[] buffer = new byte[size];
            int ReadBytes;

            while ( (ReadBytes = FromStream.Read(buffer, 0, size)) > 0 )
            {
               try
               {
                  Stream.Write(buffer, 0, size);
               }
               catch (System.IO.IOException /* e */ )
               {
                  // Loading is interrupted
                  break;
               }
            }

            Stream.Close();

            Handled = true;
         }
      }


Thank you.

---

Спасибо за вопрос.

Да, это возможно, посмотрите, к примеру, Samples\C#\Sample06_ExternalResourcesEmbedding (вам потребуется загрузить демо: http://f-in-box.com/download/FlashPlaye ... DotNet.zip ):

Code: Select all

      private void OnLoadExternalResourceByRelativePath(object sender, String strRelativePath, System.IO.Stream Stream, ref bool Handled)
      {
         System.IO.Stream FromStream = null;

         if (strRelativePath == "images/embedded_image1.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image1.jpg");
         if (strRelativePath == "images/embedded_image2.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image2.jpg");
         if (strRelativePath == "images/embedded_image3.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image3.jpg");
         if (strRelativePath == "images/embedded_image4.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image4.jpg");
         if (strRelativePath == "images/embedded_image5.jpg")
            FromStream = this.GetType().Assembly.GetManifestResourceStream("Sample06_ExternalResourcesEmbedding.Resources.embedded_images.embedded_image5.jpg");
         if (strRelativePath == "images/external_image.jpg")
         {
            if (OpenJPEGFileDialog.ShowDialog() == DialogResult.OK)
               FromStream = OpenJPEGFileDialog.OpenFile();
         }

         if (FromStream != null)
         {
            const int size = 64 * 1024;
            byte[] buffer = new byte[size];
            int ReadBytes;

            while ( (ReadBytes = FromStream.Read(buffer, 0, size)) > 0 )
            {
               try
               {
                  Stream.Write(buffer, 0, size);
               }
               catch (System.IO.IOException /* e */ )
               {
                  // Loading is interrupted
                  break;
               }
            }

            Stream.Close();

            Handled = true;
         }
      }


Спасибо.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 10 guests