C# - Play videos from resources in wmp component












0















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?










share|improve this question























  • 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
















0















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?










share|improve this question























  • 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














0












0








0








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 1 '13 at 17:24









Lucas DiasLucas 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



















  • 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












1 Answer
1






active

oldest

votes


















3














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");





share|improve this answer


























  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














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");





share|improve this answer


























  • 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
















3














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");





share|improve this answer


























  • 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














3












3








3







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");





share|improve this answer















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");






share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 1 '13 at 18:35

























answered Jul 1 '13 at 17:43









SmartisSmartis

4,22132441




4,22132441













  • 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






  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents