I'm making an application that downloads video files from the internet.
The application needs to launch the system's default video player to play these files while they are being downloaded.
I'm not interested in implementing a video (or network) stream to make this work. The videos are being downloaded in sequential order. I need to simulate the process of a user clicking on the video file from file explorer while it is downloading (which always works provided that enough bytes are saved).
To achieve this I spawn a child process that runs
start filepath/filename.avi
but it fails saying the file is in use by another process.
This command also fails if I type it in the cmd while the file is downloading.
However, if I double click the file it will start to play normally in the system's default video player.
What command can I use to make the file open in the system's default video player while it is being downloaded (used by another process)?
Thanks.
Note: files may be of any type, not only .avi like in the example
Related
I want to trigger a piece of code to run as soon as a 'copy' command is executed on Windows. Let's say I want to perform some operations as soon as the user tries to copy a file. Is there any way to detect the 'copy' operation on Windows?
You may monitor the clipboard (see Creating a Clipboard Format Listener) and check if there is an object with format CF_HDROP in it. But it will not tell you when the clipboard paste operation actually started.
This also will not cover copying which does not involve clipboard, like direct file_read/file_write loop in a File Manager application. For this you may monitor changes in the file system (see How can I monitor a Windows directory for changes?) but it will not tell you where was the file copied from, just where was it pasted to.
I am having issues with my "Automatically Add to iTunes". As a result, I am trying to make an Applescript that will be stored on my USB, and when I click on a certain Music File, I want it to launch an applescript.
I did some research, and everyone keeps telling me about Launchd. How would I use this command to run an applescript saved as .app? I want to store this Music File and the Applescript on my USB, because I have multiple computers. Can I get it to run as soon as I open a specified music file? Thank you.
I eventually figured out a way to do what I wanted, which was to somehow play a music file from inside the application. All I did was use the idea of resources because it can reference itself without having to rely on a file stored somewhere else on the system. Here's a link to essentially what I did: https://apple.stackexchange.com/questions/157724/applescript-path-to-files-in-applications-resources
in short, I contained the music file within the app itself and played it when it was needed.
I've implemented a user mode program and a Windows file system minifilter that creates a skeleton view of users files for a remote file storage system. It maps the remote files to the local drive. The user mode program creates a reparse tag for each file on the remote system. When a create request (e.g., CreateFile for read) is detected, the minifilter asks the user mode program to download the file. This should only happen when a program wants to open the file for viewing or editing.
But, I'm finding that Windows Explorer is triggering my files to download. I'd like to prevent the Explorer File windows and File Open/Save dialogs from
triggering downloads. And, I also want to display the file thumbnails and file
size.
[Update: I've found I can use Windows sparse files to show my remote
file size in Explorer. ]
Therefore, I have also implemented a Shell Extension, IThumbnailProvider, that downloads a rendition of the file. This provides the file thumbnails.
For my testing, I've registered the IThumbnailProvider for all files (*) and for .jpg files.
I'm seeing two interesting behaviors using a combination of Process Monitor and DebugView (both from SysInternals):
1. If I make my minifilter reject requests to open the file from Explorer, then my IThumbnailProvider is invoked.
2. If I permit open requests from Explorer, I see thumbcache.dll in the call stack trying to open the file and my IThumbnailProvider is not called. It appears that the default thumbnail provider reads the downloaded file and creates the thumbnail.
I must be missing something.
Update: if I use InitializeWithStream instead of InitializeWithFile, it appears my handler is invoked. But, that also triggers a download of the file.
There are many shell extension types which can access to your files. Icon handler can read file to create icon, Info tip handler can read file to create text hint, Data object handler can read file to create clipboard data and so on.
Questions from developer with the same problem: first and second. Solution was to create namespace shell extension. NSE can control all access to your files.
This is only under windows env.
As I know windows os identifies associated application of a particular file by file extension.
Like wise each file (binary) starting with corresponding symbols ("starting symbols"). For an example .JPG starts with ÿØÿà. Let say I open this .JPG file in a Hex editor or a Text editor and then I change that starting symbols into another file type. for an example I can change ÿØÿà to .Eߣ (.mkv). So when I double click on the .JPG the Windows Photo Viewer says there are some errors or similar message. So I need to get some information about the application that tries to open that kind of a file. If I can, I need to open that file using the application that associated with "starting symbols".
Briefly when I open .JPG I need to open a default video player .mkv files. But It may not work for this example. Because I changed only the "starting symbols" of my .JPG.
Please give me any idea to do this.
Thanks!
When you encrypt the file, give it a new extension. e.g. Picture.jpg becomes Picture.encrypted-jpg. You then register as the handler for encrypted-jpg, decrypt the file, then launch the normal jpg handler.
When the shell is asked to perform a verb on a file, the shell does not use the contents of the file to determine which app to pass it to. The file extension is what determines how the file will be treated.
You wish to use the contents of the file to influence which app processes a shell verb. In order to do so you would need to create a launcher app that reads the file header and then decides which app to pass the file on to. You would assign your launcher app as the handler app for all file extensions that you were interested in.
Although you could do this, it would be much easier just to set the file extension appropriately.
The proper way to do this sort of thing is to replace the files with reparse points.
The downside is that this involves writing a file system filter driver, i.e., an operating system extension, which is a whole level of trouble above and beyond ordinary application programming. (Since Windows already does file encryption, I doubt it would be worth the effort.)
I have a mediaplayer that can only read samba shared files. I would like to play http stream (from my dreambox for instance).
My idea is to share a folder on my linux. In this share, I will put a (fake?) file for each tv channel I want to be able to watch (ex : channel1.ts, channel2.ts ...).
The mediaplayer can only read these file as it should with regular files. My need : do something that "listen" for access on these files so that when my mediaplayer access it, it fires a mencoder -oac copy -ovc copy -o channel1.ts http://path.to.the.broadcast.ts.
I tried using inotify on an empty file. It fires the mencoder well BUT the mediaplayer stops before encoding starts (because the file is empty so it reaches the end before it starts). Perhaps, have to fill 5s of video in order to buffer the read ?
Could be nice to use a "fifo" => I tried it, the mediaplayer waits, when I do the mencoder, the fifo starts growing, the mediaplayer plays it ! Yeahh !!!... BUT inotify seems not to react on a fifo... so I can't fire mencoder automatically.
Every suggestions welcome.
Basic points :
The media player can ONLY reads regular files
File must be in a samba shared folder
Record must be "fired" on demand (when mediaplater try to access it)
Could be nice to watch for "inactivity" in order to stop recording / emptying buffer file
It is not easy to formalise this question. I am a bit disapointed and I even't don't know what kind of search I could googelise for that.
Hope some gurus here will find something to do the trick
Cheers.
You might want to look at the techniques Hierarchical Storage Management and on-access Virus Scanners use, as they need to do similar interruption before the normal access.
e.g. Use Talpa to intercept open operations in the selected directory, and replace the file at that point.