Cannot get mp4 file to display
7 posts by 4 authors in: Forums > CMS Builder
Last Post: February 13, 2012 (RSS)
By Mel - February 4, 2012
No player or clip is showing
Have in enabled the file extension mp4 in uploads
The field is called videoclip
The mp4 file is present in uploads folder
JW player is in folder called jwplayer in root directory
The first part of the code below does a check to see if checkbox video is ticked and then if so, do something
<?php if($biosRecord['video'] =='1'): ?><h3>Video clip checkbox is ticked & a mp4 file has been uploaded to field videoclip.... </h3>
<?php foreach ($biosRecord['videoclip'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<script type="text/javascript">
jwplayer("container").setup({
flashplayer: "jwplayer/player.swf",
file: "<?php echo $upload['urlPath'] ?>",
height: 270,
width: 480
});
</script>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
Thanks - Mel
Re: [mel] Cannot get mp4 file to display
By Jason - February 6, 2012
I think the problem here is that you're using an if statement inside your loop, looking at the isImage field. This field will be set to false on mp4 files, so the code that displays your player is very being executed.
try this:
<?php foreach ($biosRecord['videoclip'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<script type="text/javascript">
jwplayer("container").setup({
flashplayer: "jwplayer/player.swf",
file: "<?php echo $upload['urlPath'] ?>",
height: 270,
width: 480
});
</script>
<?php endif ?>
<?php endforeach ?>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Cannot get mp4 file to display
By Mel - February 6, 2012 - edited: February 6, 2012
Thanks for the reply
Tried removing the two lines as suggested but no change... still not showing player and file
Is it something to do with the php echo for the file, although I would have thought that the player would have loaded even if the file itself was not found... have you got any other thoughts on this
file: "<?php echo $upload['urlPath'] ?>",
Thanks - Mel
Re: [mel] Cannot get mp4 file to display
By Jason - February 6, 2012
It's hard to say without being able to see the page. Would you be able to send a url that demonstrates the problem?
Thanks,
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Cannot get mp4 file to display
By Mel - February 10, 2012
Here is URL, I have stripped out some of the fields as a way of testing to see if the coding in the other fields was causing the problem and also to make less code for you to look through
The video clip is definitely uploaded in her bio record (its the longtail demo clip that comes with the player)
url: http://viewit247.com/recordtest1.php
Regards - Mel
Re: [mel] Cannot get mp4 file to display
By (Deleted User) - February 10, 2012
I checked that the file is uploaded (http://viewit247.com/cmsAdmin/uploads/video.mp4) and that the player is in the right place (http://viewit247.com/jwplayer/player.swf) which they both are.
It seems that it's just the implementation of the JW Player code.
I notice that you're targeting the div "container" but you haven;t set a div with that id (there is one with that class however).
If you set the div class='container' to id='container' that may fix the problem.
Also, check to make sure that you're using the correct relative paths in the jwplayer script (if in doubt, use complete urls and work backwards!).
Let me know if this helps,
Tom
Re: [mel] Cannot get mp4 file to display
Sorry that I didn't see this earlier.
Try uploading the test video to a folder on your site (I called it presentations and called the file videotest.mp4). Once you get the video playing as it should, then replace the code with a foreach loop and a call to the upload.
Here's some code from a working mp4 video page that you can compare with yours. (don't forget to upload both the jwplayer.js and the player.swf files to your site and change the path to them as required.
In the Head:
<script type="text/javascript" src="jwplayer.js"></script>
And in the body to show the video.
<table align="center"><tr>
<td>
<div align="center">
<!-- Simple jwplayer "modes" implementation to try html5 first -->
<div id="container"> </div>
<script type="text/javascript">
jwplayer("container").setup({
file: "presentations/videotest.mp4",
height: 450,
width: 563,
image: "presentations/placeholder.jpg",
autostart: true,
modes: [
{ type: "html5" },
{ type: "flash", src: "player.swf" }
]
});
</script>
</div>
</td>
</tr>
</table>
There's a lot more on embedding video in a web page in my CMSB Cookbook http://www.thecmsbcookbook.com
Hope that helps.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php