Retrieving video file information in asp.net - c#

I have a admin panel where i am uploading some video and settings some of its parameters manually to save it in database fields, like FileName, FileSize in Mb and Video duration.Now the requirement changed and it became something this, immediately after selecting a video file (either of them avi, mpeg, mp4, mpg, dat or vob etc), in a file upload control, the properties of the video file will get immediately set to its corresponding label or textbox.
I have tried a lot but unable to find any event related to the same. Also one more issue i faced while getting the duration of the video. I have tried DirectShow and FfMpeg but of no use. So basically i am stucked with the problems where I need your help. I am only able to get the file name immediately in javascript. So i need your suggestions.
How To retrieve the duration of video,immediately after video selection in fileupload control either in javascript or c# (any open source managed lib will b heartily welcome).

What you can do is create a client app to upload, that can collect the information you want from user's machine.
Another approach is to upload to the server, process the information you need to and then send it back to browser, but that may take a while and it won't be instant like after selection.
For a lib to work with video, haven't used any, but you can try VLC.NET and this in C#, for javascript i think it will be hard to find if there is any.

Related

File upload / did I make a mistake choosing vb.net instead of php?

for the past 3 days I've been trying to create an upload system for multiple files, possibly large, with progress bars.
I've been roaming the web relentlessly for the past few days, and I can say, I am now familiar with most difficulties.
sadly, all the solutions I've found online are not written c# or vbscript, in fact most of them are written in php.
I wouldn't mind switching to another language but the entire website is written in vb.net and for the sake of coherence I thought it might be best to keep with it.
File uploads:
Problem 1 - progress bar:
I understand file uploads will not work with ajax, since the ajax response will only occur after the file had completed its upload.
I understand there is a solution using iFrames but I cannot seem to find any online examples (preferably using vb.net or c#).
I understand there is another alternative using flash. how???
I also understand people are mostly against using iframes but I can't find what the reason might be.
Problem 2 - Multiple Files:
I can have multiple file support with HTML5. great, but IE doesn't support it? well... IE users will just have to upload one file at a time.
Problem 3 - Large files:
how?
I heard something about chunking, and blobs, but these are still just random gibberish words for me. can somebody explain, the meaning and the implementation?
references to reading material are much appreciated even though, if it's on the web, I've probably already read it in my search for my solution.
#DevlshOne has a decent thread with some good information.
Here are the three basic requirements for what I did:
Create Silverlight app for clientside access and upload control. (use app of your choice)
Create an HttpHandler to receive the data in chunks and manage requests.
Create the database backend to handle the files.
Silverlight worked well because I was already in VB (ASP.NET). When used in-browser, as opposed to out-of-browser, the ASP.NET session was shared with Silverlight, so there was no need to have additional security/login measures. Silverlight also allowed me to limit what file types could be selected and allow the user to select multiple files from the same folder.
The Silverlight app grabs the files selected by the user, displays them for editing of certain properties, and then begins the upload when the user clicks the 'upload' button. This sets off a number of threads that each upload chunks of data to the httphandler. The HttpHandler and Silverlight app send and receive in chunks, with the HttpHandler always sending an OK or ERROR message when the request has been processed for the uploaded chunk.
Our specific implementation of file uploading also required some database properties (fields) to be filled out by the user, so we also had inputs for those properties and uploaded them to the server with the file data.
An in-browser Silverlight app can also have parameters passed into it through the html, so I do this with settings like 'max chunk size' or 'max thread count'. I can change the setting in the database and have it apply to all users.
The database backend is basically a few stored procedures (insert your data management preference here) that control the flow of the logic. One table holds completed files (no file data), and a second holds the temp files that are in progress of being uploaded. One stored procedure initiates a new file record in the temp table and processes additional chunk uploads, and another controls the migration of the completely uploaded file from the temp table to the completed table. (A piece of VB code in the HttpHandler migrates the actual binary file data from the temp table to a physical file.)
This seems pretty complex, but the most difficult part would be the interaction with the handler and passing the chunks around (response/requests, uploading successive chunks, etc.). I left out a lot of information, but this is the basic implementation.

Including a .SWF file in a C# Webform

I'm currently working on a project where i need to include a application page for users. I need the users to access few .SWF flash games through this page. I created a folder named applications in the Application and imported the .SWF files into that. After that I tried directly linking them using a hyperlink on my page, but they don't seem to open :/
am i missing something? or is there something else i need to do before that?
Would really appreciate it if you can help
Thank you
I don't think you can just hyperlink to your .swf file. According to this site, and your using Dreamweaver or FrontPage, you can just insert it from the Insert menu (or something of the kind). If you aren't using either of those two, you can edit you .swf file in Flash and choose "Export as HTML" from the file menu (or where ever it is) and then just copy the source code of the resulting file to your webpage.
Normally, you should be able to open .swf files directly in your browser, although embedding the swf into your html is often a good idea, you don't have to.
If the url in your address bar shows an adress ending with '.swf' you can test if a swf has loaded by right clicking in your browser window, if you see the flash context menu (zoom in, zoom out, etc) Your swf has loaded.
If your swf has loaded, but nothing else happens, there can be many other reasons for this.
Where did you get the swf game files? If you copied them from another site it's very likely that the swf is supposed to load other files (game assets (images), settings (xml) etc) before the game can be played.
Sometimes the execution of (actionscript) code in a swf is triggered by script in the html page it is embedded in.
It's not entirely clear what you are trying to do....

how to play video from gridview?

i write a code using asp.net C# to generate a thumbnail when a video file selected using fileupload control, and display it in gridview. so, what i wanna do is when image in gridview was clicked, it should play the video corresponding to the video where the particular thumbnail is created without involving database?
There must be a Jquery plugin that solves the problem. I know there is many jQuery video plugins out there, just search for it. Why would you involve database? Can't you just include video files in your project and create a link from your images?
I dont know if this will solve your problem but worth checking out:
Simple jQuery video plugin
If you decide to use database I would suggest to keep it simple and use MySQL which is free and easy to setup.

Getting early control of a large file upload request

I need to create a proxy-like solution that "forwards" an uploaded file to somewhere else. The problem I am facing is that with large uploads the file needs to be fully uploaded before my forwarding code gets control of it in Page_Loaded of an ASP.NET application.
Is there a way to get control of a Stream of a file being uploaded as soon as the upload begins? The idea is to start forwarding as soon as first file bytes start coming in without waiting for the entire upload to finish.
Can IHttpModule be used to achieve this goal?
Some time ago, I had to deal with images and some heavy files upload. We used this project:
http://silverlightfileupld.codeplex.com/
It is basically a silverlight file uploader, we added some feautures like image compression. Also the key part, is that we used this uploader to send chunks of the file instead of the whole file, so the new file was recreated as a temp file and then renamed. Maybe you can follow that approach and in the ashx file, you can transfer the bytes to the real server.
Hope this helps

ASP.NET: How to send file from database to printer?

I have an ASP.NET 2.0 (C#) webpage with a link that pulls a blob from a MS SQL database and ouputs it in the appropriat file format, i.e., Word, WordPerfect, PDF.
My users would like to print these files with one click. Right now they have to click the link to open the file, then click the "Print" button within the application that they file opened.
In addition, I would like to send multiple documents to the printer, using one click, if possible.
Thanks.
Do you want to print to a Printer attached to the Server, or attached to the client?
If you want to print on the Client, you won't have much chance. For HTML Content, maybe some JavaScript or Flash could trigger the Print Dialog (not sure), but if it's a File that has to be opened in a third party application (i.e. PDF, DOC, XLS etc.), you're out of luck.
If it's an internal Network, you could possibly create a Desktop Application that is installed on every Client's PC that then triggers the Print.
If it is a Printer Attached to the Server, you can use the standard .net facilities for Printing, although you again may have to work around situations where you are trying to print PDF/DOC/XLS etc., because then you need to use Automation (either COM or something like SendKeys), which will cause you headaches on a Server.
So in Short: Not much you can do with only ASP.net at your disposal.
The closest I've gotten to this is using Javascript:
<body onload="window.print()">
...
</body>
which will pop-up the print dialog when the page loads (see this post for more). If you think about it, you probably won't be able to do much else unless you are on an internal network. How would you like your computer to start printing pop-ups "automatically"?

Categories

Resources