Page 2 of 3

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Jan 02, 2008 4:15 pm
by vinc
Here are the minimal templates I'm using :

Summary :

Code: Select all

{literal}
<__script__ type="text/javascript">
function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
        if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
        }
};

function newMovie(urlbase,name,movie_id,movie_title,description,created,modified,start_date,end_date,genre,member,length,directurl) {
movie_url = urlbase+'/'+name+'.flv';
image_url = urlbase+'/'+name+'.jpg';
loadFile({file:movie_url,title:movie_title,link:movie_url,id:movie_id,image:image_url,author:member});
};
</__script>
{/literal}

<div class="showSummary">
{foreach from=$summaryitems item=entry}
<p class="showValue"><a href="javascript:newMovie('{$flvurlprefix}','{$entry->name}',{$entry->id},'{$entry->slash_title}','{$entry->slash_description}','{$entry->created|date_format}','{$entry->modified|date_format}','{$entry->start_date|date_format}','{$entry->end_date|date_format}','{$entry->genre}','{$entry->member}','{$entry->length_hours}:{$entry->length_minutes}:{$entry->length_seconds}','{$entry->url}')">
{$entry->slash_title}</a></p>
 
<p>{$entry->slash_description}</br>
Durée : {$entry->length_hours}:{$entry->length_minutes}:{$entry->length_seconds}</p> 
{/foreach}
</div>
Detail :

Code: Select all

<__script__ type="text/javascript" src="{$flvplayerlocation}/swfobject.js"></__script>

<div id="player">
  <a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a>to see this movie.
</div>

{literal}
<__script__ type="text/javascript">
var so = new SWFObject('{/literal}{$flvplayerlocation}{literal}/mediaplayer.swf','mpl','320','240','7');
so.addParam('allowfullscreen','true');
so.addVariable('displayheight','240');
so.addVariable('file','{/literal}{$flvurlprefix}/{$field_name}.flv{literal}');
so.addVariable('height','240');
so.addVariable('image','{/literal}{$flvurlprefix}/{$field_name}.jpg{literal}');
so.addVariable('width','320');
so.addVariable('autostart','false');
so.addVariable('overstretch','false');
so.addVariable('showvolume','true');
so.addVariable('enablejs','true');
so.addVariable('logo','{/literal}{$flvplayerlocation}{literal}/flv_logo.png');
// Very important to use the js loadFile() and sendEvent() funtions
so.addVariable('javascriptid','mpl');
so.addVariable('type','flv');
so.write('player');
</__script>
{/literal}
I'm not using the list template...

The code I'm inserting into the video page :
Note that I'm using a table to separate the video player from the video summary...

Code: Select all

<table><tbody>
	<tr>
		<td>{cms_module module='FLVPlayer' mode='detail'}</td>
		<td>{cms_module module='FLVPlayer' mode='summary'  sort='created_asc'}</td>
	</tr>
</tbody></table>
Hope this will help...
Keep in touch !

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Jan 02, 2008 4:34 pm
by deejmer
OK...that helped a little.  I noticed that the mediaplayer location I had in my Detail template was wrong. 

So now I get the video to play, but the summary section seems to be messed up.  If you go the URL I provided earlier (http://www.monzyk.com/index.php?page=videos) you will see that when you mouseover another video (test.flv), the path in the status bar has forward slashes and quotes in the path.  I don't see where this is being set.  I cant seem to find other videos in the collection as a result....can you help?

Thanks!

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Jan 02, 2008 6:11 pm
by vinc
As i can see on the first link of your page :
javascript:newMovie('http://www.monzyk.com/uploads/videos',' ... 'test','<a href=\

the backslash at the end is the problem... Maybe all the HREF is the problem...

Try not to set up a comment in the video manager or do not use the WYSIWYG editor (User Prefs...)

Keep me in touch (even in PM if you want)

Regards

Vin'c

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Sun Jan 20, 2008 4:11 am
by westis
Thanks Vince for the help with updating FLVPlayer to use the latest versions of JW FLVPlayer!

With help of Calguy (who originally wrote this module for me) I have made some changes to the templates we use at www.okv.se (Webb-TV). But there are a couple of things I don't get working with the Javascript. Maybe someone here could help.

1) typ never seems to be "item". That is, I have this function called getUpdate and if(typ == "item"), then it will call getItemData() that among other things is to include a download link and "E-mail a friend" (like at http://home5.inet.tele.dk/nyboe/flash/mediaplayer/replay.htm). In getImageData() is also the "bonus to show what is loaded in the player" that Vince included in his first code example. But that div never gets loaded... Why is typ not set to item?

2) The latest JW FLVPlayer can handle h.264-encoded mp4 files, if the user has the latest Flash Player. I also include Flash variables to detect bandwidth, as is explained on http://www.jeroenwijering.com/extras/ba ... check.html

Now the issue is that if I have an flv file and set the file extension to flv, then the correct bandwidth is detected and the file gets the suffix _768 if the bandwidth is above 768kbs. That is, the file to be played is changed from NNN.flv to NNN_768.flv.

When I set the file extension to mp4 this doesn't work. It may of course be a bug with JW FLVPlayer. But can anyone see if I may have done something wrong in the code?


I'm testing this out at http://www.kisima.org/index.php?page=testar-flv. The first file is mp4, the second is flv. Right now the file extension is set to mp4, so only the first video can be played. It's called NBV003paa.mp4, so if the bandwidth detection variables worked it should not be played... (as my bandwidth is much faster than that so that NBV003paa_768.mp4 should be played).

Btw, the player and the details about the video is updated separately, in the newMovie() function. That is with xmlHttpdRequest, thanks to Calguy.

My templates look like this. Summary template:

Code: Select all

{* The new default summary template *}

<!-- Some Handy Javascript -->
{literal}
<__script__ language="javascript" type="text/javascript">

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object
var displayed = 0;

function updateDiv(nid, text)
{
  if (document.getElementById)
    {
      x = document.getElementById(nid);
      x.innerHTML = text;
    }
  else if (document.all)
    {
      x = document.all[nid];
      x.innerHTML = text;
    }
  else if (document.layers)
    {
      x = document.layers[nid];
      x.document.open();
      x.document.write(text);
      x.document.close();
    }
}

function updateDetails(thediv,url) {
  http.open("GET", url + '&cntnt01showtemplate=false', false);
  http.send(null);
  if (http.readyState == 4) 
 {
    updateDiv(thediv,http.responseText);
  }
}
</__script>

<!-- Include some javascript for link control of the player -->
<__script__ type="text/javascript">
var currentPosition;
var currentVolume;
var currentItem;

function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
function getUpdate(typ,pr1,pr2,pid) {
	if(typ == "time") { currentPosition = pr1; }
	else if(typ == "volume") { currentVolume = pr1; }
	else if(typ == "item") { currentItem = pr1;setTimeout("getItemData(currentItem)",100); }
	var id = document.getElementById(typ);
	id.innerHTML = typ+ ": "+Math.round(pr1);
	pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
	if(pid != "null") {
		document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
	}
};

// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
function addItem(obj,idx) { thisMovie("mpl").addItem(obj,idx); }
function removeItem(idx) { thisMovie("mpl").removeItem(idx); }

function getItemData(idx) {
	var obj = thisMovie("mp1").itemData(idx);

	var nodes = "";
	for(var i in obj) { 
		nodes += "<li>"+i+": "+obj[i]+"</li>"; 
	}
	document.getElementById("data").innerHTML = nodes;


	var tmp=obj["file"]; 

	var subj="Video%20Link";
	var theAdr='the@email.adr'; 
		

	if(tmp!="") {			
		var theURL='<a href="'+tmp+'">Download</a>    '; 
		var theMail='<a href=mailto:'+theAdr+'?subject='+subj+'&body='+tmp+'>E-mail a friend</a>';
		document.getElementById("tipsa").innerHTML = theURL+theMail; 
	} else document.getElementById("tipsa").innerHTML = ""; 
};
	


function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};

function createPlayer(theFile) {
	var so = new SWFObject("{/literal}{$flvplayerlocation}{literal}/mediaplayer.swf","mpl","400","300","7");
	ImageFile = theFile+'.jpg';
	VideoFile = theFile+'.mp4';
	FallbackFile = theFile+'.flv';
	
	so.addParam("allowfullscreen","true");
	so.addVariable("file",VideoFile);
	so.addVariable("width","400");
	so.addVariable("height","300");
	so.addVariable("displayheight","300");
	so.addVariable("bwfile","{/literal}{$flvurlprefix}/100k.jpg{literal}");
	so.addVariable("bwstreams","768,5000");
	so.addVariable("overstretch","fit");
	so.addVariable("autostart","true");
	so.addVariable("image",ImageFile);
	so.addVariable("fallback",FallbackFile);

	so.addVariable("enablejs","true");
	so.addVariable("javascriptid","mpl");

	so.addVariable("callback","mysqlstat.php");
	so.write("player");
}
	
	
function newMovie(urlbase,name,id,title,description,created,modified,start_date,end_date,genre,member,length,directurl) {
  // replace the detail text
  updateDetails('flvdetailview',directurl);  // replace the detail content

  movie = urlbase+'/'+name;

  if( displayed == 0 )
    {
       // show the block
       document.getElementById("player").style.display="block";
       // sleep for a second
       setTimeout("createPlayer(movie)",100);
       displayed = 1;
    }
  else
    {  
        createPlayer(movie); // load the movie
    }
};

</__script>
{/literal}

{* search and rss *}

<div id="searchrss">
<p id="rss">
{cms_module module='flvplayer' mode='makerssbutton' rssimage="images/cms/feed-icon-28x28.png" feed_title="alla program"}
</p>


{* the filter form *}
{if isset($formstart)}
{assign var='submitbtn' value='Sök'}
<p id="search">
{$formstart}
<div class="invisible">{$labelstart}{$labeltext}{$labelend}: </div>{$input_keywords}{$submit}
{$formend}
</p>
</div>
{/if}


{* a poor attempt at a bookmarks thingie *}
{if isset($param_member)}
  <div class="breadcrumbs"><a href="/webbtv/webbtvmedlemmar">Medlemmar</a><span style="font-weight: normal"> » </span>{$param_member}</div>
{elseif isset($param_genre)}
    <div class="breadcrumbs"><a href="/webbtv/genrer">Genrer</a><span style="font-weight: normal"> » </span>{$param_genre}</div>
{elseif isset($param_input_keywords)}
<div class="breadcrumbs"><span style="font-weight: normal">Sökresultat: </span>{$param_input_keywords}</div>
{elseif isset($param_breadcrumb)}
   <div class="breadcrumbs">{$param_breadcrumb}</div>

{/if}



{* This is the meat of the template, where each of the records are output *}
{if isset($param_input_keywords) && $summaryitemcount == 0}
<p>Inga resultat</p>
{elseif $summaryitems == 0} 
{else}

{if $pagecount > 1}
  <p class="pagelinks">

{if $pagenumber > 1}
<span class="pagelinklast">{$firstpage}</span>  <span class="pagelink">{$prevpage}</span> 
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 <span class="pagelink">{$nextpage}</span>  <span class="pagelinklast">{$lastpage}</span>
{/if}
</p>
{/if}

<div class="video">
<ul>
{foreach from=$summaryitems item=entry}
<li>
<a class="thumbnail" href="javascript:newMovie('{$flvurlprefix}','{$entry->name}',{$entry->id},'{$entry->slash_title}','{$entry->slash_description|truncate:550}','{$entry->created|date_format:'%d.%m.%y'}','{$entry->modified|date_format}','{$entry->start_date|date_format}','{$entry->end_date|date_format}','{$entry->genre}','{$entry->member}','{$entry->length_hours}:{$entry->length_minutes}:{$entry->length_seconds}','{$entry->url}')"><img src="{$flvurlprefix}/{$entry->name}.jpg" alt="{$entry->name}"/></a>
<a class="videoinfo" href="javascript:newMovie('{$flvurlprefix}','{$entry->name}',{$entry->id},'{$entry->slash_title}','{$entry->slash_description|truncate:550}','{$entry->created|date_format:'%d.%m.%y'}','{$entry->modified|date_format}','{$entry->start_date|date_format}','{$entry->end_date|date_format}','{$entry->genre}','{$entry->member}','{$entry->length_hours}:{$entry->length_minutes}:{$entry->length_seconds}','{$entry->url}')">
<p class="videotitle">{$entry->title} <span class="videolength">({if $entry->length_hours > 0}{$entry->length_hours}:{/if}{$entry->length_minutes}:{$entry->length_seconds})</span></p>
   
     <p class="videomember">{$entry->member}</p>    

<p class="videodate">{$entry->start_date|date_format:'%d.%m.%y'}</p>
</a>
</li>

{/foreach}
</ul>
</div>
{/if}

Detail template for video details:

Code: Select all

<ul id="flvdetails">
  <li id="flvshow_titlerow">
     <p id="flvshow_created">{$field_start_date|date_format:'%d.%m.%y'}</p><span id="flvshow_title">{$field_title}</span> <span id="flvshow_length">({if $field_length_hours > 0}{$field_length_hours}:{/if}{$field_length_minutes}:{$field_length_seconds})</span><span id="rbw"></span> kbps.
  </li>
  <li id="flvshow_description">{$field_description|truncate:550}
    {if !isset($param_fromlink)}
        {$more} 
    {/if}</li>
  <li id="flvshow_member"><span id="tipsa" style="float: right;"></span>{$field_member}</li>
</ul>


<h2>RECEIVE UPDATES</h2>
<p id="pid"></p>
<ul>
<li id="item"> </li>
<li id="volume"> </li>
<li id="state"> </li>
<li id="time"> </li>
<li id="load"> </li>
<li id="size"> </li>
</ul>

// A bonus too to show what is loaded in the player
<h2>ITEM DATA</h2>
<ul id="data"></ul>

Template for the FLVPlayer div only:

Code: Select all

<p id="player" style="display:none;">
  <!--- this content replaced by the swf media -->
  <a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this movie.
</p>

<__script__ type="text/javascript" src="{$flvplayerlocation}/swfobject.js"></__script>

{literal}


<__script__ type="text/javascript">
	function getBandwidth(bw) {
		document.getElementById('rbw').innerHTML = bw;
	};
</__script>


{/literal}

Sorry if it's a messy explanation, it's very late here now... Would be grateful with any assistance to get this working properly! Thanks!

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Sun Jan 20, 2008 11:46 am
by westis
Hmm, it was simple... I had id="mp1" in one place and id="mpl" in the others...

However, the bandwidth Flash variable that changes the name of the file to be played still doesn't work with mp4 files. But that is an issue for JW FLVPlayer, not the CMSMS implementation. :)

When I have all set and done I'll post in the Showoff forum and explain how I've implemented this. Now that Flash Player and JW FLVPlayer can handle mp4 files I'm hoping to combine this to also have support for podcasting.

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Thu Apr 09, 2009 9:57 am
by yankee80
I got Javascript errors when clicking on the links in the movie list. Turned out it was caused by a line on my config.php:


Used to be:
#Document root as seen from the webserver.  No slash at the end
#If page is requested with https use https as root url
#e.g. http://blah.com
$config['root_url'] = 'http://000.000.000.000/~xxxadmin';

after I replaced it with a proper hostname

#Document root as seen from the webserver.  No slash at the end
#If page is requested with https use https as root url
#e.g. http://blah.com
$config['root_url'] = 'http://server.xxxx.com/~xxxadmin';

it started working just fine

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Jun 10, 2009 11:25 am
by vinc
Hi yankee80,

the problem must be on your web server. (is this yours or a shared one ?)
If the web server is a shared one, accessing ti by its IP, must cause something wrong (think about virtual hosts on a single IP)
So it is better to access it by its dns name so the webserver will know which files to send for this particular domain.

If not, maybe the same reason :)

Cheers

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Nov 18, 2009 4:15 pm
by rossdagley
I get a "database error: " when I add this code to my site. Any ideas?

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Fri Dec 11, 2009 9:31 am
by cyberman
@rossdagley

Can you explain it a little bit more?

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Wed Jan 06, 2010 2:24 am
by dcleckley
Vinc,

This is an outstanding post!  I followed your procedures to the letter.  I used your summary and detail templates.  I am using CMS Version 1.6.6, FLVPlayer 1.0.3 and JW Player 5.  I uploaded the JW player as you explained. 

Now, here is what I have.  Please look at http://www.stellarbeats.com/gullytv/index.php?page=home-2.  When I click on the video links, nothing happens.  No video loads, nor does it jump to the detail page.

As an FYI, when I pasted your detail page smarty, the player shows up all white.  No play controls. 

Here is where I may be messing up.  When I had 'videos', there is a 'video code' field and a 'title' field.  Does the video code field have to have a path, or the exact naming convention of the .flv file?  Or does it matter at all?  How does the module know what video to load?  A better question is what should I be adding when I click 'add a video'.

For some reason, I'm not getting results.  I don't know where I'm going wrong.  BTW, I'm on a shared host and I didn't put slashes at the end of the URLs in preferences. :)

Thank you for any support that you may be able to give.

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Fri Feb 12, 2010 9:29 pm
by monghidi
dcleckley,

Don't know if you have fixed things on your own, but when I hit the URL in your post (http://www.stellarbeats.com/gullytv/index.php?page=home-2) I see the videos just fine, everything seems to be working.

I'd love to know how you got it all to work! I'm not having any luck. I'm also using CMSMS 1.6.6, FLVPlayer 1.0.3, and JW Player 5.

Thanks! :D

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Sun Feb 14, 2010 2:45 am
by dcleckley
monghidi wrote: dcleckley,

Don't know if you have fixed things on your own, but when I hit the URL in your post (http://www.stellarbeats.com/gullytv/index.php?page=home-2) I see the videos just fine, everything seems to be working.

I'd love to know how you got it all to work! I'm not having any luck. I'm also using CMSMS 1.6.6, FLVPlayer 1.0.3, and JW Player 5.

Thanks! :D
Sure.  I didn't use the FLVPlayer at all.  I found that the majority of the video modules associated with CMSMS require that your server run FFMPEG.  Most shared hosts do not do that. 

I didn't uses CMSMS modules.  I simply went directly to the JW Player page and used their players, uploaded my flv or mp4 files and 'tada'. 

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Thu Jun 03, 2010 12:57 pm
by Rednes
Got it working, so for those who haven't:

(7 steps below are from this topic: http://forum.cmsmadesimple.org/index.ph ... 288.0.html. I changed it a bit tho.)

1. Installed FLVPlayer Module and CGExtentions
2. Add a "Member" called "test"
3. Added a Genres called "Featured Videos"
4. FLV File URL Prefix: is http://www.site.com/uploads/videos
5. FLV Player URL:  is http://www.site.com/mediaplayer
6. Files in the uploads/videos/ folder - video.flv
7. Added Video like so:
Video Code: video
title: test
Description: test
Genres: Featured Videos
Member: test
Length: 4 4 4
8. Download flash player from http://www.jeroenwijering.com. In the package you'll also find a file called swfobject.js
9. Upload both the player.swf and swfobject.js to a folder, in this case the folder is called 'mediaplayer'


10. To call the module and show all genres(with videos in it) on a page:

Code: Select all


{cms_module module='FLVPlayer' mode='list' sort='created_asc'}

11. List Template:

Code: Select all

{* default memberlist template *}
<div class="memberList">
{foreach from=$listitems item=entry}
  <div class="memberListEntry">
     <p class="memberListValue"><a href="{$entry->memberlist_url}">{$entry->name} ({$entry->count})</a></p>
  </div>
{/foreach}
</div>
12. Summary Template: (note: make sure you use the same name for your player in this piece of code where the SWFObject is created)

Code: Select all

<__script__ type="text/javascript" src="{$flvplayerlocation}/swfobject.js"></__script>
<div class="showSummary">
{foreach from=$summaryitems item=entry}
<div id="player{$entry->id}">
  <a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a>to see this movie.
</div>
{literal}
<__script__ type="text/javascript">


var so{/literal}{$entry->id}{literal} = new SWFObject('{/literal}{$flvplayerlocation}{literal}/mediaplayer.swf','mpl','320','240','7');
so{/literal}{$entry->id}{literal}.addParam('allowfullscreen','true');
so{/literal}{$entry->id}{literal}.addVariable('displayheight','240');
so{/literal}{$entry->id}{literal}.addVariable('file','{/literal}{$flvurlprefix}/{$entry->name}.flv{literal}');
so{/literal}{$entry->id}{literal}.addVariable('height','240');
so{/literal}{$entry->id}{literal}.addVariable('image','{/literal}{$flvurlprefix}/{$entry->name}.jpg{literal}');
so{/literal}{$entry->id}{literal}.addVariable('width','320');
so{/literal}{$entry->id}{literal}.addVariable('autostart','false');
so{/literal}{$entry->id}{literal}.addVariable('overstretch','false');
so{/literal}{$entry->id}{literal}.addVariable('showvolume','true');
so{/literal}{$entry->id}{literal}.addVariable('enablejs','true');
so{/literal}{$entry->id}{literal}.addVariable('logo','{/literal}{$flvplayerlocation}{literal}/flv_logo.png');
// Very important to use the js loadFile() and sendEvent() funtions
so{/literal}{$entry->id}{literal}.addVariable('javascriptid','mpl');

so{/literal}{$entry->id}{literal}.write('player{/literal}{$entry->id}{literal}');


</__script>
{/literal}


<p>
name: {$entry->name}<br />
description: {$entry->slash_description}</br>
</p>
{/foreach}
</div>

Solved issues:
- video's werent being displayed in the player and instead I got the error message "Loaded file is not a valid media provider".
This was being caused by a flash parameter: "so.addVariable('type','flv');", after removing this, problem was solved




Red.

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Thu Jun 03, 2010 2:30 pm
by dcleckley
Great fix.  Question though....is their a requirement for the server to run FFMPEG?

Re: [solved] FLVPlayer with last version of JW (3.9)

Posted: Tue Jun 08, 2010 8:44 am
by Rednes
Not sure, but I know it works on a pretty basic dedicated server.

Ill ask my host.

update @dcleckley: No you don't need FFMPEG installed on your server.