Thank you for your question.
Yes, you need FLVPlayer.swf embedded in the application. This file contains FLV player. Flash isn't able to play FLV directly, only from a player inside a flash movie. FLVPlayer.swf contains such movie.
How to play FLV from a stream step-by-step (also see example samples\C#\Sample02_SWF_FLV_Embedding):
1. Add FLVPlayer.swf as embedded resource to a project.
2. Add a handler:
Code: Select all
f_in_box__control1.AxCode.OnLoadExternalResourceByFullPath +=
new f_in_box__lib.AxCode.OnLoadExternalResourceByFullPathEventHandler(OnLoadExternalResourceByFullPath);
2. Loads FLVPlayer.swf from a resource:
Code: Select all
f_in_box__control1.PutMovieFromStream(
this.GetType().Assembly.GetManifestResourceStream("Sample02_SWF_FLV_Embedding.Embedded_Movies.movie.swf"));
f_in_box__control1.FlashMethod_Play();
3. The handler code:
Code: Select all
private void OnLoadExternalResourceByFullPath(object sender, String URL, System.IO.Stream Stream, ref bool Handled)
{
if (URL == "http://FLV/FlashVideo.flv")
{
System.IO.Stream FLVStream = !!!Your stream here!!!;
FromStreamToStreamWriter writer =
new FromStreamToStreamWriter(
FLVStream,
Stream
);
Handled = true;
}
}
FromStreamToStreamWriter creates a separate thread that copies bytes from FLVStream to Stream. But if FLV is small you can copy its content inside the handler:
Code: Select all
private void OnLoadExternalResourceByFullPath(
object sender,
String URL,
System.IO.Stream Stream,
ref bool Handled)
{
if (URL == "http://FLV/FlashVideo.flv")
{
Stream FLVStream = !!!Your stream here!!!;
const int nSize = 64 * 1024;
byte[] buffer = new byte[nSize];
int nReadBytes;
while (true)
{
nReadBytes = FLVStream.Read(buffer, 0, nSize);
if (0 == nReadBytes)
break;
try
{
ToStream.Write(buffer, 0, nReadBytes);
}
catch (System.IO.IOException /* e */ )
{
// Loading is interrupted
break;
}
}
FLVStream.Close();
ToStream.Close();
}
Handled = true;
}