Play audio only once (embedding mp3)

Play audio only once (embedding mp3)

by Richard Pinner -
Number of replies: 47
Hi. I'm using moodle .9.5. I want to create a listening exercise which is an exam prep. In the real exam, the students will hear the audio only once. I've tried using the code
embed src="http://www.file.mp3" width="144" height="60" type="audio/mp3" loop="0" which plays the file as soon as the page loads, but how can I limit the number of plays? The students should only hear the audio once.

I've searched on google for other html code examples, wondering if anyone has a simple workaround or a more advanced plugin etc.

Any help much appreciated.
Average of ratings: -
In reply to Richard Pinner

Re: Play audio only once (embedding mp3)

by eliana neves -

I needed this too. As I couldn´t get any way to do it, I made 2 files.

I put the sound file on a quiz with a time limit (with just a bit more then its extension) and only one attempt. The exercise itself on another quiz file...

It works smile

In reply to eliana neves

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi,

I'm in the middle of developing a Flash MP3 player that can be embedded in a Moodle quiz, or anywhere else that allows you to edit HTML, that has no user controls and starts playing the audio as soon as the page loads into the browser. It also display the ID3 tag information, i.e. track number, title, album and artist, elapsed time, time remaining and progress bar that shows loading progress and playback progess. I'm developing it primarily for Cambridge ESOL (English for Speakers of Other Languages) exam practice quizzes and when I've got it working well enough, I'll make it available for everyone from my website.

I'm sure that as soon as I post it and people start using it, I'll get a deluge of requests for added features. If you have any requests, please let me know and I'll try to incorporate them.

All the best,

Matt smile
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi,

I've uploaded the MP3 player. It's open source GPL so there won't be any problems for anyone who wants to use it.

The link is on my blog: http://matbury.com/wordpress/2009/11/10/flash-mp3-player-for-tests/

Good luck!
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by eliana neves -

Thanks Matt,

It works perfectly... Great simple player!

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Matt,
I would like to include this player in the QuizPort module which is the successor to the HotPot module.

The QuizPort module allows teacher to insert media using a [square bracket] notation. As well as specifying the media file to be played they can also specify the player. I would like to add your player, so that people could embed it into Hot Potatoes quizzes and html files as follows:
  • [mysoundfile.mp3 mattbury]
  • [mysoundfile.mp3 mattbury timesToPlay=2]
You'll notice the notation will accept options which in this case can be used to pass the number of times to play.

When a test that has several questions with audio files, it would be preferable to give the student a start button, so they can decide which question they want to listen to next. We wouldn't want all the audio files all playing at once surprise

Also, also though streaming can work well with small files, it can result in choppy playback for larger files, which can severely hamper students comprehension of the audio. Therefore, I would like to suggest you add a waitForPlay=yes/no switch, so that teachers can require that the audio is fully downloaded before the student starts to listen. In order to avoid confusion, I would further suggest that a pretty loader does something amusing while the audio loads.

thanks for all your hard work on this!

regards
Gordon
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

Of course you're welcome to use my player and I glad that you find it useful. I think it would be a good idea to start up a Google Code page to manage feature requests, issues, bugs, docs, etc.

I'll add the option to display a start button so that it's possible to deploy more than one player per page.

I'll also add the waitForPlay feature. That's a good idea for users with slow or unreliable connections.

If you can simulate a first-time download, i.e. turn off caching in your brower, you'll see that there's a download progress bar beneath the playback progress, similar to many other media players, e.g. JW FLV Player and YouTube.com Player. I try to make UI's as familiar and intuitive to users as possible.

Thanks for your interest and feedback. I'll try to find some time to make those changes/upgrades. Please don't hesitate to contact me if you have any further questions/requests.

All the best,

Matt

BTW, could you lose one of the t's in the name, i.e. matbury? - There's already a web designer with that domain name and I'd like to avoid any confusion over that (his is mattbury.com, mine's matbury.com). I don't know of this is true of other developers, but Flash developers use their domains as naming conventions for their own class libraries, e.g. com/matbury/media/MP3Player.as.

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

I've included the two extra parameters you requested, waitToPlay - which waits for download to finish before allowing playback to start, and showPlay - which shows a play button and requires users to click on it to start playback.

Let me know if this is what you had in mind. I'm sorting out the download zip package now. The project site, again, is: http://code.google.com/p/moodle-mp3-player-for-tests/

The player itself is only 5KB in size - as small as the GPL3 licence logo. smile
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Matt,
this is great news. I have successfully incorporated the media player into QuizPort as the "matbury_mp3_player" cool

The player is embedded using the ufo (Unobtrisive Flash Object) javascript library that is part of standard Moodle (see lib/ufo.js).

Here's an example of how the player can be embedded in a QuizPort quiz. This text in the quiz ...

Produces this javascript code in the browser ...

That seems to work, and the player plays the audio file. Yay!

There is a message on the screen that probably shouldn't be there since it stays there the whole time the audio is playing:

  • Waiting for MP3 tag info...
Could you give me some guidance about what that means and what I need to do to prevent it being displayed?

Over the winter vacation the QuizPort module will become the TaskChain module which is intended to replace the HotPot module in Moodle 2.0, and I would like the matbury player to be part of that. Is it OK to include your player in the QuizPort module download from now on?

best regards
Gordon
Attachment waiting.for.mp3.tag.info.png
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

I'm glad it's working out well for you and thanks for the reference! smile

The text field at the bottom of the Flash Player window displays the MP3 files ID3 tags - Track number, title, album and artist. If the MP3 file doesn't contain this data, it doesn't get read so nothing replaces the message. The player aligns to the top left of the FP window so if you reduce the height of the window to, say 50 pixels, it won't be visible.

Is it possible to do something like?:

[http://mydata.org/audio/myaudio.m_p_3 matbury width=600 height=50]

I could set it so that if no ID3 data is present, when the download is complete, the field goes blank. Sometimes the ID3 data is at the end of the file.

I see that the playback bar is getting a bit cropped on the left too. I'll see if I can remedy that.
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
OK, I've made the changes and uploaded the new source and ZIP files.

I'd like to put some documentation and a link to the Hot Potatoes module on the project site. Would that be OK with you?
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
One other thing,

The FlashVars that the player is reading:

showPlay : "1",
waitToPlay : "1",

should be boolean values:

showPlay : "true",
waitToPlay : "true",

The player converts the string values in to boolean. I could make it so that it looks for either "true" or "1" to mean true. Would you like me to do that?

Also, for this bit:

majorversion : "6",

the lowest version of Flash Player that can display this Flash app. is FP 9 and ideally should be FP 9.0.115.0:

majorversion : "9",
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Matt,
thanks for pointing out those settings.

I have changed the showPlay and waitToPlay settings to "true" and confirmed they work. For robustness, I would like to suggest that the player treats "yes" and "1" values for these settings as equivalent to "true". This will also help people switching across from the standard Moodle player which uses "yes" and "no".

As you requested, I have cranked up the minimum Flash version and build to 9.115.

Regarding the messages that the player displays, we should think about what would be the correct thing to display in a multilanguage system like Moodle.

Personally I don't think we should display MP3 tags unless the teacher specifically requests it - maybe by specifying "showTags=true". We certainly don't need that message if their are no mp3 tags anyway.

Also, I don't think we need the message saying "Complete. Press play to start". I feel it would be better to demonstate the file is loaded using a visual device - perhaps have the player start with a very transparent color and then switch to its proper color from left to right as the file loads. "Press play to start" is not neccessary. If someone really doesn't already know that, then I would think they they would need more precise instructions such as "Press the square button with a triangle in it to start". But since they other mp3 players I have come across never have such instructions, I think we would be safe to remove the instructions altogether.

I have included the matbury player in the QuizPort download, and will update if I notice that you have updated the Gcode site.
>I'd like to put some documentation and a link to the Hot Potatoes module
> on the project site. Would that be OK with you?

Sure, that would be great. For my part, I have posted an announcement on the HotPot forum:

many thanks for creating such a neat and nifty player!
Gordon
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hello again Matt,
I have been experimenting with different height and widths.

As you suggested earlier, changing the height to around 18px prevents the display of any messages.

However, I would like to suggest that player scales its heights and width to fill the complete space that it is given by the browser. This would give teachers greater control of fitting the player into their quizzes.

At the moment any extra height and width is simply filled by white space, and reducing the width and height to less than 30 x 600 results in part of the player display being truncated. Although this could be said to be useful at the moment because we can hide messages that way, I think it would be better to allow the messages to be displayed or hidden via switches, and have the player be as big as it can be while staying within the part of the screen that the browser has assigned to it.

I notice that the progress bar *does* get scaled to the width of the <object>, and that is great. However, in doing so we lose the nice blue border on the right hand end of the player (see attached screenshot in which player's width is 200px). I would like to keep the blue border even if the width is less than 600px.

If it was possible to change the way the player fits into its <object> area, so that it behaves more like other mp3 players, I think it would cause less confusion for people who are used to how the other players behave.

regards
Gordon
Attachment matbury.mp3.player.200px.png
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

Thanks for the feedback.

* The min. FP version should be 9.0.115, not 9.115. If someone has FP 8 or before, it'll just kick in an upgrade to the latest version of FP anyway.

Do you know if UFO includes expressInstall.swf or anything like it? - It seamlessly upgrades FP without having to go to the Adobe FP download page. I think if it's for a test, having a Flash app. before the actual test begins that detects users' FP version and triggers an upgrade would be a good idea. I can imagine users getting frustrated with listening tests on poorly managed networks because they can't play the audio.

I guess that you'd like the ID3 tags turned off by default. Since so many people use iTunes to manage their MP3 libraries these days, it probably makes sense to make ID3 tags an opt-in feature - iTunes doesn't alter the ID3 tags in the MP3 files, only in the iTunes XML library. I guess this way we won't get so many, "Why don't my ID3 tags show up correctly?" forum posts. ;)

* So something like: "showID3=true" and the default is false?

* I'll play around with pulling the player to more extreme dimensions and perhaps make the borders absolute values rather than ratios.

* I think going the visual route rather than multilingual support is probably the best option. I could set the play button alpha to 50% while loading when set to waitToPlay=true or make it invisible altogether. There's a slight CPU performance difference between using alpha and visible but probably not anything noticeable even with 50 or so players on the same page!

All the best,

Matt
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi again,

I've played around with it a little bit:

* Added the showID3=true, default = false

* Removed the download complete and press to play messages. Now, the play button signals when it's ready.

* The play button alpha is at 30% when inactive, 100% when active.

* Changed the blue background and progress bars to separate objects so they scale more evenly and smoothly to the stage width. The scaling is consistent right down to the point where the progress text fields overlap.

* Made the text fields unresponsive to the mouse cursor. Now, it's either a pointer or a hand, nothing else.

* Made the MP3 download progress bar black so that it contrasts more with the background and the play back progress bar, i.e. it's easier to see.

* I've added a stage resize listener so that if the player's embedded with the width values as a percentage and users resize the bowser window, the player will resize accordingly so that you'll never get parts of the player disappearing (within reason).

I've uploaded the source and I'm going to upload the ZIP package now.

Let me know if this is what you had in mind. Also, are there any accessibility features (508 compliance) that you'd like included? Obviously, it's a listening so subtitles aren't an option but the play button should be tab enabled which would also mean including the "allowseamlesstabbing=true" parameter in the embed code.
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Matt,
> The min. FP version should be 9.0.115, not 9.115.

OK, I understand this point. ufo.js looks at the navigator.plugins["Shockwave Flash"].description which comes back as ...
  • Shockwave Flash 9.0 r124
In the above case, ufo.js compares "majorversion" to 9 and "build" to 124, so I think we are doing the right thing with the following settings:
  • majorversion: "9"
  • build: "115"
Thanks for adding the showID3 setting. I would like to suggest a more teacher-friendly name, like showInfo or showExtraInfo.

To make this truly the player of choice for audio-savvy educators I would also like to suggest a few more settings:
  • showBar:
    if true the progress bar is displayed, otherwise it is not and no space is reserved for it on the stage.
  • showTime:
    if true, the time-since-start and time-to-finish are displayed as digital times (min:sec) under the progress bar. If false, the times are not displayed and no space is reserved for them on the stage.
  • showInfo:
    if true, the info (if any) is displayed, otherwise the info is not displayed and no space is reserved for it on the stage
  • allowPause:
    If true, the play button will change to a pause button when clicked, and when the pause button is clicked the audio pauses and the button changes back to a play button. Clicking the play button again resumes the audio from the point where it paused and changes the button back to a pause button. If false, the audio cannot be paused once it has begun.
  • allowRewind:
    If true, the progress bar has a handle on it that can be dragged back to a previous point, including the start, of the audio. If false, there is no handle on the progress bar and the audio cannot be rewound.

The above settings are in addition to those we already have:

  • showPlay:
    if true a play button is displayed and the audio does not start until the button is clicked. When the end of the audio is reached, if the number of plays is not greater than the "timesToPlay" setting (see below), the audio does not restart until the play button is clicked again. If false, a play button is not displayed and the audio is played either immediately (waitForPlay=false) or once the file has loaded (waitForPlay=true).
  • timesToPlay:
    the number of times the audio is allowed to be played from beginning to end (disregarding pauses and rewinds)
  • waitToPlay:
    if true, the audio cannot be started until the audio file has been completely downloaded. If false the audio file can be started as soon as possible
I would also like it to be possible to specify the colors, using 6-digit hex RGB colors, of the stage, button, bar and text. Here are some suggestions for the settings ..
  • bgColor: stage color
  • btnColor: background color of button - do we need two colors to get the current two-tone effect?
  • btnColorOver: background color(s) of button when cursor moves over it
  • iconColor: color of play (triangle pointing right) and pause (two vertical bars) symbols
  • iconOverColor: color of play and pause symbols when cursur moves over the button
  • barColor: color(s) of static border of progress bar - may need two colors for the two-tone effect?
  • barColorStart: color of the center track of the progress bar when no audio has been played yet
  • barColorFinish: color of the center track of the progress bar when the audio has finished playing. As the audio progresses the center track changes from the start color to the finish color from left to right
  • handleColor: color of the rewind handle
  • handleColorOver: color of the rewind handle when the mouse moves over it
  • timeColor: color of the time-since-start and time-to-finish text
  • infoColor: color of the info text
At the moment, the player is laid out for left-to-right languages, but it could well be that some teachers would want the player to be right-to-left, to fit in with their right-to-left language materials, so how about one final setting:
  • direction: if "left" the player appears as it is now. If "right", the elements of the player, i.e. button, bar, times and info, are positioned in the mirror image of where they are now. In addition, the play icon is also reflected and the progress bar goes from right to left
And one final thing, please allow the player to accept the media url not only via the "mp3url" parameter but also via other common parameter names:
  • src
  • movie
  • url
Well, there's my Christmas list. It reflects my experience over the last few years dealing with media players on the HotPot forum. For most people the defaults will suffice, but having the options for the advanced (or adventurous!) users will make it stand out from the crowd.

many thanks as always for all your hard work on this
Gordon
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Gordon and Matt,

To Gordon's wishlist I would add a feature I consider absolutely indispensable for an audio player to be used in the context of language learning, and that is the possibility for the student while listening, to click on a button (or, better, press a key, e.g. the left arrow) to rewind the last 10 seconds of the audio file and start playing automatically from there. Ideally that "10 seconds" might be a parameter set by the teacher (i.e. 5 seconds, etc.). One player I am using at the moment which has this very handy feature is http://flash-mp3-player.net/

Joseph

Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

That's some wish list! To be honest, I think with all the features you have in mind, it would be better to go for an existing open source project like FlowPlayer or the latest version of JW FLV Player. They both offer a full Javascript API, skinning features, localisation (languages) and support for accessibility, captioning, etc. It would give you a lot more options to play with and you'd have a player that has been developed by a team over a period of years, not just a few days in some generous guy's spare time.

Yeah, Joseph, that looks like a good project to use!

I hope this helps. smile
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Matt,
sorry if I appeared greedy and ungrateful. I appreciate your generosity and admire your work very much !

Your player is the only one I have come across which gives control over how many times the audio can be played. It is something special. Many thanks for letting me including it in the QuizPort module approve

kind regards
Gordon
In reply to Gordon Bateson

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Gordon,

You're welcome and I was in no way trying to imply greed on your part! It's always good to ask, in my opinion, otherwise you won't find out if a project can go in a particular direction. I'm glad that you like my work.

To me, it seems more practical to leverage an already well developed and feature rich media player to do what you want. And there is more than one way to skin a cat, as they say. FlowPlayer (open source) and JW FLV Player (cheap licence) both have JavaScript APIs so you can set the number of times any media file, not just an MP3, plays. Then, you can have all the features in your wish list and many, many more (both players are extensible). The JW FLV Player already has a library of free plugins and skins to choose from. If you haven't already done so, check out another project of mine, FLV Player which leverages it. You can set the appearance and behaviour of the player via FlashVars but you can also do it via XML. It also supports SMIL captioning and playlists: http://code.google.com/p/moodle-flv-player/ Of course my plugin only scratches the surface of what the media player can do!
Average of ratings: Useful (1)
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt & Gordon,

Thanks so much for your development here! I'm looking forward to using this in a language testing setting. (Yes, I understand that it isn't completely safe...nothing is, right! smile )

I've played and played with settings and for some reason cannot get this to work in the following environment:

Moodle 1.9.8+
MAMP
Firefox 3.6

I am trying to embed the sample mp3 included in the package into the explanation portion of a Forum and/or a forum post (both through the html editor of course)

I'm pretty sure I have the code correct because everything works when I click on the edit button and the html editor window comes up. mixed

But when I save the item and go back to the forum, I get the mp3url error....?

I see the player etc. but the file will not play. It's the exact same error as the one that is included in the readme file that accompanies the package.

I tried turning off both the mp3 and swf multimedia filters (although turning off the mp3 filter really isn't an option in our production environment) but it had no affect.

Also, I do have the allow Object and Embed tags option turned on.

Any advice will be most appreciated.

Jason
In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Jason,

Yes, Moodle's text filters really don't like Flash embed code! And Moodle's Flash embed filters are pretty inflexible if you want to pass in FlashVars.

I've managed to get it to work but I understand that it's too difficult and performs inconsistently across different Moodle setups. I guess I should find the time to look into this and perhaps create a filter plugin for it.

If anyone with experience of creating filters for Moodle would like to help... ??? Or am I thinking wishfully?
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt,

Thanks for the quick reply. I'd love to help but I'm afraid I don't have the expertise. I enjoy fiddling around with settings etc. but I'd be more of a hindrance than a help on a filter creation project.

I'll keep trying and see if I can get this to work on our site. I guess I could adjust the settings of the main site filter but that would affect audio files used in all courses and I don't want to do that.

I can't figure out why it is so close and will play in the html editor window but not in the main window of the activity (Forum in my case)?? I guess the site-wide filter is interfering with the one of yours that I have installed.

I assume this is going to be the same situation for the filter embedded in the QuizPort package?

Jason
In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Jason,

My cry for help was aimed at anyone reading this thread, not just you smile I think that since it isn't possible to use W3C standards embed code to pass in anything but the simplest of FlashVars in Moodle, it's necessary to have a decent Flash embed filter. Almost all open source CMS's now have a good selection of Flash embed filters.

Moodle's text filters behave differently on different pages so, for example, something that works perfectly well in the HTML editor won't necessarily work on other pages. It can be frustrating, I know.

I started the FLV Player*, now called the Media Player* and SWF Activity Module plugin projects because of this apparent lack of support for Flash in Moodle. I've had a lot of support and encouragement from Moodle users and I can see from Google Analytics that there's a lot of demand for it.

*The FLV Player and Media Player modules are actually simplified versions of the SWF Activity Module. You can deploy just about any Flash video player with the SWF Activity Module.
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt,

Thanks! Sorry, I was away from this particular thread for a few days.

We are frantically trying to work out a way to allow for single play of audio files as we've planned to give a final exam via Moodle in late July and want to allow students to only listen to the audio file once.

I was/am starting to think that we may have to "tweak" our Flash filter (site-wide) for the day of the test and then return it to normal after the test. I'll look at the SWF Activity Module and see if there is anything that can be used there.

Thanks again.

Jason
In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers
Hi Jason,

A really quick but hacky way to do it would be to create a static HTML MP3 player embed page in the moodledata course directory and embed it as an iFrame in the quiz. That is if you're sure that everyone's browsers support iFrames.

I wrote a wiki page on the Media Player module site about it: http://code.google.com/p/moodle-mplayer/wiki/MediaPlayerInMoodleQuizzes You can just substitute the Media Player with the MP3 Player for tests.

I hope this helps! smile
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt,

Thanks and sorry for the long delay in my response. I've experimented with this a little and think I see what you mean but my problem is we have 30 listening items in our quiz which means we will have to create 30 player instances in the course that houses the quiz. I haven't tried it yet but if I make a player invisible to students, will it still be accessible via the iFrame embed?

I experimented with the site-wide multimedia player but it apparently does not have the flashvars that allow for hiding the control bar built into it sad

Actually we have modified the multimedia player a bit and are using one provided by 1pixelout, which I'm pretty sure is a JW variation, but it doesn't seem to have the capability. Just wish I could hack the site wide player for the day of the test and then return it to normal afterwards. That would be easier for us at this point.

I'll play with the Mplayer a bit more and see what I can figure out.

Jason


In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt,

Just documenting my progress here. I have tried using the Mplayer and as long as I change the width and height settings to 0 I can achieve the result I'm shooting for. If I don't change those however, I get the entire page view of the Mplayer instance.

Also, I was able to confirm that making the Mplayer activity invisible does not affect the embedded file in the quiz question so I can make the audio inaccessible to students in the course but still provide the audio via the quiz questions. It's going to be a little messy as we'll have to create 30 Mplayer instances for the quiz but it looks like it's going to work for now.

Ideally, if I could substitute the side-wide multimedia filter for one that allows us to hide the control bar on the player, it would be an easy way to work with the quizzes we have already set up but I'm not having much luck there.

Thanks again for your help.

Jason
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt,

I've pretty much driven myself crazy trying to find an swf player to use for the mp3 player that will allow for the following to be specified in flashvars:

Play once
No controls
Auto start

It seems like they are out there but I can't get any to work. Quizport doesn't work in our environment and the wonderful player that you have works almost but not quite when used in quiz.

If I could just find one that will allow me to pass it those variables I could (I thought) replace the site wide player and use it for the day of a test but I can't get that to work either.

Sorry, this is a bit of a rant but I'm wondering if you have any ideas/suggestions.

The MediaPlayer idea didn't work on our computers. I'm not sure if the Flash is old, the browsers are old....or what but I managed to get it to work perfectly on my MacBook Air on a MAMP instance and was excited and then found that it doesn't work on our older PC's with IE or even a new version of Firefox....

I'm stumped sad

Jason
In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Matt & Others,

Sorry for the rant posted above. I am happy to say that I was able to Gyorgy's modification working. smile I'm trying to figure out what the flashvar is for autoplay but aside from that the player control locking and one play feature works flawlessly. We are going with this for a quiz that is to be administered in two days.... Nothing like getting it all together at the last minute smile

Jason

P.S. I'm surprised there doesn't seem to have been much done with the multimedia player filter in Moodle for some time.....or maybe I just don't see it. I certainly would be nice if we had an option at the quiz level or wherever embedding audio, video etc. to pass some of these variables (autoplay, lock controls, limit number of play times, etc.) instead of having to look for additional players/filters to install in the form of extra mods that have various compatibility issues given Moodle's architecture. That's not directed at any individual in particular. Just an observation. smile
In reply to Jason Hollowell

Re: Play audio only once (embedding mp3)

by skf bishal -

Hello Matt,

I am trying to embedd MP3 sound and would like to play only once per day.

I don't want visitors hear that sound time and again when they reach home page, but would like to set it to play next day if they reach that page.

How can I do that? do you have suggestions?

Thank you.

In reply to skf bishal

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers

Hi skf bishal,

Yes, you can achieve something like that. The simplest solution would work on a per computer browser basis and only takes a Flash MP3 player to store a local SharedObject (Flash cookie) in the browser cache and then check the current day against any previously stored day against it.

Howeverr, if the user accesses the player via a different computer or device or even a different browser, the MP3 player will play the audio again.

This would require custom modifications to whichever MP3 player you decide to use, but it's only a few lines of code to achieve this.

All the best,

Matt

Average of ratings: Useful (1)
In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by skf bishal -

Hi Matt,

Thank you for your reply. You understood exactly what i want.

Do you have any downloads available for this problem?

or Could you please help me to create this solution? What other lines of codes are needed to achieve this? I would really  appreciate if you could help me on this. I have no problem in adding any kind of codes (either Javascript-cookies based  or flash based).

NOw I am using following code:

***************************************************************************

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

*************************************************************************

if you could please help me to modify would be really great.

Thank you so much!!!

SKF Bishal

In reply to skf bishal

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers

Hi,

Please let me clarify my explanation a bit better...

The lines of code would need to be added to the Actionscript source code of the Flash player itself. It's a fairly straight forward task to add the SharedObject code to an existing Flash MP3 player if you have the source code. The same is achievable with video.

There's a full explanation of how the AS 3.0 SharedObject class works here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html The particular type you want is a local SharedObject.

I hope this helps.

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Michelle Jackman -

First of all I just wanted to say thank you to Matt for developing this. I am working with a language teacher who needs to allow students to do their listening comprehension tests online via Moodle. This is perfect as it removes control of the player from the student and I can specify how many times they can hear the recording.

However, I've hit a problem when using it within an embedded (cloze) question type. The height adjusts itself and I lose the play button completely. I'm told that it appears that the html code I insert is being parsed and altered. Have you successfuly used the player in this type of question before? Or has anyone else experienced this issue?

Here is the player code that I am using:

<div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="50" id="myFlashContent">
<param name="movie" value="http://curve.coventry.ac.uk/cu/items/4dd92056-2656-6f88-e6bb-d89b702040ef/1/mp3_test.swf" />
<param name="flashvars" value="mp3url=http://curve.coventry.ac.uk/cu/items/f3dc8a5b-b8c6-e7fe-2c3e-da0519f673ae/1/Il%20fine%20settimana_with%20pauses.mp3&amp;timesToPlay=1&amp;showPlay=true&amp;waitToPlay=true&amp;showID3=false&amp;addHttp=false" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://curve.coventry.ac.uk/cu/items/4dd92056-2656-6f88-e6bb-d89b702040ef/1/mp3_test.swf" width="300" height="50">
<param name="flashvars" value="mp3url=http://curve.coventry.ac.uk/cu/items/f3dc8a5b-b8c6-e7fe-2c3e-da0519f673ae/1/Il%20fine%20settimana_with%20pauses.mp3&amp;timesToPlay=1&amp;showPlay=true&amp;waitToPlay=true&amp;showID3=false&amp;addHttp=false" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>

And here is the question text that I am using, if you wouldn't mind trying it.  

Durante la settimana {:SA:=mi sveglio} alle 6.30 e {:SA:=mi alzo} alle 6.40. Lavoro tutto il giorno. Ecco perchè il sabato e la domenica amo stare in casa, dormire fino a tardi. {:SA:=mi riposo} davvero. Dormo anche di pomeriggio ... beh, vorrei dormire di pomeriggio. Invece di solito mi arrabbio. {:SA:=Mi arrabbio} perchè io vorrei dormire e invece i miei vicini amano la musica molto alta e appena {:SA:=mi addormento}, ecco.... loro iniziano ad ascoltare qualche canzone pop ad alto volume... e così {:SA:=mi alzo} e esco per una passeggiata con il mio cane.

In reply to Michelle Jackman

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers

Hi Michelle,

I've never heard of Moodle resizing manually entered Flash embed code before.

BTW, if you set addHttp to false and keep the "http://" part of the mp3url, if an admin ever turns on Moodle's MP3 embedding filters, all your embedded audio code will break. I strongly recommend setting:

mp3url=curve.coventry.ac.uk/etc...

and

addHttp=true

I hope this helps.

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Michelle Jackman -

Ah, thanks Matt. I will do that. I'm sort of muddling through this so appreciate the advice.

So, should the player work within an embedded (cloze) question? I've had terrible problems with the player today which I think were down to where I was storing it (not in the Moodle Files directory) which I have now overcome, but I still cannot get it to appear within a cloze question type. I can get round this by using it in a 'description' type question but it's not ideal, particularly if we want to randomise question order.

Thanks again for this marvel, and for your tip. smile

In reply to Michelle Jackman

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers

It's shouldn't matter where the player is on the server as long as it has the same URL as the web page. I see that the URL to your Moodle is in a subdomain, i.e. curve.coventry.ac.uk, which may be causing some Flash Player security issues - Flash is very strict about security! If this is the case, there's an easy remedy. All you need is a crossdomain.xml policy file at the root of your server's public directory, i.e. coventry.ac.uk/crossdomain.xml

You can see mine here: http://matbury.com/crossdomain.xml (If you view it in Firefox, ignore the parsing error warning and view the page source).

Mine is strict and only allows access from my own URL and subdomains. You can copy it and just substitute your own URLs and subdomains on it. You can also add other URLs if you want to grant them permission for Flash Player to access your media from their website(s). This should resolve any Flash Player security issues.

Ah, just had a look at your university's main domain at http://wwwm.coventry.ac.uk/Pages/index.aspx Notice the "wwwm"? Remember to include this in the crossdomain.xml policy file! Linking to http://wwwm.coventry.ac.uk/crossdomain.xml returns a 404 not found error so either there isn't one there or there's an .htaccess file preventing access. Just to let your IT support know.

I hope this helps. Good luck! smile

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Michelle Jackman -

I'd be really grateful it someone could try to use this player in a cloze question and let me know if it works or not! PLEASE! wink

In reply to Michelle Jackman

Re: Play audio only once (embedding mp3)

by Matt Bury -
Picture of Plugin developers

Hi Michelle,

Yes, it'll work anywhere in Moodle that allows object and embed tags. It gets around Moodle's multimedia filters by not requiring the http:// part of the MP3 URL.

See this page here: http://code.google.com/p/moodle-mp3-player-for-tests/wiki/HowToUse

Good luck!

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Michelle Jackman -

Just noticed that the 'enable .mp3 filter' is already set to yes anyway...thoughtful

In reply to Matt Bury

Re: Play audio only once (embedding mp3)

by Sara Cenni -

Hi Matt! We used your plugin with Moodle 1.9 and it worked perfectly. Now we need to use it in Moodle 2.5, but without legacy files. How can we do this? Is it possible?

In reply to Sara Cenni

Re: Play audio only once (embedding mp3)

by rupert salmon -

Hi Sara, Matt?


Was there any reply to this question. ,I've beehaving an enormous headache trying to use the once only player in moodle 2.5 particularly as concerns the labelling of the whereabouts of the player and mp3 file having read the importance of its address in the "moodledata course files directory" which apparently doesn'y exist in Moodle 2.5. Can someone please tell me, and I imagine numerous others who would like to use a once only player, is it possible and if so how? Do we still try to follow the google page of instructions or is there some other way. 

In reply to Richard Pinner

Re: Play audio only once (embedding mp3)

by Frankie Kam -
Picture of Plugin developers

Maybe this will help someone. 

PoodLL filter, PoodLL Repository and the PoodLL Once Player. This is what I use to play an audio once (student listens to it once and then answers a quiz question). It's now on my blog too. Actually the main reason why I post it here is as a record of how I did this kind of things. I'm afraid that my memory will fade over time, and Moodle.org's forums are a form of archive for me to dig up when my gray matter fails me.

https://moodle.org/mod/forum/discuss.php?d=188758

Cheers Moodledom!
Frankie Kam