C# - Play videos from resources in wmp component
up vote
0
down vote
favorite
I have a wmp component in a C# Windows Forms and i want it to play a video (.avi) from the solution's resources. I need to know the code for the wmp component to find the video. Suggestions?
c# video resources wmp
add a comment |
up vote
0
down vote
favorite
I have a wmp component in a C# Windows Forms and i want it to play a video (.avi) from the solution's resources. I need to know the code for the wmp component to find the video. Suggestions?
c# video resources wmp
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
1
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a wmp component in a C# Windows Forms and i want it to play a video (.avi) from the solution's resources. I need to know the code for the wmp component to find the video. Suggestions?
c# video resources wmp
I have a wmp component in a C# Windows Forms and i want it to play a video (.avi) from the solution's resources. I need to know the code for the wmp component to find the video. Suggestions?
c# video resources wmp
c# video resources wmp
asked Jul 1 '13 at 17:24
Lucas Dias
1013
1013
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
1
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29
add a comment |
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
1
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
1
1
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Currently there is a way over streaming the file.
First of all, we need a place where it should be always possible
string streamPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"";
Next Step an Instance of the MediaPlayer
WindowsMediaPlayer wmp = new WindowsMediaPlayer();
Then we need to stream the Assembly Resource
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Smartis.Resources.Natur.wmv");
using (Stream output = new FileStream (streamPath + "mediafile.avi", FileMode.Create))
{
byte buffer = new byte[32*1024];
int read;
while ( (read= stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
Finally we should be able to load the file.
wmp.URL = streamPath + "mediafile.avi";
wmp.controls.play();
After playing don't forget to clear the folder:
File.Delete(streamPath + "mediafile.avi");
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Currently there is a way over streaming the file.
First of all, we need a place where it should be always possible
string streamPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"";
Next Step an Instance of the MediaPlayer
WindowsMediaPlayer wmp = new WindowsMediaPlayer();
Then we need to stream the Assembly Resource
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Smartis.Resources.Natur.wmv");
using (Stream output = new FileStream (streamPath + "mediafile.avi", FileMode.Create))
{
byte buffer = new byte[32*1024];
int read;
while ( (read= stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
Finally we should be able to load the file.
wmp.URL = streamPath + "mediafile.avi";
wmp.controls.play();
After playing don't forget to clear the folder:
File.Delete(streamPath + "mediafile.avi");
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
add a comment |
up vote
4
down vote
accepted
Currently there is a way over streaming the file.
First of all, we need a place where it should be always possible
string streamPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"";
Next Step an Instance of the MediaPlayer
WindowsMediaPlayer wmp = new WindowsMediaPlayer();
Then we need to stream the Assembly Resource
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Smartis.Resources.Natur.wmv");
using (Stream output = new FileStream (streamPath + "mediafile.avi", FileMode.Create))
{
byte buffer = new byte[32*1024];
int read;
while ( (read= stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
Finally we should be able to load the file.
wmp.URL = streamPath + "mediafile.avi";
wmp.controls.play();
After playing don't forget to clear the folder:
File.Delete(streamPath + "mediafile.avi");
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Currently there is a way over streaming the file.
First of all, we need a place where it should be always possible
string streamPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"";
Next Step an Instance of the MediaPlayer
WindowsMediaPlayer wmp = new WindowsMediaPlayer();
Then we need to stream the Assembly Resource
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Smartis.Resources.Natur.wmv");
using (Stream output = new FileStream (streamPath + "mediafile.avi", FileMode.Create))
{
byte buffer = new byte[32*1024];
int read;
while ( (read= stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
Finally we should be able to load the file.
wmp.URL = streamPath + "mediafile.avi";
wmp.controls.play();
After playing don't forget to clear the folder:
File.Delete(streamPath + "mediafile.avi");
Currently there is a way over streaming the file.
First of all, we need a place where it should be always possible
string streamPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"";
Next Step an Instance of the MediaPlayer
WindowsMediaPlayer wmp = new WindowsMediaPlayer();
Then we need to stream the Assembly Resource
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Smartis.Resources.Natur.wmv");
using (Stream output = new FileStream (streamPath + "mediafile.avi", FileMode.Create))
{
byte buffer = new byte[32*1024];
int read;
while ( (read= stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
Finally we should be able to load the file.
wmp.URL = streamPath + "mediafile.avi";
wmp.controls.play();
After playing don't forget to clear the folder:
File.Delete(streamPath + "mediafile.avi");
edited Jul 1 '13 at 18:35
answered Jul 1 '13 at 17:43
Smartis
4,14832440
4,14832440
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
add a comment |
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
This won't work because the video is not located in an URL, it's in the resources of the program
– Lucas Dias
Jul 1 '13 at 17:53
1
1
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
Gentlemen, you had my curiosity. But now you have my attention. Upvote
– Smartis
Jul 1 '13 at 18:00
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
@LucasDias: Try this...
– Smartis
Jul 1 '13 at 18:38
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
thank you good sir ^^
– Lucas Dias
Jul 1 '13 at 18:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17410199%2fc-sharp-play-videos-from-resources-in-wmp-component%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Here come the downvotes...
– Brian
Jul 1 '13 at 17:29
What did you so far? Post some Code.
– Smartis
Jul 1 '13 at 17:29
1
@Brian always the same -.-
– Smartis
Jul 1 '13 at 17:29