General plugins

Flash module add-on: Playing a flash file on a course page

 
Picture of Dave Emsley
Flash module add-on: Playing a flash file on a course page
Particularly helpful Moodlers

I want to show a flash file on a course page.  I don't want the students to click a link to it, it has no interactivity and generates no scores.

Can I do this?

If so how please

Many Thanks

 
Average of ratings: -
Matt Bury
Re: Flash module add-on: Playing a flash file on a course page
Particularly helpful MoodlersPlugin developers
A good question. This is what works for me >>

On the course home page (where you see all the course weeks/units) you need to make sure you have editing turned on. At the top left of the page, you'll see a button to toggle editing on and off.

On the unit/week that you want to embed your SWF, you'll see a a little editing icon (a hand holding a pen) next to or just under the unit/week title. Click on this to edit the title.

This will open the text/HTML editor window where you can put your Flash embed code. At the top right of the text/HTML window, you'll see a <> icon. Click on this to enter HTML editing mode (Moodle calls it text mode).

Copy and past this code into the window:

<script type="text/javascript" src="http://yourserver.com/java/swfobject.js"></script>
<div id="content"><embed width="640" height="480" type="application/x-shockwave-flash" src="http://yourserver.com/swf/your_swf.swf" id="your_swf" name="your_swf" bgcolor="#ffffff" quality="high" wmode="transparent" /></div>
<script type="text/javascript"> var so = new SWFObject(&amp;amp;amp;quot;http://yourserver.com/swf/your_swf.swf&amp;amp;amp;quot;, &amp;amp;amp;quot;your_swf&amp;amp;amp;quot;, &amp;amp;amp;quot;640&amp;amp;amp;quot;, &amp;amp;amp;quot;480&amp;amp;amp;quot;, &amp;amp;amp;quot;9&amp;amp;amp;quot;, &amp;amp;amp;quot;#ffffff&amp;amp;amp;quot;); so.addParam(&amp;amp;amp;quot;wmode&amp;amp;amp;quot;, &amp;amp;amp;quot;transparent&amp;amp;amp;quot;); so.write(&amp;amp;amp;quot;content&amp;amp;amp;quot;); </script>

This code will embed the SWF 'your_swf.swf' which is in the directory 'http://yourserver.com/swf/' on your server. It uses a Javascript 'swfobject.js' which is in the directory 'http://yourserver.com/java/', to embed the SWF into the page.

Obviously, you have to create the directories, upload the files and edit the code above to reflect where you're really putting everything. The parts of the code in bold are the bits you need to edit.

If you read the code closely, you'll notice that some of the information is duplicated. This is because you essentially have the same code twice. The second half is for Internet Explorer, the first half is for all other browsers, including Firefox. You need to edit both halves of the code so that the corresponding parts in bold are the same.

You'll also notice that the second (IE) half is URL encoded (i.e. looks like this: &amp;amp;amp;quot;). For some reason, Moodle likes it this way. If you try putting regular <object> code there, it sometimes doesn't work.

I've attached a copy of swfobject.js

Oh yeah, if this doesn't work. Try looking in Moodle > Site Administration > Security > Site Policies > and make sure you've got the "Allow EMBED and OBJECT tags allowobjectembed " checked.

I hope I've covered everything. Good luck!
 
Average of ratings: Useful (1)
Picture of Glenys Hanson
Re: Flash module add-on: Playing a flash file on a course page
 
Hello,

I use the open source FlowPlayer to play my .flv files.

I usually use a label but anywhere in Moodle (message, wiki, html block ...) that has a html editor will do.
  • Upload the .flv file and the FlowPlayer.swf file to a folder in "Files"
  • In Add a resource choose Insert a label.
  • In the label text field:
    • Type Watch this video (or whatever instructions you want)
    • Select the words Watch this video with the mouse
    • Click on the Insert Web Link icon in the toolbar
    • Navigate to the folder in "Files"
    • Select the .flv file
  • Click on the "Save and display" button (1.8).
Remember if it's in a label and the video is a large file, it will slow down the opening of the Moodle course

Cheers,
Glenys

 
Average of ratings: -
Matt Bury
Re: Flash module add-on: Playing a flash file on a course page
Particularly helpful MoodlersPlugin developers
Ok, I got a message from a guy who tried this technique without success...

I went through these instructions very carefully and tried them myself and they work for me on my Moodle. The thing is, you have to get everything absolutely right:

Make sure you've uploaded the swfobject.js file.
Make sure all the paths to all the resources are correct.
Make sure you've edited both parts of the SWF embed code.
Make sure you've set the site security policies to allow EMBED and OBJECT tags.

That's all I can do. I could make a video tutorial (Flash based) on how to do it, but where would I put it? In Moodle?

Using Flash in Moodle is a real pain in the *****. I've considered trying a different LMS/CMS but I get messages from people using those who say the same thing. Everyone's having real trouble incorporating SWF media. It should be as easy as incorporating JPEGs, GIFsand PNGs. Flash has been around for a good few years now.

If you're listening, Moodle developers, take note!
 
Average of ratings: -
Picture of Ian Clayton
Re: Flash module add-on: Playing a flash file on a course page
 
 
Average of ratings: -
Matt Bury
Re: Flash module add-on: Playing a flash file on a course page
Particularly helpful MoodlersPlugin developers
Hi Ian,

The above code is a garbled mess that won't work on anything! The code I posted is a partially URL encoded version of the standard HTML <embed> and <object> tags for a SWF. I had problems when trying to use pure HTML and found that the URL encoding worked better. Moodle's quite idiosyncratic. My installation is Moodle 1.8. There's a Flash icon on the front page. Check out the source code there.

BTW "var so = new SWFObject(" is from a javascript for dynamically embedding SWF's. Moodle won't accept javascript from users by default. You'll have to dive into the Moodle code itself and give yourself scripting permissions.

The raw HTML for embedding Flash is:

<object width="100%" height="100%" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">
<param name="movie" value="your_swf.swf" />
<param name="quality" value="high" />
<embed width="100%" height="100%" src="your_swf.swf" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

You might want to play around with the width and height parameters to suit your needs. Again, this might not work too well in Moodle - it's very particular!
 
Average of ratings: -
Picture of Ian Clayton
Re: Flash module add-on: Playing a flash file on a course page
 
Matt
Thanks - Tom - Thanks - I actually got the embed to work - as a simple course web page using embed and as a Lesson branch - again as an embed.

Now for my next issue - it only works when I have the source swf file in the moodle root directory. When I refer to a copy in a new subdir (media) I get a blank page. Is this a permissions issue, and if so where do I go to fix that!

Ian
 
Average of ratings: -
Picture of Tom Cox
Re: Flash module add-on: Playing a flash file on a course page
 
That root dir issue is a new one to me.

I have had issues in the past, where an object/embed will work the first time, but when you go back and make any edit and then save, the code will break. sometimes there is not even any visible change. Freaky. We had to keep text copies to edit on and paste each time. Also had the same issue with some javascript used to pop up new windows, regardless of the allow settings.

Probably not your problem, but it happens a lot with moodle and object/embed tags.

 
Average of ratings: -
Matt Bury
Re: Flash module add-on: Playing a flash file on a course page
Particularly helpful MoodlersPlugin developers
You're right in that this is a paths issue. Moodle is a dynamic site an so the page your SWF is loading into might not be where you think it is. The best workaround is to use absolute paths from the HTTP root in your embed code:

i.e. "http://yoursite.com/yourMoodle/path/to/your/directory/yourSwf.swf"

But it's not really desirable to put course media in the Moodle directory at all. Moodle recommends that you use the default moodledata directory which is outside the HTTP root, usually called '/public_html/'. Because the of the Flash security model, you can't directly make calls to URLs outside the SWF's public_html directory at all. The recommended work around is a cross-domain policy file but most Flash developers use a PHP proxy script. I believe that there's one in Moodle already but I've never used it. You can just do a search in Google to find one, since there are hundreds of them out there.
 
Average of ratings: -
Picture of Tom Cox
Re: Flash module add-on: Playing a flash file on a course page
 
Here is another thread on the subject that may help/work:

http://moodle.org/mod/forum/discuss.php?d=83980#p371653
 
Average of ratings: -
Picture of Dan Leighton
Re: Flash module add-on: Playing a flash file on a course page
 
This rather nice flv and other format player works nicely.

http://www.jeroenwijering.com/?item=JW_FLV_Media_Player

Especially using his setup wizard
 
Average of ratings: -
Matt Bury
Re: Flash module add-on: Playing a flash file on a course page
Particularly helpful MoodlersPlugin developers
Moodle's SWF and FLV media filter diverts the link to an old version of Jeroen Wijering's FLV player, but I don't know if it'll work on a course page automatically.

Actually, I'd recommend updating Moodle's flvplayer.swf file with the newer version of his mediaplayer.swf in moodle/filter/mediaplugin/. Just change the file name back to flvplayer.swf so that Moodle can find it.

Something to bear in mind though: Course pages are really for providing a simple, light-weight contents page for a course so when a student logs on, they're at a really useful starting point and then they can decide where they want to go. If you put relatively heavy files on a course page it slows the loading time down considerably, especially for slower connections.
 
Average of ratings: -