Jun. 10, 2007andersen
how about a thread to collect solutions not questions!
heres some [url=http://home5.inet.tele.dk/nyboe/flash/mediaplayer/]demos[/url] for inspiration, to begin with...
Jun. 11, 2007Will
I think this is a very good idea, because the other threads have so much discussion and off topic posts that it would be very difficult for a new user to find the solution.
The "fix" for IE not displaying (add "width" and "height" flashvars) is a good example. It is now in 4 or 5 threads, mixed with other stuff.
It could be just one short post.
Do this:
so.addVariable('width', '320');
so.addVariable('height', '240');
Another example is the ""MONSTER"" thread "How to prevent downloading and leeching", which is now at 260 posts. There are some solutions in that thread, but no new user is going to read through that thread and come away anything but cOnFuSeD.
Jun. 11, 2007Will
And how about one on "How to get help".
"It doesn't work" doesn't work.
A couple of simple instructions:
1. Post your code.
2. Post a link.
3. What, very specifically, doesn't work.
Jun. 11, 2007andersen
when playing files on windows machines locally in internet explorer
it can be helpful to include the microsoft specific [url=http://msdn2.microsoft.com/en-us/library/ms537628.aspx]MOTW[/url]:
<!-- saved from url=(0014)about:internet -->in the head of the html, to prevent the yellow security bar
also renaming the .htm or .html file to .hta gives more rights to the player...
Jun. 13, 2007Eugenio
Is .hta only for Windows platform? I couldn't use it on Linux.
Jun. 13, 2007andersen
yes,- .hta is windows specific im afraid...
Jun. 13, 2007Will
MOTW = Mark Of The Web
Sounds kind of ominous to me... :@
Jun. 13, 2007andersen
i can only agree! - but now its there...
Jun. 15, 2007JeroenW
Will and andersen: great idea, this thread! If we have gathered the most asked for solutions here, I can build this into a FAQ and place it on top of the forum's thread lists.
* common error with embedding: the swfobject.js file isn't referred in the HTML's header or it isn't even copied at all.
* and the hints at the bottom of the readme also are a small FAQ in itself. I can copy them to a separate FAQ as well.
Jun. 15, 2007Will
@Jeroen,
Ok, I'll start posting the frequently asked for solutions here. For example, adding height & width to the flashvars for IE.
Jun. 15, 2007Will
For RTMP streams, the location is the URL to the stream.
It looks like a path to a directory, but it isn't, it's to the stream source. On Flash Media Server it looks like this: (real, live, working demo)
<track> <!-- FMS streaming video -->
<title>on2 demo</title>
<creator>FMS RTMP Streaming</creator>
<location>rtmp://flash-r1.vitalstreamcdn.com/on2_vitalstream_com/_definst_</location> (no trailing slash, never, ever)
<identifier>falling_hare_600_480x320_CBR</identifier> (no leading slash)
<meta rel="type">rtmp</meta>
</track>
Common variations of the <identifier> tag:
<identifier>my/files/falling_hare_600_480x320_CBR</identifier>
<identifier>falling_hare_600_480x320_CBR.flv</identifier> (Red5 only ,not FMS)
<identifier>song1.mp3</identifier> (must have extension if MP3)
Since the <location> tag only points to the stream source, something else has to tell the server which file to stream. That's where the <identifier> tag comes into use. The identifier tag is the filename with/without an extension and with/without a leading path. Then, the type (which may be optional) tells the player to expect an RTMP stream. I say may be optional because Jeroen, in another thread, said that the player can tell that it is an RTMP stream because of the protocol "rtmp://" in the <location> tag.
Jun. 15, 2007Will
Using "force_download.php".
The <info> tag should contain a link to the "force_download.php" file with the media file as a variable, like this:
<info>http://www.livingfaithchristiancenter.org/media/force_download.php?file=2007-6-6.mp3</info>
A quick test shows that this works:
http://my.domain.com/path-to-file/force_download.php?file=song4.mp3
Where file= can be a media file in the same directory as force_download.php or in a sub-directory ONLY below the directory where force_download.php resides. In which case, the <info> link might look like this:
<info>http://www.livingfaithchristiancenter.org/media/force_download.php?file=music/2007-6-6.mp3</info>
where music is a sub-directory of media.
Jun. 16, 2007Will
Standalone CD Slideshow from Image Rotator
Have You ever wanted to make a standalone CD slideshow? Here's how to do it, using Image Rotator.
You need these files:
1. imagerotator.swf
2. swfobject.js
3. playlist.xml (example below)
4. index.html (example below)
5. autorun.inf (example below)
6. autorun.bat (example below)
7. Your image files (any supported type, GIF, SVG, PNG, JPG)
Burn all of the files to a CD. That's it!
playlist.xml
<?xml version="1.0" encoding="UTF-8"?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<title>Sample PHP Generated Playlist</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One Title</title>
<creator>Image One Creator</creator>
<location>Image One.png</location>
</track>
<track>
<title>Image Two Title</title>
<creator>Image Two Creator</creator>
<location>Image Two.jpg</location>
</track>
<track>
<title>Image Three Title</title>
<creator>Image Three Creator</creator>
<location>Image Three.gif</location>
</track>
</trackList>
</playlist>
index.html
<html>
<head>
<title>Standalone CD Slideshow from Image Rotator</title>
<script type="text/javascript" src="swfobject.js">
</script>
</head>
<body>
<center>
<div id="player">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a>
to see this player.
</div>
<script type="text/javascript">
var s1 = new SWFObject('imagerotator.swf', 'playlist', '1024', '768', '7');
s1.addVariable('width', '1024');
s1.addVariable('height', '768');
s1.addVariable('rotatetime', '20');
s1.addVariable('shuffle', 'true');
s1.addVariable('repeat', 'true');
s1.addVariable('transition', 'slowfade');
s1.addVariable('file', 'playlist.xml');
s1.write('player');
</script>
</center>
</body>
</html>
Adjust height & width to suit your images; adjust shuffle, repeat, transition, and repeat to suit your taste.
autorun.inf
[autorun]
open=autorun.bat
autorun.bat
@echo Loading CD
@start index.html
@cls
@exit
Jun. 16, 2007andersen
@Will
nice! - one question: is the CD Slideshow autorun also valid for mac and linux?
(if not, what would it take?)
Jun. 16, 2007Will
@andersen,
Very good question. This [url=http://research.silmaril.ie/autoruncd/]Creating a multiplatform autorun CD[/url] seems to be the answer. They use an Open Source program [url=http://freshmeat.net/projects/mkisofs/]mkisofs[/url] to do the configuration.
It looks almost the same for *nix, shell script instead of a batch file, Macs don't need anything because the program recommended in the article referenced above does the trick.
Jun. 16, 2007Will
The same basic setup could be used for self-playing videos or MP3s. As soon as Jeroen finishes the audio track for the Image Rotator, I'm going to add audio to the disk I made. It's great for the senior family members who aren't too computer savvy. Instructions are, "Just Insert This Disk".
Jun. 16, 2007Will
On-The-Fly FLV Preview Image Generator
Inspired by a recent post of an image generator for *nix, I decided to make one for Windows.
This short PHP script uses ffmpeg [url=http://ffdshow.faireal.net/mirror/ffmpeg/](Windows binaries)[/url] to generate an image from a frame of an FLV video on-the-fly and returns it to the player. Or you can save the image and call it when needed.
Use a couple of lines of PHP to overlay some text and you could have a custom preview image. If someone desperately needs that I could be persuaded to add that to the image generator. Send it some text and the image will be returned with that text overlaid on the image.
There's one small bug in the script. I can't get it to send the image directly to a requesting player - it has to be used in a playlist until I sort that out.
Call it from a playlist like this:
<image>http://my.domain.com/path-to-file/ffmpeg_image.php?file=video.flv&time=00:00:15&browser=true</image>
If you call it from a browser or the commandline with "browser=false", the image will be saved instead of being returned. Images are named like this:
Video File: video.flv
Image File: video1.png
The image generator can also make jpg images; at the bottom of the
script, comment out the png lines and uncomment the jpg lines (3 of each).
ffmpeg_image.php
<?php
// generate a preview image from an FLV file on-the-fly, or to save
// Will - 06-16-07
// call with: ffmpeg_image.php?file=video.flv&time=00:00:05&browser=true
// no time defaults to "00:00:00" (first frame), no browser defaults to "true"
if (isset($_GET['file']))
{
$videofile = $_GET['file'];
$image = substr($videofile, 0, strlen($videofile) - 4);
}
// debug (" File: ", $file);
// debug (" Image: ", $image);
if (isset($_GET['time']))
{
$time = $_GET['time'];
// check time format here
if (!preg_match('/\d\d:\d\d:\d\d/', $time))
{
$time = "00:00:00";
}
}
// debug (" Time: ", $time);
$browser = "true";
if (isset($_GET['browser']))
{
$browser = $_GET['browser'];
}
// debug ("Browser: ", $browser);
if ($browser == "true")
{
header('Content-Type: image/png');
passthru("\"C:/path-to-ffmpeg/ffmpeg.exe\" -vcodec png -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 -");
// header('Content-Type: image/jpeg');
// passthru("\"C:/path-to-ffmpeg/ffmpeg.exe\" -vcodec mjpeg -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 -");
}
else
{
passthru("\"C:/path-to-ffmpeg/ffmpeg.exe\" -vcodec png -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 " . $image . "%d.png");
// passthru("\"C:/path-to-ffmpeg/ffmpeg.exe\" -vcodec mjpeg -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 " . $image . "%d.jpg");
}
function debug($text1, $text2)
{
print "<pre>\n";
print $text1 . $text2 . "\n";
print "</pre>\n";
}
?>
Jun. 18, 2007Will
You can use two Media Players on the same page to:
1. Display images (MP1-playlist1)
2. Display captions (MP1-Playlist1 - captions files - each item on the playlist can have its own captions file)
3. Play a commentary file (MP1-playlist1)
4. Play background music (MP2-playlist2)
Alternately, if you want to use the Image Rotator to display the images, so you can use the transition and other effects, you can use one Image Rotator to display the images and play the background music, and one Media Player to display the captions just below the images and play the commentary audio. I provide code for each below.
1. Display images (IR-playlist3)
2. Display captions (MP-playlist4 - captions files - each item on the playlist can have its own captions file)
3. Play a commentary file (MP-playlist4)
4. Play background music (IR-playlist3)
Both Media Players or the Image Rotator/Media Player combo each have their own playlists, further increasing the possibilities.
Sample page code for two Media Players:
[/code]
<html>
<head>
<title>Two Media Players</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="player1">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var so = new SWFObject('mediaplayer.swf', 'player', '640', '480', '7');
so.addParam('allowfullscreen', 'false');
so.addVariable('file', 'playlist1.xml');
so.addVariable('width', '640');
so.addVariable('height', '480');
so.addVariable('displayheight', '480');
so.addVariable('autostart', 'true');
so.addVariable('repeat', 'true');
so.addVariable('rotatetime', '20');
so.addVariable('shuffle', 'false');
so.addVariable('useaudio', 'true');
so.addVariable('usecaptions', 'true');
so.write('player1');
</script>
<div id="player2">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
//var sx = new SWFObject('mediaplayer.swf', 'player', '1', '1', '7');
//sx.addVariable('width', '1');
//sx.addVariable('height', '1');
var sx = new SWFObject('mediaplayer.swf', 'player', '640', '20', '7');
sx.addVariable('width', '640');
sx.addVariable('height', '20');
sx.addVariable('displayheight', '0');
sx.addVariable('file', 'playlist.xml');
sx.addVariable('autostart', 'true');
sx.addVariable('repeat', 'true');
sx.write('player2');
</script>
</body>
</html>
[/code]
You can make the second player "disappear" by uncommenting the three commented lines and commenting or deleting the corresponding lines that set the width to 640 and the height to 20.
Sample page code for one Image Rotator and one Media Player:
<html>
<head>
<title>Image Rotator and Media Player</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="player1">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var so = new SWFObject('imagerotator.swf', 'player', '640', '480', '7');
so.addParam('allowfullscreen', 'false');
so.addVariable('file', 'playlist3.xml');
so.addVariable('width', '640');
so.addVariable('height', '480');
so.addVariable('displayheight', '480');
so.addVariable('overstretch', 'false');
so.addVariable('autostart', 'true');
so.addVariable('repeat', 'true');
so.addVariable('rotatetime', '20');
so.addVariable('shuffle', 'false');
so.addVariable('useaudio', 'true');
//so.addVariable('kenburns', 'true');
so.addVariable('transition', 'slowfade');
so.addVariable('shownavigation', 'false');
so.addVariable('backcolor', '0x000000');
so.addVariable('linkfromdisplay', 'true');
so.write('player1');
</script>
<div id="player2">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var sx = new SWFObject('mediaplayer.swf', 'player', '640', '80', '7');
sx.addVariable('width', '640');
sx.addVariable('height', '80');
sx.addVariable('displayheight', '60');
sx.addVariable('file', 'playlist4.xml');
sx.addVariable('autostart', 'true');
sx.addVariable('repeat', 'true');
sx.addVariable('rotatetime', '20');
sx.write('player2');
</script>
</body>
</html>
Sample captions1.xml
<tt xml:lang="en" xmlns="http://www.w3.org/2006/10/ttaf1" xmlns:tts="http://www.w3.org/2006/10/ttaf1#style">
<head>
</head>
<body tts:extent="640px 460px" xml:id="b1">
<div xml:id="d1" begin="11s" dur="8s">
<p xml:id="p1" region="r1"><![CDATA[<font size="9">I'm findin' out how hot an old flame can burn,]]></p>
</div>
<div xml:id="d2" begin="20s" dur="4s">
<p xml:id="p2" region="r1"><![CDATA[<font size="9">You're a feeling I haven't forgot,]]></p>
</div>
<div xml:id="d3" begin="25s" dur="4s">
<p xml:id="p3" region="r1"><![CDATA[<font size="9">A love I can't unlearn,]]></p>
</div>
<div xml:id="d4" begin="30s" dur="7s">
<p xml:id="p4" region="r1"><![CDATA[<font size="9">You've become a memory I can't live without,]]></p>
</div>
<div xml:id="d5" begin="38s" dur="6s">
<p xml:id="p5" region="r1"><![CDATA[<font size="9">You'll always be a fire I can't put out.]]></p>
</div>
<div xml:id="d6" begin="47s" dur="3s">
<p xml:id="p6" region="r1"><![CDATA[<font size="9">I don't know how to handle,]]></p>
</div>
<div xml:id="d7" begin="51s" dur="4s">
<p xml:id="p7" region="r1"><![CDATA[<font size="9">The dream you left behind,]]></p>
</div>
<div xml:id="d8" begin="56s" dur="3s">
<p xml:id="p8" region="r1"><![CDATA[<font size="9">It's like a lighted candle,]]></p>
</div>
<div xml:id="d9" begin="60s" dur="5s">
<p xml:id="p9" region="r1"><![CDATA[<font size="9">Burnin' up my mind,]]></p>
</div>
<div xml:id="d10" begin="67s" dur="9s">
<p xml:id="p10" region="r1"><![CDATA[<font size="9">At least I'm happy knownin' what love's all about,]]></p>
</div>
<div xml:id="d11" begin="77s" dur="4s">
<p xml:id="p11" region="r1"><![CDATA[<font size="9">You'll always be a fire I can't put out.]]></p>
</div>
<div xml:id="d12" begin="96s" dur="7s">
<p xml:id="p12" region="r1"><![CDATA[<font size="9">Embers to ashes, that's how it could be,]]></p>
</div>
<div xml:id="d13" begin="104s" dur="8s">
<p xml:id="p13" region="r1"><![CDATA[<font size="9">You'd think by now my heart would know, that it could set me free]]></p>
</div>
<div xml:id="d14" begin="113s" dur="4s">
<p xml:id="p14" region="r1"><![CDATA[<font size="9">Things I've tried, tears I've cried,]]></p>
</div>
<div xml:id="d15" begin="118s" dur="4s">
<p xml:id="p15" region="r1"><![CDATA[<font size="9">I guess there's no doubt,]]></p>
</div>
<div xml:id="d16" begin="122s" dur="6s">
<p xml:id="p16" region="r1"><![CDATA[<font size="9">You'll always be a fire I can't put out.]]></p>
</div>
<div xml:id="d17" begin="131s" dur="3s">
<p xml:id="p17" region="r1"><![CDATA[<font size="9">I don't know how to handle,]]></p>
</div>
<div xml:id="d18" begin="135s" dur="4s">
<p xml:id="p18" region="r1"><![CDATA[<font size="9">The dream you left behind,]]></p>
</div>
<div xml:id="d19" begin="140s" dur="4s">
<p xml:id="p19" region="r1"><![CDATA[<font size="9">It's like a lighted candle,]]></p>
</div>
<div xml:id="d20" begin="145s" dur="5s">
<p xml:id="p20" region="r1"><![CDATA[<font size="9">Burnin' up my mind,]]></p>
</div>
<div xml:id="d21" begin="152s" dur="8s">
<p xml:id="p21" region="r1"><![CDATA[<font size="9">At least I'm happy knownin' what love's all about,]]></p>
</div>
<div xml:id="d22" begin="161s" dur="7s">
<p xml:id="p22" region="r1"><![CDATA[<font size="9">You'll always be a fire I can't put out.]]></p>
</div>
<div xml:id="d22" begin="169s" dur="8s">
<p xml:id="p22" region="r1"><![CDATA[<font size="9">You'll always be a fire I can't put out.]]></p>
</div>
</body>
</tt>
Sample playlist1.xml (Media Player 1 - Images, captions, and commentary audio)
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Media Player 1 - Images, Captions and Commentary Audio</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One</title>
<creator>Myself</creator>
<location>commentary1.mp3</location>
<image>background-1.png</image>
<link rel="captions">captions1.xml</link>
</track>
<track>
<title>Image Two</title>
<creator>Myself</creator>
<location>commentary2.mp3</location>
<image>background-2.png</image>
<link rel="captions">captions2.xml</link>
</track>
<track>
<title>Image Three</title>
<creator>Myself</creator>
<location>commentary3.mp3</location>
<image>background-3.png</image>
<link rel="captions">captions3.xml</link>
</track>
<track>
<title>Image Four</title>
<creator>Myself</creator>
<location>commentary4.mp3</location>
<image>background-4.png</image>
<link rel="captions">captions4.xml</link>
</track>
<track>
<title>Image Five</title>
<creator>Myself</creator>
<location>commentary5.mp3</location>
<image>background-5.png</image>
<link rel="captions">captions5.xml</link>
</track>
</trackList>
</playlist>
Sample playlist2.xml (Media Player 2 - background music)
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Media Player 2 - Background Music</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Song One</title>
<creator>Myself</creator>
<location>song1.mp3</location>
</track>
<track>
<title>Song Two</title>
<creator>Myself</creator>
<location>song2.mp3</location>
</track>
<track>
<title>Song Three</title>
<creator>Myself</creator>
<location>song3.mp3</location>
</track>
<track>
<title>Song Four</title>
<creator>Myself</creator>
<location>song4.mp3</location>
</track>
<track>
<title>Song Five</title>
<creator>Myself</creator>
<location>song5.mp3</location>
</track>
</trackList>
</playlist>
Sample playlist3.xml (Image Rotator - images and background music)
Note: The Background Music is the same for every track; it repeats as necessary.
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Image Rotator - Images and Background Music</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One</title>
<location>background-1.png</location>
<link rel="audio">song1.mp3</link>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Two</title>
<location>background-2.png</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Three</title>
<location>background-3.png</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Four</title>
<location>background-4.png</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Five</title>
<location>background-5.png</location>
<info>http://my.domain.com/</info>
</track>
</trackList>
</playlist>
Sample playlist4.xml (Media Player - captions and commentary audio)
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Media Player - Captions and Commentary Audio</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One</title>
<location>commentary1.mp3</location>
<link rel="captions">captions1.xml</link>
</track>
<track>
<title>Image Two</title>
<location>commentary2.mp3</location>
<link rel="captions">captions2.xml</link>
</track>
<track>
<title>Image Three</title>
<location>commentary3.mp3</location>
<link rel="captions">captions3.xml</link>
</track>
<track>
<title>Image Four</title>
<location>commentary4.mp3</location>
<link rel="captions">captions4.xml</link>
</track>
<track>
<title>Image Five</title>
<location>commentary5.mp3</location>
<link rel="captions">captions5.xml</link>
</track>
</trackList>
</playlist>
Jun. 18, 2007Will
Repost to fix a couple of errors.
Sample page code for two Media Players:
<html>
<head>
<title>Two Media Players</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="player1">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var so = new SWFObject('mediaplayer.swf', 'player', '640', '480', '7');
so.addParam('allowfullscreen', 'false');
so.addVariable('file', 'playlist1.xml');
so.addVariable('width', '640');
so.addVariable('height', '480');
so.addVariable('displayheight', '480');
so.addVariable('autostart', 'true');
so.addVariable('repeat', 'true');
so.addVariable('rotatetime', '20');
so.addVariable('shuffle', 'false');
so.addVariable('useaudio', 'true');
so.addVariable('usecaptions', 'true');
so.write('player1');
</script>
<div id="player2">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
//var sx = new SWFObject('mediaplayer.swf', 'player', '1', '1', '7');
//sx.addVariable('width', '1');
//sx.addVariable('height', '1');
var sx = new SWFObject('mediaplayer.swf', 'player', '640', '20', '7');
sx.addVariable('width', '640');
sx.addVariable('height', '20');
sx.addVariable('displayheight', '0');
sx.addVariable('file', 'playlist2.xml');
sx.addVariable('autostart', 'true');
sx.addVariable('repeat', 'true');
sx.write('player2');
</script>
</body>
</html>
You can make the second player "disappear" by uncommenting the three commented lines and commenting or deleting the corresponding lines that set the width to 640 and the height to 20.
Jun. 19, 2007Will
Here's an easy way to make a "Wet Floor Effect" with two Image Rotators and a PHP script.
You can play around with the height of the reflection and the reflection image parameters to get the most pleasing effect for your images.
Get the PHP script here [url=http://reflection.corephp.co.uk/v3.php]Easy PHP Reflections v3.0[/url].
Put the script on your server with your other files.
Comment out these two lines:
// $source_image = str_replace('://','',$source_image);
// $source_image = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $source_image;
HTML page code:
<html>
<head>
<title>Wet Floor Effect</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="player1">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var so = new SWFObject('imagerotator.swf', 'player', '640', '480', '7');
so.addParam('allowfullscreen', 'false');
so.addVariable('file', 'playlist1.xml');
so.addVariable('width', '640');
so.addVariable('height', '480');
so.addVariable('displayheight', '480');
so.addVariable('overstretch', 'false');
so.addVariable('autostart', 'true');
so.addVariable('repeat', 'true');
so.addVariable('rotatetime', '20');
so.addVariable('shuffle', 'false');
so.addVariable('useaudio', 'true');
//so.addVariable('kenburns', 'true');
so.addVariable('transition', 'slowfade');
so.addVariable('shownavigation', 'false');
so.addVariable('backcolor', '0x000000');
so.addVariable('linkfromdisplay', 'true');
so.write('player1');
</script>
<div id="player2">
<a href="http://www.macromedia.com/go/getflashplayer">You need Flash</a>
to see this gallery.
</div>
<script type="text/javascript">
var sx = new SWFObject('imagerotator.swf', 'player', '640', '100', '7');
sx.addParam('allowfullscreen', 'false');
sx.addVariable('file', 'playlist2.xml');
sx.addVariable('width', '640');
sx.addVariable('height', '100');
sx.addVariable('displayheight', '100');
sx.addVariable('overstretch', 'false');
sx.addVariable('autostart', 'true');
sx.addVariable('repeat', 'true');
sx.addVariable('rotatetime', '20');
sx.addVariable('shuffle', 'false');
sx.addVariable('transition', 'slowfade');
sx.addVariable('shownavigation', 'false');
sx.addVariable('backcolor', '0xFFFFFF');
sx.addVariable('linkfromdisplay', 'true');
sx.write('player2');
</script>
</body>
</html>
playlist1.xml (main image & audio)
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Image Rotator - Images and Background Music</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One</title>
<location>rotate-1.jpg</location>
<link rel="audio">song1.mp3</link>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Two</title>
<location>rotate-2.jpg</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Three</title>
<location>rotate-3.jpg</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Four</title>
<location>rotate-4.jpg</location>
<info>http://my.domain.com/</info>
</track>
<track>
<title>Image Five</title>
<location>rotate-5.jpg</location>
<info>http://my.domain.com/</info>
</track>
</trackList>
</playlist>
playlist2.xml (reflection)
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Image Rotator - Reflection</title>
<info>http://www.jeroenwijering.com/</info>
<trackList>
<track>
<title>Image One</title>
<location>reflect_v3.php?img=rotate-1.jpg&height=100&fade_start=90%25&fade_end=0%25</location>
<meta rel="type">jpg</meta>
</track>
<track>
<title>Image Two</title>
<location>reflect_v3.php?img=rotate-2.jpg&height=100&fade_start=90%25&fade_end=0%25</location>
<meta rel="type">jpg</meta>
</track>
<track>
<title>Image Three</title>
<location>reflect_v3.php?img=rotate-3.jpg&height=100&fade_start=90%25&fade_end=0%25</location>
<meta rel="type">jpg</meta>
</track>
<track>
<title>Image Four</title>
<location>reflect_v3.php?img=rotate-4.jpg&height=100&fade_start=90%25&fade_end=0%25</location>
<meta rel="type">jpg</meta>
</track>
<track>
<title>Image Five</title>
<location>reflect_v3.php?img=rotate-5.jpg&height=100&fade_start=90%25&fade_end=0%25</location>
<meta rel="type">jpg</meta>
</track>
</trackList>
</playlist>
Jun. 19, 2007JeroenW
@Will and @Andersen: thanks for your extensive support!
I've done a thorough cleanup of all the forums today, but found very little things that were "frequently asked". Only the IE dimension bug keeps returning, so I'll make sure to note that in the readme and wizard and use the width/height flashvars by default in the examples inside the downloads. Apart from that, there's little consistency to create a FAQ on. All the frequently asked things are already in the extras it seems, so I'll make sure to add more links to that. The only thing left to cut down on the extreme amount of (unneccessary?) posts at this forum is to insert registration. But I'd like to keep things as open and as free as possible.
andersen, I'll make sure to link to your mediaplayer demos from the forum! And Will, a typo-corrector is coming up!
Jul. 05, 2007Will
How to know how much of the video was played when the viewer navigates away....
It's pretty simple because Jeroen has output the needed data through the player's JavaScript API.
1) So, you need his JavaScript from the demo page.
2) You need to enable the JS API.
var s1 = new SWFObject('flvplayer.swf', 'mpl', '540', '580', '7');
s1.addVariable('enablejs', 'true');
s1.addVariable('javascriptid', 'mpl');
... the rest of the player code ...
3) You need a JS function to send the title & time to the server.
function sendDuration(title_time)
{
xmlhttp.open('GET', 'http://my.domain.com/path-to-file/stats.php' + title_time, true);
xmlhttp.send();
}
4) You need some JS to enable XHTML.
// Get an XMLHttpRequest object in a portable way.
var xmlhttp
function newRequest()
{
xmlhttp = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest)
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
else if (window.ActiveXObject)
{
// For Internet Explorer on Windows
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlhttp = false;
}
}
}
}
5) You need to add the fourth line in bold to the three existing vars in Jeroen's JS code.
var currentPosition;
var currentVolume;
var currentItem;
var currentTitle;
6) You need to add the line in bold to Jeroen's JS code.
if(typ == "time")
{
currentPosition = pr1;
// Add this next line to the existing JavaScript code...
sendDuration('?title=' + currentTitle + '&time=' + currentPosition);
}
7) You need to initiate the XHTML in the <body> tag.
<body onload="javascript:newRequest();">
8) You need a little script like this on the server to log the data.
<?php
// log stats
// call with: http://my.domain.com/path-to-file/stats.php?title=Video Title&time=5
$title = (isset($_GET["title"])) ? strval($_GET["title"]) : "No Title";
$time = (isset($_GET["time"])) ? strval($_GET["time"]) : "0";
$filename = 'stats.log';
// check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);
// log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER[REMOTE_ADDR] . " " . $datetime . " " . $title . " " . $time . "\n";
// open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");
// Write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");
fclose($handle);
?>
All of the above will result in a log file that looks like this.
192.168.0.1 [05/Jul/2007:05:00:18 -0700] Futurama - Less Than Hero 1
192.168.0.1 [05/Jul/2007:05:00:19 -0700] Futurama - Less Than Hero 2
192.168.0.1 [05/Jul/2007:05:00:19 -0700] Futurama - Less Than Hero 3
192.168.0.1 [05/Jul/2007:05:02:58 -0700] Futurama - Less Than Hero 4
192.168.0.1 [05/Jul/2007:05:02:58 -0700] Futurama - Less Than Hero 4
192.168.0.1 [05/Jul/2007:05:02:59 -0700] Futurama - Less Than Hero 5
192.168.0.1 [05/Jul/2007:05:03:00 -0700] Futurama - Less Than Hero 6
192.168.0.1 [05/Jul/2007:05:03:01 -0700] Futurama - Less Than Hero 7
192.168.0.1 [05/Jul/2007:05:03:01 -0700] Futurama - Less Than Hero 7
192.168.0.1 [05/Jul/2007:05:03:02 -0700] Futurama - Less Than Hero 8
192.168.0.1 [05/Jul/2007:05:03:03 -0700] Futurama - Less Than Hero 9
192.168.0.1 [05/Jul/2007:05:03:04 -0700] Futurama - Less Than Hero 10
192.168.0.1 [05/Jul/2007:05:03:05 -0700] Futurama - Less Than Hero 11
192.168.0.1 [05/Jul/2007:05:03:06 -0700] Futurama - Less Than Hero 12
192.168.0.1 [05/Jul/2007:05:03:07 -0700] Futurama - Less Than Hero 13
192.168.0.1 [05/Jul/2007:05:03:08 -0700] Futurama - Less Than Hero 14
192.168.0.1 [05/Jul/2007:05:03:09 -0700] Futurama - Less Than Hero 15
192.168.0.1 [05/Jul/2007:05:03:10 -0700] Futurama - Less Than Hero 16
192.168.0.1 [05/Jul/2007:05:03:12 -0700] Futurama - Less Than Hero 18
192.168.0.1 [05/Jul/2007:05:03:13 -0700] Futurama - Less Than Hero 19
192.168.0.1 [05/Jul/2007:05:03:14 -0700] Futurama - Less Than Hero 20
192.168.0.1 [05/Jul/2007:05:03:16 -0700] Futurama - Less Than Hero 22
192.168.0.1 [05/Jul/2007:05:03:17 -0700] Futurama - Less Than Hero 23
192.168.0.1 [05/Jul/2007:05:03:19 -0700] Futurama - Less Than Hero 25
192.168.0.1 [05/Jul/2007:05:03:20 -0700] Futurama - Less Than Hero 26
192.168.0.1 [05/Jul/2007:05:03:21 -0700] Futurama - Less Than Hero 27
192.168.0.1 [05/Jul/2007:05:03:22 -0700] Futurama - Less Than Hero 28
192.168.0.1 [05/Jul/2007:05:03:23 -0700] Futurama - Less Than Hero 29
192.168.0.1 [05/Jul/2007:05:03:24 -0700] Futurama - Less Than Hero 30
192.168.0.1 [05/Jul/2007:05:03:25 -0700] Futurama - Less Than Hero 31
192.168.0.1 [05/Jul/2007:05:03:26 -0700] Futurama - Less Than Hero 32
192.168.0.1 [05/Jul/2007:05:03:27 -0700] Futurama - Less Than Hero 33
192.168.0.1 [05/Jul/2007:05:03:28 -0700] Futurama - Less Than Hero 34
192.168.0.1 [05/Jul/2007:05:03:29 -0700] Futurama - Less Than Hero 35
192.168.0.1 [05/Jul/2007:05:03:31 -0700] Futurama - Spanish Fry 1
192.168.0.1 [05/Jul/2007:05:03:32 -0700] Futurama - Spanish Fry 2
192.168.0.1 [05/Jul/2007:05:03:32 -0700] Futurama - Spanish Fry 3
192.168.0.1 [05/Jul/2007:05:03:34 -0700] Futurama - Spanish Fry 4
192.168.0.1 [05/Jul/2007:05:03:35 -0700] Futurama - Spanish Fry 5
192.168.0.1 [05/Jul/2007:05:03:35 -0700] Futurama - Spanish Fry 6
192.168.0.1 [05/Jul/2007:05:03:37 -0700] Futurama - Spanish Fry 7
192.168.0.1 [05/Jul/2007:05:03:38 -0700] Futurama - Spanish Fry 8
192.168.0.1 [05/Jul/2007:05:03:38 -0700] Futurama - Spanish Fry 9
192.168.0.1 [05/Jul/2007:05:03:39 -0700] Futurama - Spanish Fry 10
192.168.0.1 [05/Jul/2007:05:03:40 -0700] Futurama - Spanish Fry 11
192.168.0.1 [05/Jul/2007:05:03:42 -0700] Futurama - Spanish Fry 12
192.168.0.1 [05/Jul/2007:05:03:42 -0700] Futurama - Spanish Fry 13
192.168.0.1 [05/Jul/2007:05:03:45 -0700] Futurama - The Route of All Evil 0
192.168.0.1 [05/Jul/2007:05:03:45 -0700] Futurama - The Route of All Evil 1
192.168.0.1 [05/Jul/2007:05:03:46 -0700] Futurama - The Route of All Evil 2
192.168.0.1 [05/Jul/2007:05:03:47 -0700] Futurama - The Route of All Evil 3
192.168.0.1 [05/Jul/2007:05:03:48 -0700] Futurama - The Route of All Evil 4
192.168.0.1 [05/Jul/2007:05:03:49 -0700] Futurama - The Route of All Evil 5
192.168.0.1 [05/Jul/2007:05:03:50 -0700] Futurama - The Route of All Evil 6
192.168.0.1 [05/Jul/2007:05:03:51 -0700] Futurama - The Route of All Evil 7
192.168.0.1 [05/Jul/2007:05:03:52 -0700] Futurama - The Route of All Evil 8
192.168.0.1 [05/Jul/2007:05:03:53 -0700] Futurama - The Route of All Evil 9
192.168.0.1 [05/Jul/2007:05:03:54 -0700] Futurama - The Route of All Evil 10
192.168.0.1 [05/Jul/2007:05:03:55 -0700] Futurama - The Route of All Evil 11
192.168.0.1 [05/Jul/2007:05:03:56 -0700] Futurama - The Route of All Evil 12
192.168.0.1 [05/Jul/2007:05:03:57 -0700] Futurama - The Route of All Evil 13
You can see how long I watched each of these videos. Normally your user's IP would be in place of 192.168.0.1, but I'm testing locally.
The final piece of the puzzle would be a script that parsed the log file, looking for the highest number associated with an IP/Title pair and outputs the IP, Titles, and Time or, depending on your needs, outputs the Title and time watched for all IPs.
Maybe like this:
.....IP..............Title...........Time..
192.168.0.1 Futurama - Less Than Hero 35
192.168.0.1 Futurama - Spanish Fry ...13
192.168.0.1 The Route of All Evil ....13
or
.........Title...........Time..
Futurama - Less Than Hero 11
Futurama - Less Than Hero 13
Futurama - Less Than Hero 13
Futurama - Less Than Hero 15
Futurama - Less Than Hero 15
Futurama - Less Than Hero 15
.....................Total 6
Futurama - Spanish Fry ...3
Futurama - Spanish Fry ...10
Futurama - Spanish Fry ...10
Futurama - Spanish Fry ...13
Futurama - Spanish Fry ...13
Futurama - Spanish Fry ...18
Futurama - Spanish Fry ...26
Futurama - Spanish Fry ...136
Futurama - Spanish Fry ...145
.....................Total 9
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
The Route of All Evil ....13
....................Total 19
Or averages, or whatever meets your needs.
Jul. 30, 2007Lee Davis
This is a ? directed @ JeroenW -PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
PLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASEPLEASE
Make a page for SEVERE noobs (like myself) who have no idea what in HELL is up with the usage of all the scripts that you have to offer. While I have been computing for 10+ years, the attempt on my part to setup and use the JW Media Player script in Windows Live Spaces has been one of the more challenging projects undertaken by myself. Even as I mentioned in another post in the section on placing player scripts on social sites like MySpace (and others), I'm going beserk trying to do it and I noticed that the ?s that I had on even the most basic installation (have no skill with js/html - trying to learn daily)were not even remotely approached. So, do you think you can write something that incorporates an approach from the layman's perspective? I think that your scripts for these players will become a new user standard for the millions of frustrated (by WMP) users (like myself, AND I've taught myself to surmount the ridiculousness of it)who want to create their own video experiences without depending on the bullshit spewing from the backsides of Bill & Paul or have to worry about instituting the proprietary nonsense of video sharing site players (and their obtrusive branding). I'm not too proud to admit that I have to be handheld and walked thru any process that has the inexperienced individual confronting code-driven application. And I've read the "Read Me"s for the Media Player about 100 times now and I'm still in the dark, which is why I'm taking time to beg and plead for a Noob step-by-step manual (of sorts). In all my web travels, I spent a long time searching for a resource such as yours and I don't want to have to settle for throwing up my hands in frustration and giving in to the organized insanity in the video delivery hostage spectrum. For every struggling noob user like myself who love the application, there are 1000s (if not millions more) who I KNOW would jump ship from their current video applications if there was a step by step approach. I have no problem with the wizard to make the player, but my problem is getting the player to actually function as I need it to in my Live Spaces page.
I apologize if this post is a bit long, but as I REALLY love the JW Media Player (and the other scripts you have to offer), I want to make sure I understand the process of how to get it up and running, so I can offer it as an alternative to others like myself who are sick and tired of the war of video (only exacerbated in the coming months and years with the trends of corporate money going into locking down video for profits and squeezing us for more cash and out of the proceedings of becoming future video content producers). I thank you for your fine past work in the creation of this application - I LOVE IT, but I need to know how to get it up and running so I can turn around and direct your future customers to you. Thank you for all your efforts.
Aug. 14, 2007Will
Chapterizer - Town Meeting
Harry, over on this post [url=http://www.jeroenwijering.com/?thread=6590#msg31506]High level question about streaming[/url] wanted to chapterize his Town Meetings, so we threw up this code to do it.
This is better than the original Chapterizer because it lets you make a simple text file of Title,Description,Time which the chapterizer uses to generate a playlist. The JW Player then uses that playlist to select and play the video served through an adaptation of the "stream.php" file (NOT streamscript).
Here is the ULTRA Beta draft version of the Meeting Chapterizer.
Included files:
1) chapterize_meeting.php - the main script
2) stream_chapters.php - a specialized FLV streamer
3) chapters.txt - a sample chapters file
4) chapters.html - a sample JW Player file
Additional files:
5) video.flv - Jeroen's sample file "video.flv" or another short video file for testing.
6) FLVMDI.exe - metadata creator/injector**
7) mediaplayer.swf - or another JW Player (flvplayer.swf or mp3player.swf)
8) swfobject.js - JavaScript for the JW Player
**You will need to have FLVMDI.exe in the same directory unless you have already used FLVMDI to create an XML metadata file of "video.flv" and it is named "video.xml" and it is in the same directory.
Generated files:
a) video.xml - the video metadata generated by FLVMDI, same name as your video file with the xml extension
b) playlist_video.xml - the generated playlist file
Note that these files take the name of the submitted video file as part of their filename.
In the configuration section of chapterize_meeting, set these variables.
1) $chapters_file - the name of the chapters file
2) $browser = true; - initial setting to return the playlist to your browser for testing
3) $video_url - the full URL to the video file
4) $info_url - the full URL to be used in the <info> element of the playlist
5) $logging = true; - if you want to log the completion status of the chapterizing
6) $logfilename - log file name
7) $debug_output - set to true if you want to see the creation of the arrays and other garbage
So, basically, you just need to place these 8 files in the same web-accessible directory, adjust the configuration variables, and call "chapterize_meeting.php" with your browser. The full test URL is near the top of the file. Then you can run "chapters.html" to see the result. Also examine the playlist to see the chapterizing.
Right now time is in integer seconds nnn format, but I can add the code to use the 00:00:00 hh:mm:ss format if that works better for you. I do that conversion back and forth quite frequently, so it's no big deal.
chapterize_meeting.php
<?php
// chapterize an FLV video file based on a chapter file and generate an XSPF playlist
// optionally, generate thumbnail images for the playlist
// Will - 08-15-07
// for testing, call with: http://my.domain.com/path-to-file/chapterize_meeting.php?filename=video.flv
// set chapters file
$chapters_file = "chapters.txt";
// return the playlist to the browser
$browser = true;
// set URLs
$video_url = "http://my.domain.com/path-to-file/stream_chapters.php?file=";
$info_url = "http://my.domain.com/path-to-file/";
// $image_url = "http://my.domain.com/path-to-file/";
// optional sub-directory for the images
$image_dir = "";
// thumbnail image width and height
$width = 32;
$height = 32;
// if you enable logging, it goes into this file
$logging = true;
$logfilename = "chapterize.log";
// set true for debug output
$debug_output = false;
//////////////////////// DON'T CHANGE VARIABLES BELOW THIS LINE ///////////////////////////////
// logging result
$result = "success";
// get filename
$filename = (isset($_GET["filename"])) ? strval($_GET["filename"]) : "video.flv";
$video_name = substr($filename, 0, strlen($filename) - 4);
$metadata_file = $video_name . ".xml";
// create keyframes metadata with FLVMDI
if (!file_exists($metadata_file))
{
exec("FLVMDI.exe /k /x \"" . $filename . "\"", $output, $return);
}
// open metadata and read keyframes
if (@$file_handle = fopen($metadata_file, 'r'))
{
while (($data = fgets($file_handle)) !== false)
{
if (preg_match('/<time>(.*)<\/time>/', $data, $matches))
{
$metadata[$matches[1]] = 0;
}
}
rewind($file_handle);
reset($metadata);
while (($data = fgets($file_handle)) !== false)
{
if (preg_match('/<pos>(.*)<\/pos>/', $data, $matches))
{
$metadata[key($metadata)] = $matches[1];
next($metadata);
}
if (preg_match('/<filesize>(.*)<\/filesize>/', $data, $matches))
{
$filesize = $matches[1];
}
}
reset($metadata);
fclose($file_handle);
}
else
{
if ($result = "success")
{
$result = $metadata_file . " not found.";
}
else
{
$result = $result . " " . $metadata_file . " not found.";
}
}
debug('MetaData', $metadata);
// exit;
// open chapters file and read chapter, description, and time
if (@$file_handle = fopen($chapters_file, 'r'))
{
$previous_time = "";
while (($data = fgets($file_handle)) !== false)
{
preg_match('/(.*?),(.*?),(.*)/', $data, $matches);
$chapters[$matches[1]]['description'] = $matches[2];
// if time is 00:00:00 format, convert here
$chapters[$matches[1]]['time'] = intval($matches[3]);
if ($previous_time)
{
$duration = $chapters[$matches[1]]['time'] - $previous_time;
$chapters[$previous]['duration'] = $duration;
}
$previous = $matches[1];
$previous_time = $matches[3];
}
array_pop($chapters);
reset($chapters);
fclose($file_handle);
}
else
{
if ($result = "success")
{
$result = $chapters_file . " not found.";
}
else
{
$result = $result . " " . $chapters_file . " not found.";
}
}
debug("Chapters", $chapters);
// exit;
// add pos & dur to chapters array
if ($metadata && $chapters)
{
while (false !== ($things = current($chapters)))
{
// get pos
$time = $things['time'];
// read first array element
next($metadata);
while (key($metadata) < $time)
{
next($metadata);
}
debug("Time-pos", $time);
debug("key(metadata)", key($metadata));
debug("current(metadata)", current($metadata));
// exit;
prev($metadata);
$chapters[key($chapters)]['pos'] = current($metadata);
reset($metadata);
// get dur
$time = $time + $things['duration'];
// read first array element
next($metadata);
while (key($metadata) < $time)
{
next($metadata);
}
debug("Time-dur", $time);
debug("key(metadata)", key($metadata));
debug("current(metadata)", current($metadata));
// exit;
prev($metadata);
$chapters[key($chapters)]['dur'] = current($metadata) - $chapters[key($chapters)]['pos'];
reset($metadata);
next($chapters);
}
reset($chapters);
}
debug("Chapters", $chapters);
// exit;
/* generate images
while (false !== ($elements = current($metadata)))
{
$time = $metadata[key($metadata)];
exec("ffmpeg-9260.exe -vcodec png -i \"" . $filename . "\" -ss " . $time . " -s " . $width . "x" . $height . " -y -vframes 1 -f image2 \"" . $video_name . key($metadata) . "%d.png\"");
next($metadata);
}
reset($metadata);
*/
// output playlist
if (is_array($chapters))
{
$playlist = "<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
";
while (false !== ($things = current($chapters)))
{
$playlist .= " <track>
<creator>" . key($chapters) . "</creator>
<title>" . $things['description'] . "</title>
<location>" . $video_url . $filename . "&pos=" . $things['pos'] . "&dur=" . $things['dur'] . "</location>
<meta rel='type'>flv</meta>
<info>" . $info_url . "</info>
</track>
";
// use the next line for images (place it after <location>)
// <image>" . $image_url . $video_name . $current_position . "1.png</image>
next($chapters);
}
$playlist .= " </trackList>
</playlist>
";
if ($browser)
{
print $playlist;
}
else
{
$fh = fopen("playlist_" . $video_name . ".xml", 'w') or die("Could not open file: playlist_" . $video . ".xml\n");
fwrite($fh, $playlist);
fclose($fh);
}
}
if ($logging)
{
// check to see if $logfilename exists, if not, create it.
@touch($logfilename);
// log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER[REMOTE_ADDR] . " - - " . $datetime . " " . $filename . " " . $result . "\n";
// open $filename for append.
@$log_handle = fopen($logfilename, 'a');
@fwrite($log_handle, $somecontent);
@fclose($log_handle);
}
function debug($title, $value)
{
global $debug_output;
if ($debug_output)
{
print "<pre>\n";
if (is_array($value))
{
print $title . ":\n";
print_r($value) . "\n";
}
else
{
print $title . ": " . $value . "\n";
}
print "</pre>\n";
}
}
?>
stream_chapters.php
<?php
// testing - adjust pos & dur
// http://my.domain.com/path-to-file/stream_chapters.php?file=video.flv&pos=4352&dur=6670
$file = (isset($_GET["file"])) ? strval($_GET["file"]) : "video.flv";
$pos = (isset($_GET["pos"])) ? strval($_GET["pos"]) : "0";
$dur = (isset($_GET["dur"])) ? strval($_GET["dur"]) : strval(filesize($file));
/* Uncomment for logging */
$filename = 'stream_dur.log';
// check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);
// log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER[REMOTE_ADDR] . " " . $datetime . " " . $file . " " . $pos . " " . $dur . "\n";
// open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");
// Write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");
fclose($handle);
/* Uncomment for logging */
// uncomment the next two lines if you don't want the media files
// to be cached on the cient computer
// header("Cache-Control: no-store, must-revalidate");
// header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: video/x-flv");
header('Content-Length: ' . $dur);
if($pos > "0")
{
print("FLV");
print(pack('C',1));
print(pack('C',1));
print(pack('N',9));
print(pack('N',9));
}
$fh = fopen($file,"rb");
fseek($fh, $pos);
while (!feof($fh))
{
$bytes = 0;
while ($bytes < $dur)
{
print(fread($fh, 8092));
$bytes += 8192;
}
}
fclose($fh);
?>
chapters.txt
1 Start of the Meeting,The opening minutes are read,0
2 Old Business,Garbage collection schedule,3
3 New Business,John brought up the pothole issue,5
4 Citizens Comments,Mrs. Smith complained about truck noise,8
5 Contracts,Review of park maintenance,10
6 Zoning,Staff presentation of zoning changes,13
7 Summary,Wrapping up all issues,16
8 End,End of video,20
chapters.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Chapter Streamer</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type='text/javascript'>
function createPlayer1()
{
var s1 = new SWFObject('mediaplayer.swf', 'playlist', '840', '426', '7');
s1.addParam('allowfullscreen', 'true');
s1.addVariable('width', '840');
s1.addVariable('height', '426');
s1.addVariable('displayheight', '406');
s1.addVariable('displaywidth', '540');
s1.addVariable('file', 'playlist_video.xml');
s1.addVariable('overstretch', 'true');
s1.addVariable('showdigits', 'true');
s1.addVariable('autostart', 'false');
s1.addVariable('shuffle', 'false');
s1.addVariable('repeat', 'false');
s1.addVariable('showicons', 'true');
s1.addVariable('thumbsinplaylist', 'true');
s1.addVariable('backcolor', '0xFFFFFF');
s1.addVariable('frontcolor', '0x404040');
s1.addVariable('lightcolor', '0x0FFFF0');
s1.write('player1');
};
</script>
</head>
<body onload="createPlayer1();">
<div id="player1">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Plugin</a>
to see this gallery.
</div>
</body>
</html>
The playlist thumbnail image generation using ffmpeg is commented out, but you can easily enable it with judicious use of the DELETE key.
Sep. 02, 2007dj stampede
@anyone doing classic asp and using jwflv player
Here is what I established (nothing new).
- Turn the buffer on when trying to do chunking of large files:
thus:
response.buffer = true
at the beginning of the script.
- The pack code in PHP is not needed to create the FLV header but can b created by reading the 13 bytes of data at the beginning of the flv file thus:
If (valPos > 0) Then
Response.BinaryWrite objStream.Read(13)
End if
When looping through the file and streaming the 16384 bytes of data ,if the file is sufficiently large you may run out of memory(buffer) and get errors.I fixed this by flushing the response object each time and clearing the buffer so the buffer did not have more than 16384 bytes at any time.Thus:
do while Not objStream.EOS
Response.BinaryWrite objStream.Read (16384)
Response.Flush
Response.Clear
loop
With this I was finally able to stream even my large file ..... good.The code below is th complete stream.asp, you may want to add it to the stream.asp (zip file) code on your http streaming page for people to try it out and hopefully improve on it.
<%
response.Buffer = true
Response.ContentType = "video/x-flv"
//request position and file name
Dim valPos,valFile
valPos = Request("pos")
valFile = Server.Mappath(Request("file"))
//check whether file type is FLV
If (LCase(Right(valFile,Len(valFile)-InstrRev(valFile,"."))) <> "flv")Then
Response.End
End if
//if position was not passed set pos to 0
If (valPos = "") Then
valPos = 0
End if
//create streaming object
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile(valFile)
//if pos is greate than 0 proceed to get FLV header information
If (valPos > 0) Then
Response.BinaryWrite objStream.Read(13)
End if
//set position to begin streaming
objStream.Position = valPos
//loop through file, flush and clear buffer each time
do while Not objStream.EOS
Response.BinaryWrite objStream.Read (163840)
Response.Flush
Response.Clear
loop
//close stream object
objStream.Close
Set objStream = Nothing
%>
The only pain is that this only works for both small and large files on IE, when accessed on Mozilla only the smaller files can be streamed , if you try it on a large file it stops playback.Let me know what your take on that is.
Oct. 16, 2007Will
Code for getting the video clip by time or percentage of the total video size (see the comments for the calling methods) requires ffmpeg:
<?php
// call this way for testing:
// http://my.domain.com/path-to-file/stream_dur.php?file=video.flv&pos=00:00:10&dur=00:00:10
// http://my.domain.com/path-to-file/stream_dur.php?file=video.flv&pct=50&dur_pct=10
// Will - 10-16-07
$file = (isset($_GET["file"])) ? strval($_GET["file"]) : "video.flv";
$pos = (isset($_GET["pos"])) ? strval($_GET["pos"]) : "00:00:00";
$dur = (isset($_GET["dur"])) ? strval($_GET["dur"]) : "00:00:10";
// check position format
if (!preg_match('/\d\d:\d\d:\d\d/', $pos))
{
$pos = "00:00:00";
}
// check duration format
if (!preg_match('/\d\d:\d\d:\d\d/', $dur))
{
$dur = "00:00:10";
}
/* Uncomment for logging */
/*
$filename = 'stream_dur.log';
// check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);
// log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER[REMOTE_ADDR] . " " . $datetime . " " . $file . " " . $pos . " " . $dur . "\n";
// open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");
// Write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");
fclose($handle);
*/
/* Uncomment for logging */
// get file info from ffmpeg
ob_start();
passthru("ffmpeg.exe -i \"" . $file . "\" 2>&1");
$duration = ob_get_contents();
ob_end_clean();
// parse file info
preg_match('/Duration: (.*?),/', $duration, $matches);
$duration = $matches[1];
// split into an array of 00 00 00
$duration_array = split(':', $duration);
$duration = $duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2];
// use percentage starting and duration
if (isset($_GET['pct']))
{
$percent = $_GET['pct'];
// check percent size
if ($percent > 100)
{
$percent = 50;
}
// debug(" Percent: ", $pct);
if (isset($_GET['dur_pct']))
{
$duration_percent = $_GET['dur_pct'];
// check duration_percent size
if (($duration + $duration_percent) > 100)
{
$duration_percent = 100 - $duration;
}
}
else
{
$duration_percent = 10;
}
$time = $duration * $percent / 100;
$dur_time = $duration * $duration_percent / 100;
// format for use by ffmpeg - not really necessary - could just use raw seconds
$pos = sprintf("%02d", intval($time/3600)) . ":" . sprintf("%02d", intval(($time-(intval($time/3600)*3600))/60)) . ":" . sprintf("%02.3f", ($time-(intval($time/60)*60)));
$dur = sprintf("%02d", intval($dur_time/3600)) . ":" . sprintf("%02d", intval(($dur_time-(intval($dur_time/3600)*3600))/60)) . ":" . sprintf("%02.3f", ($dur_time-(intval($dur_time/60)*60)));
}
// calculate length
$filesize = filesize($file);
// calculate bytes per second
$Bps = $filesize / $duration;
$dur_sec_array = split(':', $dur);
$dur_sec = $dur_sec_array[0] * 3600 + $dur_sec_array[1] * 60 + $dur_sec_array[2];
$length = $Bps * $dur_sec;
header("Content-Type: video/x-flv");
header('Content-Length: ' . $length);
// create the video clip and send it to standard output
passthru("ffmpeg.exe -i " . $file . " -sameq -ss " . $pos . " -t " . $dur . " -f flv -");
?>
Oct. 21, 2007Will
Here's a self-contained statistics package with pretty graphs made using PHPLOT from: [url=http://sourceforge.net/projects/phplot/]PHPLOT[/url]
It saves the data in a tab-seperated CSV file which can also be imported into Excel or other applications that read CSV files.
Put the "phplot.php" file from PHPLOT with this script, enable the callback in your JW Player, play a few videos or songs, call with graph=true, and enjoy the pretty graphs.
statistics_CSV-3.php
<?php
/*
* Full CSV package - with phplot - will - 10-21-07
* This is a statistics script for use with the callback flashvar in the JW Players.
* You have to set the location of this script as the "callback" flashvar for your player.
* The script outputs a tab-separated CSV playcount file with file, playcount, and playlist($id).
* Add the playlist name to the playlist like this: <identifier>Movie Trailers</identifier>
* Available values are:
* 1. $file (filename up to full URL, if used)
* 2. $title (media content title, if available)
* 3. $id (media id, if available) (can be used for playlist logging)
* 4. $state (player state, "start" or "stop")
* 5. $duration (only with state:stop)
*
* Double counting on start & stop is prevented.
*/
// for testing, call with: http://my.domain.com/path-to-file/statistics_CSV-3.php?file=video.flv&id=Movie Trailers&state=start
// for testing, call with: http://my.domain.com/path-to-file/statistics_CSV-3.php?graph=true
// this is the filename for the playcount file
$filename = 'playcount.csv';
//////////////////////// End of user configurable variables ////////////////////////////
extract($_POST, EXTR_PREFIX_SAME, "post_");
$file = stripslashes($file);
// check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);
if ($state == 'start')
{
$graph = 'false';
update_csv($file, $id, $filename, $graph);
}
// create graphs
if ($graph == 'true')
{
list($data1, $data2) = phplot($file, $id, $filename, $graph);
// debug
// print_r($data1);
// print_r($data2);
// exit;
// debug
output_graph($data1, $data2);
}
function output_graph($data1, $data2)
{
// output headers
$html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\n";
$html .= "<html lang=\"en\">\n\n";
$html .= "<head>\n\n";
$html .= " <title>Playcount</title>\n\n";
$html .= " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\n";
$html .= " <style type=\"text/css\">\n";
$html .= " td\n";
$html .= " {\n";
$html .= " vertical-align: top;\n";
$html .= " }\n\n";
$html .= " th\n";
$html .= " {\n";
$html .= " text-align: center;\n";
$html .= " color: #5588FF;\n";
$html .= " font-size: 16pt;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " }\n\n";
$html .= " div.plot\n";
$html .= " {\n";
$html .= " border: 20px solid #87CEEB;\n";
$html .= " background-color: #000000;\n";
$html .= " text-align: center;\n";
$html .= " color: #5588FF;\n";
$html .= " font-size: 0pt;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " }\n\n";
$html .= " div.title\n";
$html .= " {\n";
$html .= " width: 430px;\n";
$html .= " height: 20px;\n";
$html .= " text-align: center;\n";
$html .= " color: #87CEEB;\n";
$html .= " font-size: 16pt;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " }\n\n";
$html .= " div.legendS\n";
$html .= " {\n";
$html .= " background-color: #FFFFFF;\n";
$html .= " width: 470px;\n";
$html .= " height: 497px;\n";
$html .= " text-align: right;\n";
$html .= " overflow: auto;\n";
$html .= " color: #87CEEB;\n";
$html .= " font-size: 8pt;\n";
$html .= " font-weight: bold;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " scrollbar-3dlight-color: #DCDCDC;\n";
$html .= " scrollbar-arrow-color: #D3D3D3;\n";
$html .= " scrollbar-base-color: #0000CD;\n";
$html .= " scrollbar-track-color: #579EBB;\n";
$html .= " scrollbar-darkshadow-color: #000000;\n";
$html .= " scrollbar-face-color: #87CEEB;\n";
$html .= " scrollbar-highlight-color: #C0C0C0;\n";
$html .= " scrollbar-shadow-color: #000080;\n";
$html .= " }\n";
$html .= " div.legend1\n";
$html .= " {\n";
$html .= " width: 30px;\n";
$html .= " height: 515px;\n";
$html .= " text-align: right;\n";
$html .= " color: #87CEEB;\n";
$html .= " font-size: 8pt;\n";
$html .= " font-weight: bold;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " }\n";
$html .= " div.legend2\n";
$html .= " {\n";
$html .= " width: 400px;\n";
$html .= " height: 515px;\n";
$html .= " text-align: left;\n";
$html .= " color: #87CEEB;\n";
$html .= " font-size: 8pt;\n";
$html .= " font-weight: bold;\n";
$html .= " font-family: Comic Sans MS;\n";
$html .= " }\n";
$html .= " </style>\n\n";
$html .= "</head>\n\n";
$html .= "<body>\n\n";
$html .= " <table>\n";
$html .= " <tr>\n";
$html .= " <td>\n";
$html .= " <div class=\"plot\">\n";
$html .= " <img src=\"plays.png\" />\n";
$html .= " </div>\n\n";
$html .= " </td>\n";
$html .= " <td>\n";
$html .= " <table>\n";
$html .= " <th colspan=\"2\">\n";
$html .= " <div class=\"title\">\n";
$html .= " Plays\n";
$html .= " </div>\n\n";
$html .= " </th>\n";
$html .= " </table>\n";
$html .= " <div class=\"legendS\">\n";
$html .= " <table>\n";
$html .= " <tr>\n";
$html .= " <td>\n";
$html .= " <div class=\"legend1\">\n";
$count = 0;
foreach($data2 as $value)
{
$html .= " " . $data2[$count][0] . " -\n";
$html .= " <br />\n";
$count++;
}
$html .= " </div>\n\n";
$html .= " </td>\n";
$html .= " <td>\n";
$html .= " <div class=\"legend2\">\n";
$count = 0;
foreach($data2 as $value)
{
$html .= " " . $data2[$count][1] . " (Plays = ". $data1[$count][1] . ")\n";
$html .= " <br />\n";
$count++;
}
$html .= " </div>\n\n";
$html .= " </td>\n";
$html .= " </tr>\n";
$html .= " </div>\n\n";
$html .= " </table>\n";
$html .= " </td>\n";
$html .= " </tr>\n";
$html .= " </table>\n\n";
$html .= "</body\n\n";
$html .= "</html>\n\n";
print $html;
}
function phplot($media_file, $playlistid, $playcount_file, $graph)
{
require_once 'phplot.php';
// debug
$data = array
(
array('Song1', 45, 5), array('Song2', 90, 9),
array('Song3', 50, 6), array('Song4', 40, 3),
array('Song5', 75, 2), array('Song6', 45, 6),
array('Song7', 40, 5), array('Song8', 35, 6),
array('Song9', 50, 5), array('Song10', 45, 6),
array('Song11', 35, 6), array('Song12', 40, 7),
array('Song13', 35, 6), array('Song14', 35, 7),
array('Song15', 44, 6), array('Song16', 48, 7),
);
// debug
$playcount = readplaycount($media_file, $playlistid, $playcount_file, $graph);
$count = 0;
foreach($playcount as $key => $value)
{
$data1[$count][0] = $count +1;
$data1[$count][1] = $value['playcount'];
$data2[$count][0] = $count +1;
$data2[$count][1] = $key;
$count++;
}
// debug
//print "<pre>";print_r($data);exit;
//print "<pre>";print_r($data1);exit;
//print "<pre>";print_r($data2);exit;
$plot = new PHPlot(660, 500, 'plays.png');
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetIsInline(true);
$plot->SetDataType('text-data');
$plot->SetDataValues($data1);
$plot->SetTitle('Video Plays for October');
$plot->SetYTitle('Plays');
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->SetYTickIncrement(1);
// Turn on Y data labels:
$plot->SetYDataLabelPos('plotin');
$plot->SetDataColors(array('SkyBlue'));
$plot->DrawGraph();
return array($data1, $data2);
}
function update_csv($media_file, $playlistid, $playcount_file, $graph)
{
$playcount = readplaycount($media_file, $playlistid, $playcount_file, $graph);
// open $playcount_file for write.
$pc_handle = fopen($playcount_file, 'w') or die("Could not open file: " . $playcount_file . "\n");
// write $playcount to the open file.
while (false !== ($things = current($playcount)))
{
$filename = key($playcount);
$count = $things['playcount'];
$list = $things['playlist'];
$write = $filename . "\t" . $count . "\t" . $list . "\n";
fwrite($pc_handle, $write);
next($playcount);
}
fclose($pc_handle);
}
function readplaycount($media_file, $playlistid, $playcount_file, $graph)
{
// read playcount file into array
if (@$pc_handle = fopen($playcount_file, 'r'))
{
$found = false;
while (($data = fgets($pc_handle)) !== false)
{
$data = rtrim($data);
preg_match('/(.*?)\t(.*?)\t(.*)/', $data, $matches);
$playcount[$matches[1]]['playcount'] = $matches[2];
$playcount[$matches[1]]['playlist'] = $matches[3];
if ($matches[1] == $media_file)
{
$playcount[$media_file]['playcount']++;
$found = true;
}
}
// first playcount for a new file
if (($found == false) && ($graph == 'false'))
{
$playcount[$media_file]['playcount'] = 1;
if ($playlistid != '')
{
$playcount[$media_file]['playlist'] = $playlistid;
}
else
{
$playcount[$media_file]['playlist'] = 'Unknown';
}
}
}
if($graph)
{
$playcount = playcount_sort($playcount, 'playcount', false, $flags=0);
// $playcount = playcount_sort($playcount, 'playcount', true, $flags=0);
}
else
{
$array_lowercase = array_map('strtolower', array_keys($playcount));
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $playcount);
}
fclose($pc_handle);
return $playcount;
}
function playcount_sort($playcount_array, $order_by, $reverse=false, $flags=0)
{
// Create 1-dimensional named array with only sortfield values
$named_hash = array();
foreach($playcount_array as $key => $fields)
{
$named_hash[$key] = $fields[$order_by];
}
// sort 1-dimensional array, maintaining key-value relationship
if($reverse)
{
// arsort($named_hash, $flags=0);
foreach ($named_hash as $key => $row)
{
$plays[$key] = $row;
$files[$key] = $key;
}
// debug
// print_r($plays);
// print_r($files);
// exit;
// debug
// sort files as all lowercase
$files_lowercase = array_map('strtolower', array_keys($files));
array_multisort($files_lowercase, SORT_DESC, SORT_STRING, $files);
// debug
// print_r($files_lowercase);
// exit;
// debug
// Sort the data with plays descending, then files descending
// Add $named_hash as the last parameter, to sort by the common key
array_multisort($plays, SORT_DESC, $files_lowercase, SORT_ASC, $named_hash);
}
else
{
// asort($named_hash, $flags=0);
foreach ($named_hash as $key => $row)
{
$plays[$key] = $row;
$files[$key] = $key;
}
// debug
// print_r($plays);
// print_r($files);
// exit;
// debug
// sort files as all lowercase
$files_lowercase = array_map('strtolower', array_keys($files));
array_multisort($files_lowercase, SORT_ASC, SORT_STRING, $files);
// debug
// print_r($files_lowercase);
// exit;
// debug
// Sort the data with plays ascending, then files ascending
// Add $named_hash as the last parameter, to sort by the common key
array_multisort($plays, SORT_ASC, $files_lowercase, SORT_ASC, $named_hash);
}
// debug
// print_r($named_hash);
// exit;
// debug
// Create copy of playcount array in order of sorted array
$sorted_records = array();
foreach($named_hash as $key => $val)
{
$sorted_records[$key] = $playcount_array[$key];
}
// debug
// print_r($sorted_records);
// exit;
// debug
return $sorted_records;
}
?>
Dec. 27, 2007CrimsonMoon
Ordinarily, if you want to throw some PNG images, with Alpha channel transparency, up over flash using CSS, they have an ugly gray background and are not transparent in Internet Explorer.
Here's a technique for making those images transparent in Internet Explorer for nice CSS drop-down menus or advertising overlay images.
This code is for a drop-down menu system, but the essential code, in bold, can be used with any CSS and PNG images with Alpha channel transparency. It is conditional to only use the DXImageTransform for IE.
<![if IE]>
<style type="text/css">
li li
{
display: block;
float: none;
font-size: 7pt;
background-color: transparent;
background: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='images/bar_opaque-18.png');
/* next line changes menu item spacing */
padding: 3px;
}
</style>
<![endif]>
<![if !IE]>
<style type="text/css">
li li
{
display: block;
float: none;
font-size: 8pt;
background-color: transparent;
background: url(images/bar_opaque-18.png) top left no-repeat;
padding: 3px;
}
</style>
<![endif]>
Jan. 09, 2008jkerr
Hey guys,
I've been unable to get this script to work:
What I've done:
1. Downloaded and copied phplot.php to my root folder
2. Copied will's php script above and saved it as statistics_CSV-3.php to my root folder
3. Added s.addVariable("callback", "statistics_CSV-3.php"); to my JW Player script
4. Created a blank playcount.csv file to my root folder.
5. Changed permissions of playcount.csv and phplot.php to 664.
I pointed my browser to the test link indicated in the head of will's script ...
but it reports that it cannot create the csv file (even though the file already exists .. relative vs. absolute paths make no difference.)
I checked my PHP GD tables and it looks like the PHPLOT installation is fine.
I'm pretty sure i've covered all the bases here, and not sure why it won't create my stats file.
I had similar issues trying to use even the basic stats script from the JW extras page .. would appreciate a second set of eyes on this .. test link for stats script is:
http://www.parkingkarma.ca/training/statistics_CSV-3.php?graph=true
and my main JW player page is here:
http://www.parkingkarma.ca/training/351-internal.php
cheers,
-jeremy
Jan. 09, 2008touchIt
If you are on a *nix server, you will have to fiddle with the file permissions.
See the first "User Contributed Notes" on this page: http://us2.php.net/touch
Always Google "PHP function_name()" for PHP problems (substitute your function name).
Jan. 09, 2008jkerr
Hmm .. yes, it appears that permissions are the issue, but everything looks in order ..
i'll continue my googling on the function, but i think i've tried each possibility of relative/absolute path names and chmods ..
in the meantime, if anyone encountered this same issue and has the fix, please let me know ..
cheers,
-jeremy
Jan. 09, 2008touchIt
I saved some data to your .csv file with repeated calls:
http://www.parkingkarma.ca/training/statistics_CSV-3.php?file=video.flv&state=start
http://www.parkingkarma.ca/training/statistics_CSV-3.php?file=video.flv&state=stop&dur=45
Then I called for a graph and this is the error message that I got:
Warning: imagepng() [function.imagepng]: Unable to open 'plays.png' for writing: Permission denied in /home/parkingk/public_html/training/phplot.php on line 1139
So the permissions problem is in creating the "plays.png" file, not the .csv. And the text area shows three plays for video.flv, so that is working.
Jan. 09, 2008jkerr
@touchIt
thanks .. i added a dummy plays.png file, and that solved the problem ... sort of ..
the only way this script wants to work is if i chmod 777 for plays.png ..
i'm not up for that security vulnerability, so i've gone back to the basic stats script .. which i think i've got working now ..
i'll have to live without the fancy graphs for now :-(
cheers,
-jeremy
Feb. 16, 2008touchIt
Statistics Plus 02-16-08
This script will monitor the player's state and send statistical information to a serverside script.
Once the code is in place, you can send any flashvar that is available in getUpdate(), getIitemData(), and getLength() back to the player.
In fact, the player's callback is no longer needed if you send the full data set to the server.
You can even track how much of a video the user watched before switching to another track (not implemented, but easy within the existing framework), but unfortunately, NOT if the user left the page.
There's a short version of the callback and a longer version (commented out) in the JavaScript.
There's a sample playlist_statistics_callback_plus.xml file, a sample statistics_callback_plus.html page, and a sample statistics_plus.php script to get you started.
playlist_statistics_callback_plus.xml<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<creator>Blondie</creator>
<title>Heart of Glass</title>
<location>Blondie - Heart of Glass.flv</location>
<image>Blondie - Heart of Glass36804921.png</image>
<identifier>B-HoG</identifier>
<annotation>This is the Blondie hit Heart of Glass</annotation>
</track>
<track>
<creator>Bryan Adams</creator>
<title>Here I Am</title>
<location>/Movies/Bryan Adams - Here I Am.flv</location>
<image>Blondie - Heart of Glass36804921.png</image>
<identifier>BA-HIA</identifier>
<annotation>This is the Bryan Adams hit Here I Am</annotation>
</track>
</trackList>
</playlist>
statistics_callback_plus.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Simple JW Player</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type='text/javascript'>
function createPlayer()
{
var s1 = new SWFObject('mediaplayer.swf', 'mpl', '320', '306', '7');
s1.addParam('allowfullscreen', 'true');
s1.addVariable('width', '320');
s1.addVariable('height', '306');
s1.addVariable('displayheight', '240');
s1.addVariable('file', 'playlist_statistics_callback_plus.xml');
s1.addVariable('overstretch', 'false');
s1.addVariable('showdigits', 'true');
s1.addVariable('autostart', 'false');
s1.addVariable('shuffle', 'false');
s1.addVariable('repeat', 'false');
s1.addVariable('showicons', 'true');
s1.addVariable('showstop', 'true');
s1.addVariable('enablejs', 'true');
s1.addVariable('javascriptid', 'mpl');
s1.addVariable('callback', 'statistics_plus.php?userid=' + userid);
s1.addVariable('backcolor', '0xFFFFFF');
s1.addVariable('frontcolor', '0x404040');
s1.addVariable('lightcolor', '0x808080');
s1.addVariable('screencolor', '0xD5D5D5');
s1.write('player');
};
var userid = Math.round(10000000000 * Math.random());
var currentPosition;
var currentItem;
var currentFile;
var currentTitle;
var currentId;
var currentState;
var currentDuration;
var currentAuthor;
var currentDescription;
var currentStart = false;
function getUpdate(typ, pr1, pr2, pid)
{
if(typ == 'time')
{
// instrumentation only
tI = document.getElementById('time');
tI.innerHTML = '<li>time: ' + pr1 + ':' + pr2 + '</li>';
}
if(typ == 'state')
{
// instrumentation only
sT = document.getElementById('state');
sT.innerHTML = '<li>state: ' + pr1 + '</li>';
if((pr1 == 2) && (currentStart == false))
{
// callback with data
var iframe = document.getElementById('COMM');
// iframe.src = 'statistics_plus.php?author=' + currentAuthor + '&description=' + currentDescription + '&userid=' + userid;
iframe.src = 'statistics_plus.php?file=' + currentFile + '&title=' + currentTitle + '&id=' + currentId + '&state=start&author=' + currentAuthor + '&description=' + currentDescription + '&userid=' + userid;
currentStart = true;
// alert('Statistics Posted');
}
if(pr1 == 3)
{
// callback with data
var iframe = document.getElementById('COMM');
// iframe.src = 'statistics_plus.php?author=' + currentAuthor + '&description=' + currentDescription + '&userid=' + userid;
iframe.src = 'statistics_plus.php?file=' + currentFile + '&title=' + currentTitle + '&id=' + currentId + '&state=stop&duration=' + currentDuration + '&author=' + currentAuthor + '&description=' + currentDescription + '&userid=' + userid;
// also need to reset currentStart if the user selects a new track
currentStart = false;
// alert('Statistics Posted');
}
}
if(typ == 'item')
{
// need to reset currentStart here if the user selects a new track
if(currentItem != pr1)
{
currentStart = false;
}
currentItem = pr1;
setTimeout("getItemData(currentItem)", 100);
}
};
function getItemData(idx)
{
var obj = thisMovie('mpl').itemData(idx);
var nodes = '';
for(var i in obj)
{
nodes += '<li>' + i + ': ' + obj[i] + '</li>';
}
currentFile = obj['file'];
currentTitle = obj['title'];
currentId = obj['id'];
currentDuration = obj['duration'];
currentAuthor = obj['author'];
currentDescription = obj['description'];
// instrumentation only
dT = document.getElementById('data');
dT.innerHTML = nodes;
};
function thisMovie(movieName)
{
if(navigator.appName.indexOf('Microsoft') != -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
};
</script>
</head>
<body onload="createPlayer();">
<div id="player">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Plugin</a>
to see this gallery.
</div>
<!-- instrumentation only -->
<div id="time">
Time:
</div>
<div id="state">
State:
</div>
<div id="data">
Data:
</div>
<!-- ************* THIS IFRAME MUST REMAIN IN THE CODE *************** -->
<iframe id="COMM" style="border: none; width: 0px; height: 0px;"></iframe>
</body>
</html>
statistics_plus.php<?php
/*
* Statistics+ 02-16-08
* This is a statistics script for use with the callback flashvar in the JW Players.
* You have to set the location of this script as the "callback" flashvar for your player.
* You have to add the additional JavaScript shown in the example HTML doc. to get the full set of parameters.
* 1. $file (filename up to full URL, if used)
* 2. $title (media content title, if available)
* 3. $id (media id, if available) (can be used for playlist logging)
* 4. $state (player state, "start" or "stop")
* 5. $duration (only with state:stop)
* 6. $author (author's name)
* 7. $description (description or contents of the annotation element of the playlist)
* 8. $userid (randomnumber user id)
*/
// for testing, call with: http://domain/path/stats_plus.php?file=filename.flv&title=Video Title&id=7h836&state=start&duration=30&author=Author's Name&description=Descriptive Text goes Here&userid=123456789
// this is the filename for the log file
$filename = 'statistics_plus.log';
//////////////////////// End of user configurable variables ////////////////////////////
extract($_GET, EXTR_PREFIX_SAME, "get_");
extract($_POST, EXTR_PREFIX_SAME, "post_");
/* debug
print "<pre>\n";
print " File: " . $file . "\n";
print " Title: " . $title . "\n";
print " ID: " . $id . "\n";
print " State: " . $state . "\n";
print " Duration: " . $duration . "\n";
print " Author: " . $author . "\n";
print "Description: " . $description . "\n";
print " user ID: " . $userid . "\n";
print "</pre>\n";
exit;
*/
// check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);
// log file format: [01/Apr/2007:00:01:40 -0700]
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER[REMOTE_ADDR] . " - - " . $datetime . " \"" . $file . " : " . $title . " : " . $id . " : " . $state . " : " . $duration . " : " . $author . " : " . $description . " : " . $userid . "\" - \"-\" \"" . $_SERVER[HTTP_USER_AGENT] . "\"\n";
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");
// Write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");
fclose($handle);
?>
Feb. 16, 2008touchIt
The JavaScript in this page attempts to give you control over buffering.<html>
<head>
<title>Buffer Control</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function createplayer()
{
var s = new SWFObject('mediaplayer.swf', 'mpl', '400', '406', '7');
s.addParam('allowfullscreen', 'true');
s.addVariable('width', '400');
s.addVariable('height', '406');
s.addVariable('displayheight', '225');
s.addVariable('overstretch', 'fit');
s.addVariable('file', 'playlist_bufferControl.xml');
s.addVariable('shuffle', 'false');
s.addVariable('repeat', 'true');
s.addVariable('showstop', 'true');
s.addVariable('autostart', 'true');
s.addVariable('enablejs', 'true');
s.addVariable('javascriptid', 'mpl');
s.write('placeholder');
};
</script>
<script type="text/javascript">
var currentState;
var currentLoad;
var currentItem;
var desiredLoad = 15;
var paused = false;
var bufferControl = true;
function getUpdate(typ, pr1, pr2, pid)
{
if(typ == 'state')
{
currentState = pr1;
// instrumentation only
sT = document.getElementById('state');
sT.innerHTML = 'State: ' + pr1;
}
// instrumentation only
pA = document.getElementById('paused');
pA.innerHTML = 'Paused: ' + paused;
if((currentState == 2) && (paused == false))
{
setTimeout("thisMovie('mpl').sendEvent('playpause')", 50);
// alert('playpause');
paused = true;
// instrumentation only
pA = document.getElementById('paused');
pA.innerHTML = 'Paused: ' + paused;
}
if(typ == 'load')
{
// instrumentation only
bU = document.getElementById('buffer');
bU.innerHTML = 'Buffer: ' + pr1 + ':' + desiredLoad;
bC = document.getElementById('buffercontrol');
bC.innerHTML = 'Buffer Control: ' + bufferControl;
if((pr1 > desiredLoad) && (bufferControl == true))
{
// take some action here, like... start playing the video
if(currentState != 2)
{
thisMovie('mpl').sendEvent('playpause');
}
bufferControl = false;
// instrumentation only
bC = document.getElementById('buffercontrol');
bC.innerHTML = 'Buffer Control: ' + bufferControl;
// alert('Play Movie');
}
}
if(typ == 'item')
{
// instrumentation only
cI = document.getElementById('currentitem');
cI.innerHTML = 'Current Item:New Item: ' + currentItem + ':' + pr1;
// reset bufferControl and paused if it's a new track
if(currentItem != pr1)
{
bufferControl = true;
paused = false;
// instrumentation only
bC = document.getElementById('buffercontrol');
bC.innerHTML = 'Buffer Control: ' + bufferControl;
pA = document.getElementById('paused');
pA.innerHTML = 'Paused: ' + paused;
// alert('Current Item:New Item: ' + currentItem + ':' + pr1);
}
currentItem = pr1;
}
};
function thisMovie(movieName)
{
if(navigator.appName.indexOf('Microsoft') != -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
};
</script>
</head>
<body onLoad="createplayer()">
<div id="placeholder">
<a href='http://www.macromedia.com/go/getflashplayer'>Get the Adobe Flash Player</a>
to see this JW Media Player.
</div>
<!-- ** instrumentation only ** -->
<div id="state">
State:
</div>
<div id="currentitem">
Current Item:New Item:
</div>
<div id="paused">
Paused:
</div>
<div id="buffercontrol">
Buffer Control:
</div>
<div id="buffer">
Buffer:
</div>
</body>
</html>
Feb. 23, 2008windowFocus
How to drop out of fullscreen when the video finishes.
function getUpdate(typ, pr1, pr2, pid)
{
if(typ == 'state')
{
// drop out of fullscreen
if(pr1 == 3)
{
this.window.focus();
}
}
};
Feb. 23, 2008AJAX
Two Players - One Playlist
(Separate playlist.)
Position to suit your page with CSS.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Jenny N - Two Players - One Playlist</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
currentItem = 0;
newItem = 0;
function getUpdate(typ, pr1, pr2, pid)
{
if((typ == 'state') && (pid == 'ply') && (pr1 == 2))
{
// if the playlist player is playing, stop it
thisMovie('ply').sendEvent('stop');
}
if((typ == 'item') && (pid == 'ply'))
{
newItem = pr1;
}
if(currentItem != newItem)
{
thisMovie('mpl').sendEvent('playitem', newItem);
currentItem = newItem;
}
};
function thisMovie(movieName)
{
if(navigator.appName.indexOf('Microsoft') != -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
};
</script>
<script type="text/javascript">
function loadPlayer(aPlayer, aId, aWidth, aHeight, aDisplayheight, aPlaylist, aAutostart, aShownavigation)
{
var so = new SWFObject('mediaplayer.swf', aId, aWidth, aHeight, '9.0.115', '#F6B5CD');
so.addVariable('width', aWidth);
so.addVariable('height', aHeight);
so.addVariable('displayheight', aDisplayheight);
so.addVariable('file', aPlaylist);
so.addVariable('overstretch', 'none');
so.addVariable('bufferlength', '2');
so.addVariable('volume', '70');
so.addVariable('autostart', aAutostart);
so.addVariable('repeat', 'false');
so.addVariable('shuffle', 'false');
so.addVariable('enablejs', 'true');
so.addVariable('javascriptid', aId);
so.addVariable('shownavigation', aShownavigation);
so.addVariable('showstop', 'true');
so.addVariable('frontcolor', '0xF06D9C');
so.addVariable('backcolor', '0xFE87C3');
so.addVariable('lightcolor', '0xF6EC63');
so.addVariable('screencolor', '0xF6B5CD');
so.write(aPlayer);
};
</script>
<script type="text/javascript">
function createPlayers()
{
// load primary player
loadPlayer('player', 'mpl', '400', '340', '320', 'playlist_songs.xml', 'true', 'true');
// load playlist player
loadPlayer('playlist', 'ply', '300', '245', '0', 'playlist_songs.xml', 'false', 'false');
};
</script>
</head>
<body onload="createPlayers();">
<div id="player">
<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Player</a>
to see this Media Player.
</div>
<br />
<br />
<div id="playlist" style="position:absolute;top:333px;left:555px;">
<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Player</a>
to see this Media Player.
</div>
</body>
</html>
Mar. 01, 2008AJAX
Two Players - One Playlist **Updated**<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Two Players - One Playlist</title>
<style type="text/css">
body
{
background-color: #333333;
}
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var currentItem = 0;
var newItem = 0;
var mplState = 0;
function getUpdate(typ, pr1, pr2, pid)
{
if(typ == 'state')
{
if((pid == 'ply') && (pr1 == 2))
{
// if the playlist player is playing, pause it
thisMovie('ply').sendEvent('playpause');
}
else if((pid == 'mpl') && (pr1 == 2))
{
mplState = pr1;
}
}
else if((typ == 'item') && (pid == 'ply'))
{
newItem = pr1;
if(currentItem != newItem)
{
if(mplState == 2)
{
thisMovie('mpl').sendEvent('playpause');
}
setTimeout("thisMovie('mpl').sendEvent('playitem', newItem)", 100);
currentItem = newItem;
}
}
else if((typ == 'item') && (pid == 'mpl'))
{
newItem = pr1;
if(currentItem != newItem)
{
// update the playlist item
setTimeout("thisMovie('ply').sendEvent('playitem', newItem)", 100);
currentItem = newItem;
}
}
};
function thisMovie(movieName)
{
if(navigator.appName.indexOf('Microsoft') != -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
};
</script>
<script type="text/javascript">
function loadPlayer(aPlayer, aId, aWidth, aHeight, aDisplayheight, aPlaylist, aAutostart, aShownavigation, aThumbsinplaylist)
{
var so = new SWFObject('mediaplayer.swf', aId, aWidth, aHeight, '8', '#333333');
so.addVariable('width', aWidth);
so.addVariable('height', aHeight);
so.addVariable('displayheight', aDisplayheight);
so.addVariable('file', aPlaylist);
so.addVariable('overstretch', 'none');
so.addVariable('bufferlength', '2');
so.addVariable('volume', '70');
so.addVariable('autostart', aAutostart);
so.addVariable('repeat', 'false');
so.addVariable('shuffle', 'false');
so.addVariable('enablejs', 'true');
so.addVariable('javascriptid', aId);
so.addVariable('shownavigation', aShownavigation);
so.addVariable('showstop', 'false');
so.addVariable('showdigits', 'true');
so.addVariable('thumbsinplaylist', aThumbsinplaylist);
so.addVariable('frontcolor', '0xCCCCCC');
so.addVariable('backcolor', '0x333333');
so.addVariable('lightcolor', '0xEEEEEE');
so.addVariable('screencolor', '0x333333');
so.write(aPlayer);
};
</script>
<script type="text/javascript">
function createPlayers()
{
// load primary player
loadPlayer('player', 'mpl', '300', '320', '300', 'playlist_songs.xml', true, true, false);
// load playlist player
loadPlayer('playlist', 'ply', '300', '120', '0', 'playlist_songs.xml', false, false, false);
};
</script>
</head>
<body onload="createPlayers();">
<div id="player">
<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Player</a>
to see this Media Player.
</div>
<div id="playlist" style="position:absolute;top:9px;left:746px;">
<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Player</a>
to see this Media Player.
</div>
</body>
</html>
Mar. 05, 2008Yansky
Just a quick one for people that don't want to use the SWFObject script. You can do something like:
var fVars = [];
function setVars(key, value){
fVars.push(key+value);
}
setVars('height=', '395');
setVars('width=', '480');
setVars('file=', 'foo.flv');
setVars('image=', 'default.jpg');
var fVJoined = fVars.join('&');
themovieelement.setAttribute('flashvars', fVJoined);
Apr. 08, 2008Ragscoon
I have been able to edit the PlayerController.as and now the repeat variable can have a setting called "once" so you can add so.addVariable("repeat","once"); and it will play the list from where ever you start it, all the way to the end, but once the last item on the list has finished playing it will jump back to the top of the list and stop at the first item.
If you have flash you can add this to your PlayerController.as in the com / jeroenwijering / players / PlayerController.as.
Replace your setComplete Function with this one:
/** Determine what to do if an item is completed. **/
private function setComplete() {
var itm;
itemsPlayed++;
if (feeder.feed[currentItem]['type'] == "rtmp" || config["streamscript"] != undefined) {
sendChange("stop");
}
if (config["repeat"] == "false" || (config["repeat"] == "once" && itemsPlayed>=feeder.feed.length)) {
sendChange("pause", 0);
isPlaying = false;
itemsPlayed = 0;
/** Play list once then jump back to the top of the list and pause. **/
} else if ((config["repeat"] == "once" && itemsPlayed>=feeder.feed.length)) {
if (currentItem == feeder.feed.length-1) {
itm = 0;
setPlayitem(itm);
sendChange("pause", 0);
isPlaying = false;
} else {
itm = currentItem+1;
setPlayitem(itm);
}
/** Play list once then jump back to the top of the list and pause. **/
} else {
if (config["shuffle"] == "true") {
itm = randomizer.pick();
} else if (currentItem == feeder.feed.length-1) {
itm = 0;
} else {
itm = currentItem+1;
}
setPlayitem(itm);
}
}
Then simply recompile the player and use this new feature =<^_^>=
Nov. 13, 2008<WMP DeviceID
={f6994A91-E5C8-4875-82AB-7E480F4ED725}
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.