1

I am developing vb.net Windows application for playing the video file.

I have added a video files in embedded resource in this way:

Project->Properties. Then select the "Resources" tab. Next Select "Add Resource"->"From Existing File".

I am able to play the one video,with following code

   Dim FilePath = Path.Combine(Application.StartupPath, "My video.mp4")
    If (Not File.Exists(FilePath)) Then
        File.WriteAllBytes(FilePath, My.Resources.video1)
    End If

    AxWindowsMediaPlayer1.URL = FilePath
    AxWindowsMediaPlayer1.Ctlcontrols.play()

The video is working fine , but problem is, application creates the video file in the bin folder every time.

You can see here...

enter image description here

My application's Current exe size in 200 MB, as I have added many videos into the resources. What the use of adding video into resources, if it going to produce new video file every time ?

I have did same thing with images, I have added images in resources which used in the app, but I don't req. to carry these images as well , it dont produce the image after running the app.

I can put the exe on any machine and app gets run with those images perfectly...

Is there any way to play the embedded video , from resource itself without creating the video file ?

bnil
  • 1,531
  • 6
  • 35
  • 68
  • 1
    `What the use of adding video into resources` it assures that the video will be available to your app and wont get deleted when you distribute it. BTW, *you* are writing out the file with `File.WriteAllBytes...` – Ňɏssa Pøngjǣrdenlarp May 13 '16 at 16:12
  • Possible dupe of: http://stackoverflow.com/q/23968387/1070452 (Roman is Mr Wizard when it comes to DX and WMP) – Ňɏssa Pøngjǣrdenlarp May 13 '16 at 16:18
  • @Plutonix, Is there any way other than 'File.WriteAllbytes...' and I don't find any perfect solution for that question... – bnil May 13 '16 at 16:20
  • I am not sure why writing out the file is such a big deal, but you could always request a Tempfile name, write to *that* (a distributed app may well not have the right to write to the install location anyway). Then after it plays or when the app ends, delete the file so it *looks like* it played internally. – Ňɏssa Pøngjǣrdenlarp May 13 '16 at 16:24
  • Well, I want to avoid the piracy of these videos, as I am going to install the app in various machines which are out of my reach... – bnil May 13 '16 at 16:36

1 Answers1

1

Some thoughts, then a possible solution:

  • I wouldn't recommend embedding large videos in your .exe as it creates a huge executable.

  • There's only so much you can do to prevent piracy. Even if you prevent them from copying the local video file, they could still use software to record their screen.

Having said that, what you'd ideally want to do is play from a memory stream instead of a file. But AxWindowsMediaPlayer can't play from a stream.

What you might be able to do is play it from a virtual file system which mimics a local file but in memory. Here's an SDK that allows you to do that: http://boxedapp.com/encrypted_video_streaming.html

From the documentation: Why and when is it useful? "When an application uses DLL and files, which are to be kept secure, and because of that you can't save them to disk"

They have examples for VB.Net including using the AxWindowsMediaPlayer.

Also, it does require purchasing a developer's license.

Chase Rocker
  • 1,908
  • 2
  • 13
  • 14
  • The most important thing is, I don't want to put any video file on the machine... thats why I am trying to embedd the video in resources, whether boxedapp , will help me in that ? – bnil May 14 '16 at 06:16