Video Player

By James Kanjo James Kanjo

Description

With the traditional Video Player, you need to manually inject your video's url into the html code. This also means you need an individual code block for each song you want to play.

This is very tedious, and frankly, too complicated for less advanced users. So I've expanded upon the original code, and made it possible to dynamically play videos as specified in the URL:

This is the code that does all of the hard work. You should never need to use this code.

<html><head><metahttp-equiv="Content-Type"content="text/html; charset=iso-8859-1"/><title>Video Player</title><!-- © James Kanjo 2009 --></head><body><scripttype='text/javascript' src='http://snippets.wdfiles.com/local--files/code:video/swfobject.js'></script><scripttype="text/javascript">
 var url_params = /^#([^#]*)(#autoplay)?$/;
 var match = url_params.exec(unescape(window.location.hash));
 
 if (match) {
 document.write('<pid="preview"><i>Flash has been disabled, or is not installed. This video player requires <atarget="_blank"href="http://get.adobe.com/flashplayer/">Flash</a> to function.</i></p>');
 
 var s1 = new SWFObject('http://snippets.wdfiles.com/local--files/code:video/player.swf','player','400','300','9');
 s1.addParam('allowfullscreen','true');
 s1.addParam('allowscriptaccess','always');
 if (match[2]) {
 match[1] = match[1] + '&autostart=true';
 }
 s1.addParam('flashvars','file=' + match[1]);
 s1.write('preview');
 }
 else {
 document.write('<i>Invalid URL syntax</i>');
 }
 </script><noscript><i>Your Javascript has been disabled. This video player requires Javascript to function.</i></noscript></body></html>

Don't worry if looking at that scares you. You actually don't need to use it in your wiki at all.

Code

The video player can play *.flv files and H.264 encoded files.

[[iframe http://snippets.wdfiles.com/local--code/code:video#VIDEO-URL frameborder="0" scrolling="no" height="320px" width="440px"]]

To make the player automatically start playing when the page loads, just append #autoplay to the video's URL. For example:

[[iframe http://snippets.wdfiles.com/local--code/code:video#http://squark.wdfiles.com/local--files/dev:9/video.flv#autoplay frameborder="0" scrolling="no" height="320px" width="440px"]]

In action

[フレーム]


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by James Kanjo


Rate this solution

If you think this solution is useful — rate it up!

rating: +7
Video size
UVM UVM 18 Sep 2010 15:07

It seems the height and width options don't work. Any ideas? Also, is there a way to force the video to start in full screen mode? I've got a video running for my upcoming Haunted House volunteer project.

Thanks,

George
United Volunteers of Maine

See our Haunted House info at: http://uvm.wikidot.com/projects-hh/

by UVM UVM , 18 Sep 2010 15:07
Thanks everyone...
HobStarCS HobStarCS 21 Apr 2010 23:27

I can create the same video as a avi, perhaps I could upload that to Youtube and embed from there?

- Rob, which SWF/FLV player do you use?

~ Paul

by HobStarCS HobStarCS , 21 Apr 2010 23:27
Something not working right.
HobStarCS HobStarCS 21 Apr 2010 15:30

It seems to be having problems playing my .swf file. When you click play to says '10' with the spinning circle, nothing happens.

Template: http://hobstarcs.wikidot.com/video:_template
In action: http://hobstarcs.wikidot.com/video:1
Actual file: http://hobstarcs.wikidot.com/local--files/video/How-To-Upload_Images.swf

File seems to be fine, need a little help please. :)

by HobStarCS HobStarCS , 21 Apr 2010 15:30
Re: Something not working right.
(account deleted) 21 Apr 2010 16:17

It would be easier to help if you had page options turned on so we could view source, files, etc.. In looking at the HTML source, I see you're using a SWF instead of an FLV. Most SWF files require a separate FLV file unless you create the SWF so it has the video and player in the same file. I also found a small typo when viewing the HTML source:

<iframe src="http://snippets.wdfiles.com/local--code/code:video#http://hobstarcs.wikidot.com/local--files/video/How-To-Upload_Images.swf" align="" frameborder="0" height="400px&quot;" scrolling="no" width="500px" class="" style=""></iframe>

There's an extra &quot; in the height parameter. I doubt that's breaking things, but you never know…

I can try this later today with a variety of SWF/FLV files to see if I can narrow it down.

-Ed

by (account deleted), 21 Apr 2010 16:17
Re: Something not working right.
RobElliott RobElliott 21 Apr 2010 21:34

I downloaded the swf to my site and tried to play it with the SWF/FLV player I normally use (I don't use James' snippet). However I am getting an error message from Flash Player 10 so something seems to be wrong with the source. You might try re-creating the swf file if you can.


Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.

by RobElliott RobElliott , 21 Apr 2010 21:34
HobStarCS HobStarCS 22 Oct 2009 00:40

Great,

Used to good effect here (click on "▼ Upload Images, How To" to view)

by HobStarCS HobStarCS , 22 Oct 2009 00:40
page revision: 19, last edited: 16 Feb 2012 01:50
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /