# How to play a FLV on my web site at a given day and time



## ericjw316 (Dec 4, 2008)

I was wondering if any one would know how to set a FLV to play on a given date and time example 12/15/08 start at 8:00 pm cst. 

I can set a video to be a progressive download and let anyone come in to the page and watch the video but is there a way with out going through a flash server to set up the file to only play from 8 pm to 10 pm on the given day?

If you know how to do this let me know.


----------



## BobFoster (Dec 5, 2008)

If you are using a dynamic HTML system, such as ASP or PHP, you should be able to have the server do this quite easily (and if you have any security concerns about having the video played outside your timeframe, you should definitely try to do it this way). If you tell us what you have, I'm sure someone could help with some code.

However, I suspect you are just using ordinary HTML pages and, if so, you can do this with javascript.

Try this:

```
You must have Javascript enabled to view this video
```
The two assigned strings in the if...else statement ("You can / cannot watch the video") can be changed for any HTML, so you can use the first to put your tag in and the second to put alternative text (or a different object) for those viewing the page outside your timeframe. Obviously, this is just skeleton code - the important thing is to have the "onload" event trigger in the tag and to make sure that you have a (or other tag) with an "id=video" attribute.

There are some things to be aware of.


Anyone viewing the souce code of the web page will easily be able to download the video whether or not they are accessing your site within your timeframe.


Those with javascript turned off (or not present in the browser) won't ever see the film. But I can't imagine who would have a flash player installed in a browser with JS disabled.


You should find that timezones are taken account of, but anyone who has their clock set incorrectly (either the time or the timezone is wrong) will not have access to the video during the correct period. This is an unavoidable consequence of relying on the user's clock, which is all you can do in Javascript.

Hope this helps!

Regards,
Bob


----------



## ericjw316 (Dec 4, 2008)

If anyone could look at the code and let me know what i am doing wrong. I get the message saying i can play the video but than it doesn't allow me to video the video on this page. Also if anyone knows how to play a video with a the skin, play pause buttons that would also be a help.

Untitled Document

Eric


----------



## BobFoster (Dec 5, 2008)

I can't help you with the video player, but I probably should have explained my JS a bit better.

In your page, you have the ###stuff### pair of tags. The Javascript I gave you actually replaces anything that is between those tags with whatever you want; in the case of the example I posted, it replaces it with the text "You can watch the video". This means that most of the stuff in the code you've pasted in your last post is removed! What you are actually doing is rewriting the HTML on the fly.

What you need to do is put the HTML you are using to play the video (the tag and the script to check if Flash is installed) in the JS function instead of the "You can watch the video" text (but still inside the inverted commas).

Since there are several lines, you migh come across the problem that JS doesn't usually let you continue a string onto a new line. Use a "\" character on it's own at the end of each line and you will be fine - this isn't included in the string but tells JS to treat the next line as a part of the same string. The term for this is usually a "continuation character".

For example:

document.getElementById('video').innerHTML = "This line is \
split into two."

will work.

Regards,
Bob


----------



## ericjw316 (Dec 4, 2008)

How would i copy the code into the java script? is it just a single ' in stead of the "?


----------



## BobFoster (Dec 5, 2008)

When you need to put a character in a string that JS will recognise as a string terminator (specifically " or '), you need to "escape" it.

You use the same character (\) that you use to indicate a new line before each inverted comma:

SomeString = "Place your name in the \"hat\".";

However, you could have written this as:

SomeString = 'Place your name in the "hat".';

' and " are interchangeable as string delimiters (but you must use the same one to start and finish any given string) and if you only need one type in the string, use the other sort to delimit it: if you enclose your string in 's, "s are okay in the string and vice versa.

If you need a \ itself, just use two together: \\.

There are a number of places in your HTML that you have got " where ' will also do (or vice versa) so you will make things easier if you change all of your "s to 's (or vice versa).

I realise your string is quite complicated (and it's probably going to take a while to get it this to work), but I can't think of a better way of doing it. There is a method that involves using CDATA (an XML directive), but it is complicated in itself and won't work in all browsers. I don't know anything about it either, so you will need some help from somebody else.

Bob


----------

