 |
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |

08-06-2008, 09:44 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
Coding Guru needed, HELP!
I work at a local newspaper which is beginning to host news videos with their editorials. The videos are being called in with iframes, the videos are on html pages in a sub folder.
we want to begin putting commercials in the beginning of the videos
THIS IS THE TRICKY PART
We want commercial A to play on news video A on Html A, once Html "A" page has hit 1000 page loads, we would like to disable html A and begin loading html B which will play another video, once this hits 1000 page loads we would like to disable video B and load C and so forth
is there a javascript that can disable a page and load another, maybe in conjunction with an xml list.
Please keep in mind that it is all called into one iframe, wich will relay all these changes.
Please help, thanks!
|

08-06-2008, 10:38 AM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
Well, if you don't want to put the commercial into the video, or do a flash/silverlight script which automatically changes the commercial to the video, then you would need to know the exact time of the commercial.
So, what you would do is just a HTTP-META-REFRESH tag on the commercial html page.. after it hits say 30 seconds (if the commercial is 30 seconds), then it will transfer to the video.
If you are assembling this all by XML, which is good, all you need to be able to do is update the XML file with the person who hit it and keep adding the count, from there, you can determine which commercial to go to.
Not possible with Javascript to edit a file on a server, but it is rather easy with Server Side code (ASP.NET, PHP, etc)
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-06-2008, 11:57 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
actually the commercial is already rendered before the video so it's one file.
Essentially what im looking for is once html A is loaded 20 times, it disables, then we want html B to load 20 times, then disable and go to the next video and so forth.
so this would require php or asp? or can an xml simply swap this transition out?
we are trying to make this so that our online writer doesnt have to keep track of all the hits and swap it all out
thank you so much for your insight thus far!
|

08-06-2008, 12:01 PM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
Right, JavaScript cannot edit files. So, you could do this all via an XML file. You just need to write a simple script back end that will append to this XML file everytime it is reached to update the count on the commercial. So, once it hits 20, the script will see that and then tell the HTML to render the next commercial instead.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-06-2008, 12:08 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
oh great!
any leads to where i might be able to find something like this? which language would handle it better?
im not too well adept with server side languages.
do you know of any simple scripts?
|

08-06-2008, 01:01 PM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
PHP is the most lightweight for this kind of situation.
Do you know what your server operating system is? Windows or Linux?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-06-2008, 01:47 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
yes im on a windows back end.
|

08-06-2008, 01:47 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
actually my mistake i have newfirms which is unix. i think its both windows and linux.
|

08-06-2008, 01:51 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
*netfirms
|

08-06-2008, 02:02 PM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
So, it probably supports and has PHP compiled and running, correct?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-06-2008, 02:07 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
yes it does support php
|

08-06-2008, 02:36 PM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
Okay, then you could write a simple script using the fopen and fwrite commands for XML.. or use the XML functions, whichever.
Do you need an example?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-06-2008, 03:16 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
an example would be great!
ideally this will show through an iframe on our homepage
then it would point to a sub folder of 3 html pages with 3 different videos, each will expire after 20 loads in the list
thank you so much!
|

08-07-2008, 08:54 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
any luck izzmo?
|

08-07-2008, 09:02 AM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
Yes, I've been working on this morning
Hopefully you have PHP 5?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-07-2008, 09:32 AM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
Okay
So, here is a really brief example.
What happens is everytime you access the XML file (with an id attached to it) it will update the hits on that id. So, when you want to access a video, you can pull the url down and also update the hits.
Hopefully this is what you needed!
Here is the XML file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<items>
<item name="1">
<url>http://www.yoursite.com/videos/com1.wmv</url>
<hits>19</hits>
</item>
<item name="2">
<url>http://www.yoursite.com/videos/com2.wmv</url>
<hits>1</hits>
</item>
<item name="3">
<url>http://www.yoursite.com/videos/com3.wmv</url>
<hits>0</hits>
</item>
</items>
</rss>
Here is the PHP file
PHP Code:
<?php
$fid = (Int)$_GET["id"];
$element = (String)"";
$eid = (Int)0;
$xr = new XMLReader();
$xr->open("http://www.yoursite.com/feed.xml", "UTF-8");
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument("1.0", "UTF-8");
while($xr->read())
{
switch($xr->nodeType)
{
case XMLReader::ELEMENT:
$xw->startElement($xr->name);
$element = $xr->name;
$element_string = (String)"";
if(!$xr->isEmptyElement)
$element_string = $xr->value;
if($xr->hasAttributes)
{
while($xr->moveToNextAttribute())
{
if($xr->name == "name")
$eid = $xr->value;
$xw->writeAttribute($xr->name, $xr->value);
}
}
$xw->text($element_string);
break;
case XMLReader::TEXT:
case XMLReader::CDATA:
if($fid == $eid && $element == "hits")
$xw->text($xr->value + 1);
else
$xw->text($xr->value);
break;
case XMLReader::SIGNIFICANT_WHITESPACE:
case XMLReader::WHITESPACE:
$xw->text($xr->value);
break;
case XMLReader::END_ELEMENT:
$xw->endElement();
break;
}
}
$xw->endDocument();
Header("application/xml");
$handle = fopen("feed.xml", "w");
fwrite($handle, $xw->outputMemory(true));
fclose($handle);
?>
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

08-07-2008, 10:15 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-24-08
Posts: 70
|
|
|
WOW thank you.
Im sorry but how would i implement this? I go server side with my html iframe page, my php document and my videos. is it then working from there.
thanks again for your time and efforts!
|

08-07-2008, 12:38 PM
|
 |
v7n Mentor
|
|
Join Date: 11-01-03
Location: Kansas City
Posts: 1,347
|
|
|
That's just an example, not a pure implementation for you. You would have to tweak it.
But essentially, figure out what you need to pull out from the XML sheet (and populate it before hand) and then use that script to update it.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:23 AM.
© Copyright 2010 V7 Inc Powered by vBulletin Copyright © 2000-2010 Jelsoft Enterprises Limited.
|
|
|