Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
How to play a FLV on my web site at a given day and time

Reply  
Thread Tools
ericjw316's Avatar
Junior Member with 3 posts.
 
Join Date: Dec 2008
04-Dec-2008, 02:45 PM #1
How to play a FLV on my web site at a given day and time
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's Avatar
Junior Member with 18 posts.
 
Join Date: Dec 2008
Experience: Advanced
05-Dec-2008, 10:14 AM #2
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:
HTML Code:
 <head>
<script type="text/javascript">
    function CheckVid()
    {
      var start = Date.parse("Dec 15, 2008 20:0:0 CST");
      var end   = Date.parse("Dec 15, 2008 22:0:0 CST");
      var now   = new Date();
           
      if (now > start && now < end)
      {
        document.getElementById('video').innerHTML = "You can watch the video";
      }
      else
      {
        document.getElementById('video').innerHTML = "You cannot watch the video";
      }
    } 
    
    </script>
  </head>
  <body onload="CheckVid()">
    <div id="video">
      You must have Javascript enabled to view this video
    </div>
  </body> 
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 <object> 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 <body> tag and to make sure that you have a <div> (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's Avatar
Junior Member with 3 posts.
 
Join Date: Dec 2008
05-Dec-2008, 11:51 AM #3
Video code
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.



<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">
function CheckVid()
{
var start = Date.parse("Dec 5, 2008 08:00:00 CST");
var end = Date.parse("Dec 15, 2008 12:00:00 CST");
var now = new Date();

if (now > start && now < end)
{
document.getElementById('video').innerHTML = "You can watch the video";
}
else
{
document.getElementById('video').innerHTML = "You cannot watch the video";
}
}

</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body onload="CheckVid()">


<div id="video" align="center">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','600','height','338','id','video','src ','FLVPlayer_Progressive','flashvars','&MM_ComponentVersion=1&skinName=Coro na_Skin_3&streamName=final_tour_01&autoPlay=true&autoRewind=false','quality ','high','scale','noscale','name','FLVPlayer','salign','lt','pluginspage',' http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','FLVPlayer_Progressive ' ); //end AC code
</script>
<noscript>
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="338" id="video">
<param name="video" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=final_tour_ 01&autoPlay=true&autoRewind=false" />
<embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=final_t our_01&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="600" height="338" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />
</object>
</noscript>
</div>

</body>
</html>



Eric
BobFoster's Avatar
Junior Member with 18 posts.
 
Join Date: Dec 2008
Experience: Advanced
05-Dec-2008, 12:25 PM #4
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 <div id="video">###stuff###</div> 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 <object> 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

Last edited by BobFoster; 05-Dec-2008 at 12:26 PM.. Reason: typo
ericjw316's Avatar
Junior Member with 3 posts.
 
Join Date: Dec 2008
05-Dec-2008, 12:35 PM #5
How would i copy the code into the java script? is it just a single ' in stead of the "?
BobFoster's Avatar
Junior Member with 18 posts.
 
Join Date: Dec 2008
Experience: Advanced
05-Dec-2008, 02:09 PM #6
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
Reply

Tags
flv, play website video, video, website video

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:01 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.