javascript pop-up window for audio

javascript pop-up window for audio

by Henry Foster -
Number of replies: 2

My problem is not really with the quiz module, but I don't know where else to post this. I am using Moodle 2.5.2. I use the Moodle with live EFL students in a classroom setting, and sometimes use quizzes for guided listening activities. We keep the multimedia plugins filter active on our site, and I have always had my students use the mini audio player that results. However, I have never liked that player because it is difficult to back up or jump forward with any accuracy. I recently discovered that I could make the audio pop up in a separate window using javascript (as below), in which case the browser's default player displays, making it easier to control the audio track.

<p>→ <a title="audio" onclick="window.open('https://dl.dropboxusercontent.com/u/.../trackname.mp3','audio','resizable=yes,width=350,height=150,left='+(screen.availWidth/2-150)+',top='+(screen.availHeight/2-100)+'');return false;" href="http://ktu-e-learn.net">Click to listen</a></p>

This is great, and I am totally satisfied with the results. However, I have found that I cannot do the same thing in a page (made with the page module). For some kinds of listening, I want to make a set of audio tracks available and would like it if each could be popped up in the way described above. When I use the same code in a page, however, clicking on the link takes you to the href; the javascript does not execute. Of course, if I put the resource URL in the href, I get the embedded mini-player and no link at all. I do not want to deactivate multimedia plugins on our site, and I do not want to put all of the audio tracks directly on the course page (where they can be made to pop up with the URL appearance settings) because there are too many of them.

How can I enable javascript in pages?

Average of ratings: -
In reply to Henry Foster

Re: javascript pop-up window for audio

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you really want this everywhere, then the best way to do it would be to change Moodle to always output the embed code you want, instead of the code Moodle automatically generates.

That is in the class core_media_player_mp3 in lib/medialib.php and it is not the simplest code ever, so that probably requires moderate PHP skills.

In reply to Tim Hunt

Re: javascript pop-up window for audio

by Henry Foster -

Thanks for the reply. I figured the answer would be something to that effect. Unfortunately, I have zero PHP skills. What I would really like, rather than a pop-up, would be for the embedded player to be more functional. A bit bigger and easier to back up, jump forward etc. accurately and robustly. Is there any way, without rewriting the core code, to change the default embedded player?