How to play video stream with MPMoviePlayerController in iOS

Instead of creating a MPMoviePlayerController and adding that to your view, it is probably simpler to create a MPMoviePlayerViewController and present that view controller modally (since you are trying to show your video full screen anyway). Then the MPMoviePlayerViewController can manage the presentation of your video for you. MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; [[NSNotificationCenter … Read more

File.ReadLines without locking it?

No… If you look with Reflector you’ll see that in the end File.ReadLines opens a FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.SequentialScan); So Read-only share. (it technically opens a StreamReader with the FileStream as described above) I’ll add that it seems to be child’s play to make a static method to do it: public static IEnumerable<string> … Read more

How to read the first byte of a subprocess’s stdout and then discard the rest in Python?

If you’re using Python 3.3+, you can use the DEVNULL special value for stdout and stderr to discard subprocess output. from subprocess import Popen, DEVNULL process = Popen([“mycmd”, “myarg”], stdout=DEVNULL, stderr=DEVNULL) Or if you’re using Python 2.4+, you can simulate this with: import os from subprocess import Popen DEVNULL = open(os.devnull, ‘wb’) process = Popen([“mycmd”, … Read more

How can I read an Http response stream twice in C#?

Copy it into a new MemoryStream first. Then you can re-read the MemoryStream as many times as you like: Stream responseStream = CopyAndClose(resp.GetResponseStream()); // Do something with the stream responseStream.Position = 0; // Do something with the stream again private static Stream CopyAndClose(Stream inputStream) { const int readSize = 256; byte[] buffer = new byte[readSize]; … Read more

java file input with rewind()/reset() capability

I think the answers referencing a FileChannel are on the mark . Here’s a sample implementation of an input stream that encapsulates this functionality. It uses delegation, so it’s not a true FileInputStream, but it is an InputStream, which is usually sufficient. One could similarly extend FileInputStream if that’s a requirement. Not tested, use at … Read more