Website ‘Media Player’
Do any of you know if it is possible to make it so if any .wmv / .avi file is clicked on my website, it is automatically loaded either in that window, or in a popup.. instead of prompting user to download?
People upload files to my website, and want to be able to play the videos right on the site.. instead of having to download.
how the browser deals with .wmv/.avi files is up to the browser and the operating systems default file types. instead of linking directly to the file you can either embed it in the current page or you can have a javascript link that opens a new window with the file embedded in the popup.
i was hoping there may be a chance i could manipulate the way my website handles any url with *.wmv* in it.. maybe using the .htaccess… heh… guess i’ll have to do things the hard (right) way…
thanks
well you can link to a script that will output different headers and change the content-type while keeping the file as a wmv but that just helps the browser and OS know what to do with it. examples with php here:
ya but if you actually want it to play inside the browser you’ll have to embed it.
short of using a windows media player plugin, java applet, or flash you can’t guarantee that function. In the end, the browser decides how to handle it.
Use .htaccess to pass it through a PHP file that will properly embed it.
That’s what I am going to try do do..
[edit] i sucks, read next post [/edit]
Okie Dokie… I’m a little stuck (and off to bed so I have given up until tomorrow night after work)
Dumpy: (or anybody) … embedding into a php file is easy.. manually… how can I make it so clicking on ‘mysite.com/uploaded/ai2a/funnylol.avi’ will be rewritten to say… ‘mysite.com/streaming/video.php’ with the ‘funnylol.avi’ video embedded into it…
Or is that too dificult / too much work / not possible?
You want flash video, man. Its REALLY easy to create a playable .swf (flash) video if you have .flv video, or any kind of video for that matter. Get Flash (the program) and create videos to embed. It will even output the HTML to embed them for you, and you can easily set options for the player like audio controls, FF/rewind, etc.
Otherwise you just want to embed the video file in HTML. You do not need PHP.
Do this: <EMBED SRC="filename.???"></EMBED>
Look up the EMBED HTML docs.
Here’s an example of some audio: <embed width="200" height="30" src="http://dev.myapp.com/static/audio/bob/restaurant.wav"/>
|
You want flash video, man. Its REALLY easy to create a playable .swf (flash) video if you have .flv video, or any kind of video for that matter. Get Flash (the program) and create videos to embed. It will even output the HTML to embed them for you, and you can easily set options for the player like audio controls, FF/rewind, etc.
Otherwise you just want to embed the video file in HTML. You do not need PHP. Do this: <EMBED SRC="filename.???"></EMBED> Look up the EMBED HTML docs. Here’s an example of some audio: <embed width="200" height="30" src="http://dev.myapp.com/static/audio/bob/restaurant.wav"/> |
Converting to flv/swf is easy… my problem is I have people uploading .wmv, .avi, .mpg files, and I am trying to see if there is a way to redirect a direct URL if to something like > video.php having code in it to grab that video and play it…
I think I am complicating things too much.
|
Converting to flv/swf is easy… my problem is I have people uploading .wmv, .avi, .mpg files, and I am trying to see if there is a way to redirect a direct URL if to something like > video.php having code in it to grab that video and play it…
I think I am complicating things too much. |
Then I suggest you read my post again, because I included instructions for embedding any kind of video using HTML.
I can embed… my issue was the video is being uploaded, and the url to the file will cause the browser (most likely) to download it…
I sort of figured this out… but I am having a problem…
I wanted when a user clicked , it to load in an embedded html/php file…
The easiest way to do this I figured was using .htaccess…
I have a php file that when combined with … it plays it in the embedded page.
I then used a rewrite rule in .htaccess to rewrite the url to …
Anyway… the video isn’t loading when it is redirected using the .htaccess!!
RewriteRule (.+).avi http://www.mysite.com/video.php?vid=$1.avi [QSA,L]
*edited out website name because until i’m finished i dont want it published.
CLIFFS:
Embedded video = easy and works
Rewriting link to video to the embedded link = easy? and no works… WtF
I posted this on another forum a while back (so I may not stand by the exact wording, but overall, it’s still accurate)…
RewriteRule Okay, this is put into your .htaccess file, but CD forgot to mention that you need to turn on the rewrite engine. Options +FollowSymlinks RewriteEngine on Although, putting those in your .htaccess file may wind up being redundant if you’re on a shared server (since most shared hosts have already done it for you), it’s always good practice to do it since both commands MUST be passed in order for rewrite rules work. Moving on… RewriteRule = Begining of regex phrase (verbatim) = variable. You use this to call the variable created from . = just an example PHP with various GET options in the URL. Simply put, this can be anything your little heart desires. Another example would be: (assuming you have a file named viewfile.php and it is set up to $_GET["file"]). = No Case (case insensitive) So here’s another example: Options +FollowSymlinks RewriteEngine on RewriteRule ^files/(.+)$ view.php?file=$1 [NC,L] Everything that is in the directory "files" will be passed through view.php for processing. Obviously in here, I can put a border, create a HTML page, throw in some ads, etc. Love Always, |
So in your case, you’re going to want to go with:
Options +FollowSymlinks RewriteEngine on RewriteRule ^videos/(.+)$ videos.php?view=$1 [R,L]
That’s assuming your videos are contained in the videos subdirectory.
I noticed one funny thing about my post: I used [NC,L], which is contradictory. Like I put above, you’ll want to go with [Redirect,Last rule].
Here is the information on flags from Apache []:
Additionally you can set special flags for Substitution by appending
[flags]as the third argument to the RewriteRule directive. Flags is a comma-separated list of the following flags:
- ‘redirect|R [=code]‘ (force redirect)
Prefix Substitution with [:thisport]/ (which makes the new URL a URI) to force a external redirection. If no code is given a HTTP response of 302 (MOVED TEMPORARILY) is used. If you want to use other response codes in the range 300-400 just specify them as a number or use one of the following symbolic names: temp (default), permanent, seeother. Use it for rules which should canonicalize the URL and give it back to the client, e.g., translate “/~” into “/u/” or always append a slash to /u/user, etc.
Note: When you use this flag, make sure that the substitution field is a valid URL! If not, you are redirecting to an invalid location! And remember that this flag itself only prefixes the URL with [:thisport]/, rewriting continues. Usually you also want to stop and do the redirection immediately. To stop the rewriting you also have to provide the ‘L’ flag.- ‘forbidden|F‘ (force URL to be forbidden)
This forces the current URL to be forbidden, i.e., it immediately sends back a HTTP response of 403 (FORBIDDEN). Use this flag in conjunction with appropriate RewriteConds to conditionally block some URLs.- ‘gone|G‘ (force URL to be gone)
This forces the current URL to be gone, i.e., it immediately sends back a HTTP response of 410 (GONE). Use this flag to mark pages which no longer exist as gone.- ‘proxy|P‘ (force proxy)
This flag forces the substitution part to be internally forced as a proxy request and immediately (i.e., rewriting rule processing stops here) put through the . You have to make sure that the substitution string is a valid URI (e.g., typically starting with ) which can be handled by the Apache proxy module. If not you get an error from the proxy module. Use this flag to achieve a more powerful implementation of the directive, to map some remote stuff into the namespace of the local server. Notice: To use this functionality make sure you have the proxy module compiled into your Apache server program. If you don’t know please check whether mod_proxy.c is part of the “httpd -l” output. If yes, this functionality is available to mod_rewrite. If not, then you first have to rebuild the “httpd” program with mod_proxy enabled.- ‘last|L‘ (last rule)
Stop the rewriting process here and don’t apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL (‘/’) to a real one, e.g., ‘/e/www/’.- ‘next|N‘ (next round)
Re-run the rewriting process (starting again with the first rewriting rule). Here the URL to match is again not the original URL but the URL from the last rewriting rule. This corresponds to the Perl next command or the continue command from the C language. Use this flag to restart the rewriting process, i.e., to immediately go to the top of the loop.
But be careful not to create an infinite loop!- ‘chain|C‘ (chained with next rule)
This flag chains the current rule with the next rule (which itself can be chained with the following rule, etc.). This has the following effect: if a rule matches, then processing continues as usual, i.e., the flag has no effect. If the rule does not match, then all following chained rules are skipped. For instance, use it to remove the “.www” part inside a per-directory rule set when you let an external redirect happen (where the “.www” part should not to occur!).- ‘type|T=MIME-type‘ (force MIME type)
Force the MIME-type of the target file to be MIME-type. For instance, this can be used to simulate the mod_alias directive ScriptAlias which internally forces all files inside the mapped directory to have a MIME type of “application/x-httpd-cgi”.- ‘nosubreq|NS‘ (used only if no internal sub-request)
This flag forces the rewriting engine to skip a rewriting rule if the current request is an internal sub-request. For instance, sub-requests occur internally in Apache when mod_include tries to find out information about possible directory default files (index.xxx). On sub-requests it is not always useful and even sometimes causes a failure to if the complete set of rules are applied. Use this flag to exclude some rules.
Use the following rule for your decision: whenever you prefix some URLs with CGI-scripts to force them to be processed by the CGI-script, the chance is high that you will run into problems (or even overhead) on sub-requests. In these cases, use this flag.- ‘nocase|NC‘ (no case)
This makes the Pattern case-insensitive, i.e., there is no difference between ‘A-Z’ and ‘a-z’ when Pattern is matched against the current URL.- ‘qsappend|QSA‘ (query string append)
This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.- ‘noescape|NE‘ (no URI escaping of output)
This flag keeps mod_rewrite from applying the usual URI escaping rules to the result of a rewrite. Ordinarily, special characters (such as ‘%’, ‘$’, ‘;’, and so on) will be escaped into their hexcode equivalents (‘%25′, ‘%24′, and ‘%3B’, respectively); this flag prevents this from being done. This allows percent symbols to appear in the output, as in RewriteRule /foo/(.*) /bar?arg=P1%3d$1 [R,NE]which would turn ‘/foo/zed’ into a safe request for ‘/bar?arg=P1=zed’. Notice: The noescape flag is only available with Apache 1.3.20 and later versions.
- ‘passthrough|PT‘ (pass through to next handler)
This flag forces the rewriting engine to set the uri field of the internal request_rec structure to the value of the filename field. This flag is just a hack to be able to post-process the output of RewriteRule directives by Alias, ScriptAlias, Redirect, etc. directives from other URI-to-filename translators. A trivial example to show the semantics: If you want to rewrite /abc to /def via the rewriting engine of mod_rewrite and then /def to /ghi with mod_alias: RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghiIf you omit the PT flag then mod_rewrite will do its job fine, i.e., it rewrites uri=/abc/… to filename=/def/… as a full API-compliant URI-to-filename translator should do. Then mod_alias comes and tries to do a URI-to-filename transition which will not work. Note: You have to use this flag if you want to intermix directives of different modules which contain URL-to-filename translators. The typical example is the use of mod_alias and mod_rewrite..
- ‘skip|S=num‘ (skip next rule(s))
This flag forces the rewriting engine to skip the next num rules in sequence when the current rule matches. Use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes skip=N where N is the number of rules in the else-clause. (This is not the same as the ‘chain|C’ flag!)- ‘env|E=VAR:VAL‘ (set environment variable)
This forces an environment variable named VAR to be set to the value VAL, where VAL can contain regexp backreferences $N and %N which will be expanded. You can use this flag more than once to set more than one variable. The variables can be later dereferenced in many situations, but usually from within XSSI (via <!–#echo var="VAR"–>) or CGI (e.g. $ENV{‘VAR’}). Additionally you can dereference it in a following RewriteCond pattern via %{ENV:VAR}. Use this to strip but remember information from URLs.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.