I've embedded a Silverlight video file which is 15 MB in my silverlight assembly. I use Application.GetResourceStream to read the resource as an stream and then I pass the returned stream to the MediaElement control to start playing it.
Question: Does Application.GetResourceStream read the whole embedded file at once? If yes, Is there any solution to prevent this behaviour?
Note: I'm building an OOB silverlight application and it's going to be published using offline media(CD ROM), so don't worry about the enlarged xap file.
Thanks in advance.
The clue is in the name Stream. That means it opens a file and reads from it sequentially (like a flowing stream).
Because of the nature of video players, which decompress streams on the fly, it will buffer a certain amount internally before playback starts. This allows the playback to stay ahead of the incoming data. For a locally stored file that will only be a small amount of data.
Why were you concerned about it reading the whole file? Are you having performance problems or long delays?
Related
I'm running into problems on the WP7 with MediaElement downloading a 128kbps mp3 stream from a web service for a music player app that i'm working on. The file downloads correctly when the wp7 is on a wifi connection, but downloading sometimes stops when off of wifi. The problem is that i'm not getting any errors or exceptions when the downloading fails and the MediaElement state is "playing". MediaElement runs right past the downloaded portion of the stream and acts like it is playing, but there is nothing to play since the download stopped. I can somewhat replicate this issue based upon my location and using the 3g instead of wifi, so i believe it is due to a low connection. I don't believe any code needs to be shown in this instance, but i try to post something. I want to know if I have any control over this? Are there any other events I could use to detect when the download has failed? Is there another way I could download a mp3 stream that is more reliable and play it? Is there another player/component I should try?
Thanks in advance
You could always use MediaStreamSource to try to handle the download and implement streaming, to some extent. It is a more "painful" way of doing this since you will have to work with an extra media layer, but it pays off by improving playback stability.
Here is a starter example by Tim Heuer. Take a look specifically at how he takes advantage of a custom implementation of MediaStreamSource. Here is a more complex sample.
If streaming is not a requirement, you could download the file (and store it in the Isolated Storage) and then play from there.
I currently send a live video mix to a output screen (a form on a particular screen). Consider it like a really advanced version of PowerPoint. I call it a video control room for the pc. I want to take 30 frames a second from a screen (of my choice, I allow multiple screens) and the audio from the computer (stereo) set, save it to a hard disks. How do I do that?
I know I can draw the image of the interface using the RenderTargetBitmap class, but How do I put those images (as frames) in an AVI file or push it to a video server? An SDK? or a Code Example to point me in the right direction, would be nice! I also want to capture the sound of the current Stereo mix, or microphone (as determined by the user).
I don't want to use a third-party and I'd prefer doing it in the program to take maximum control over it. I'm ok, with using a second program to do compression and just saving a raw AVI file (with audio stream). Disk is cheap, as any programmer would say. If I have to, I'll save the video and audio streams separately, but I'd prefer not to.
Let me know.
Check out the RenderTargetBitmap class. it allows you to turn any visual into pixels that you can then pass along to an encoder/network stack, like the ones described here
also check out Windows media foundation for turning your pixels into an avi or stream
I've data in MP4 format which needs to be copied to DVD on Linux platform. Now I am creating MP4 file on hard disk and then burning that file to DVD using growisofs command.
It would be more efficient if I didn't have to write the MP4 data to hard disk before they are burned to DVD. Please let me know if there is a way to write in memory data to DVD using C program.
By reimplementing the tasks growisofs performs. DVDs are different to randomly accessible storage. First the data to be burnt onto the blank medium must be prepared into in a certain format, namely ISO9660, this includes a certain error correction scheme. The result of this is a complete Track. In the ISO9660 scheme it's not possible to record single files, only whole file systems. Once you got the FS you must implement the whole program for controlling the recording process.
This is what growisofs does. Now you could take the source of growisofs and replace the code it uses to read the files with code to read from some shared memory. But then you must make sure, that your program can deliver the data continously, without falling into pauses. Once started, the recording process should not be interrupted.
Anyway: If you're under Linux your program could provide the filesystem structure through FUSE.
I have a program written in C that allows the user to scroll through a display of about a zillion small files. Each file needs to undergo a certain amount of processing (read only) before it's displayed to the user. I've implemented a buffer that preprocesses the files in a certain radius around the user's position, so if they're working linearly through them, there's not much delay. For various reasons, I can only actually run my processing algorithm on one file at a time (though I can have multiple files open, and I can read from them) so my buffer loads sequentially.
My processing algorithms are as optimized as they're going to get, but I'm running into I/O problems. At first, my loading process is slow, but when the files have been accessed a few times, it speeds up by about 5x. Therefore I strongly suspect that what's slowing me down is waiting for the Windows page cache to pull my files into memory. I know very little about that sort of thing. If I could ensure my files were in the cache before my processing algorithm needed them, I'd be in business.
My question is: is there a way to persuade/cajole/trick/intimidate Windows into loading my files into the page cache before I actually get around to reading/processing them?
There's only one way to get a file into the file system cache: reading it. That's a chicken-and-egg problem. You can get the egg first by using a helper thread that reads files. It would have to have some kind of smarts about what file is likely to be next. And not read too much.
On a POSIX system, you'd use posix_fadvise:
POSIX_FADV_WILLNEED
Specifies that the application expects to access the specified data in the near future.
However, that doesn't seem to exist on Windows. What is fadvise/madvise equivalent on windows ? - Stack Overflow has some alternatives.
How do I stream live audio from the location to over the internet using Silverlight 2.0? What equipment, software etc do I need?
I've written/ported a MP3 decoder to Silverlight 3.
To get around the issue of a seekable stream and MediaStreamSource, I wrote a custom stream, SeekableStream, that wraps around any other Stream and makes it appear seekable by using an internal memory stream.
You can see it in action here where it can play a MP3 files located locally on your machine or on the web.
Source for the library and demo is now up on CodePlex
It depends what you want to stream. If you just want to stream Mp3s over the web the Silverlight 2 MediaElement will do it for you. Just point the Source property to the Uri of the mp3 and you're done. That same technique works for video, too. If you want to stream live content (i.e. a webcam) then you should use the stream services that were linked to by the other commenter.