General developer forum

 
 
Picture of Patrick Juhl
Embed VLC in moodle quiz
 

Hello moodlers!

First of all sorry if I missed to write this post in the right thread.. I didn't really see where to include it.

My question concerns the <embed> html tag and more specificaly the possibilty to use a specific player to read video files. I use moodle 2.2.2+.

I have a case where I need the users to be able to change the playback rate (2x,1/2x,1/4x speed) of audio and video they watch through my site. I have done some research and although HTML5's player allows that, it is not portable (officially only works in Chrome... IE seems to work but the page looks awful) and the quality loss when going for lower speeds, 1/2x, is unacceptable. 1/4x speed doesn't work at all for sound.

So my solution around this is to force the use of the VLC plugin which carries those functionalities and reads just about anything. In order to achieve that, I use the embed tag in the following way:

<embed type="application/x-vlc-plugin" name="video1" id="player" autoplay="true" loop="true" target="http://media.w3.org/2010/05/sintel/trailer.ogv" height="300" width="400" />

Although the player is loaded when I open my quiz page, the play button does not launch the video. When I use the console, I can see that the video is loaded in the playlist but neither the autoplay nor the play button will work. The only way I have found to start the video is to launch it manually from the console using:

document.getElementById('player').playlist.play();

Does anyone have any idea why it does that ?

Or, does anyone have any other suggestion for me ?

I have heard of the VLC plugin but it was unfortunately only out there for 1.9 and I don't really see the need for a plugin if this can be done using the <embed> tag. Though that is probably where I start being wrong..

Thanks in advance!

 

Patrick

 

 

 
Average of ratings: -
Picture of Patrick Juhl
Re: Embed VLC in moodle quiz
 

Just noted something: moodle seems to correct my HTML code by replacing the following:

autoplay="true" loop="true"

with:

autoplay="autoplay" loop="loop"

Any idea why it does that ?

Cheers!

 

Patrick

 
Average of ratings: -
Picture of Patrick Juhl
Re: Embed VLC in moodle quiz
 

Got a bit further but I am still not answering my own question ;)

It seems the VLC player I have embedded can't get access to the files uploaded via moodle. If the file is accessible locally or on the web then the player is happy, and so am I. But the files uploaded via moodle aren't working.Is there some kind of access limitation to files within moodle ? it would be surprising since the HTML player work fine...

Again, any idea anyone ?

 

Patrick

 
Average of ratings: -
Matt Bury
Re: Embed VLC in moodle quiz
Group Particularly helpful Moodlers

Hi Patrick,

I'd be surprised if you could get video to play back in a browser without using a browser plugin or the browser's native video player. You can find out more about the VLC plugin here: http://www.videolan.org/doc/play-howto/en/ch04.html#id591206

Yes, Moodle filters HTML code and, in many cases, messes it up. It's difficult to pass in full URLs the embedded apps and to get them to work as expected. Partly why a developed an MP3 player especially for Moodle that works around this problem: http://code.google.com/p/moodle-mp3-player-for-tests/

My question is, why do you want to use the VLC plugin? AFAIK, it only works for Mozilla, Firefox and Safari, and only if users have the VLC browser plugin installed. Wouldn't it be easier for them to download the media files and play them locally?

For browser playback, the obvious choice is a Flash based media player. Flash can do rudimentary time-stretch but the problems you're experiencing with poor sound quality are more likely caused by the quality of the media files. When I use time-stretched audio in my projects, I create duplicate time-stretched MP3 files from the original source WAV recordings, recorded at 48Khz 24-bit uncompressed (DVD quality). Directly time-stretching MP3 files that have been optimised for the web usually gives poor results no matter how good your media player or plugin is.

My advice is to use a Flash media player with an HTML5 fallback (for iOS devices) and provide pre-prepared duplicate media files that have been time-stretched using decent audio editing software.

I hope this helps!

 
Average of ratings: -
Picture of Patrick Juhl
Re: Embed VLC in moodle quiz
 

Hello Matt!

Thanks for the answer!

To start with, I continued a bit on the VLC plugin, trying to understand why it didn't work for moodle files. I sniffed the HTML request on my network and suprise, the GET URL sent by the player was bluntly answered with a 303 error redirecting to the moodle login page. What I get out of this is that VLC does not forward the cookie for authentication. So maybe fixing that on the VLC side would solve it ?

Concerning the file quality, the files I have are pretty decent WAV recordings and they are used for beat counting exercises (which is why I need the different playback rates). Ideally, the student would play the file using the rate of choice and fill in some cloze fields with the answers.

Also, the quality when using VLC with respect to the embeded browser was clearly better for slower speeds. And finally, I got it to work fine on Chrome as well as Firefox.

Now if it doesn't work out, the solution is probably as you said to create various files for the different playback rates and load them separatly. In which case, I think I will go for your player as it has some pretty neat functionalities I will probably be asked to include. I have tried to read my files in audacity with different rates and there the result is perfect.

Cheers,

 

Patrick

 
Average of ratings: -
Matt Bury
Re: Embed VLC in moodle quiz
Group Particularly helpful Moodlers

You're welcome smile

If you're using Audacity, be aware that by default it encodes MP3 at a variable bitrate which can cause problems for some media players. There's a box somewhere that you can check to fix the bitrate to something appropriate.

Also make sure you encode audio files to a sampling rate that's roughly divisble by 11, e.g. 22Khz, 44.1Khz, etc. This'll help avoid what's called the "chipmunk effect" whereby recordings playback faster than intended because of the difference in sampling rate.

 
Average of ratings: -
Picture of Patrick Juhl
Re: Embed VLC in moodle quiz
 

I guess there isn't many ways around it, I'll go for multiple files recorded at different rates. Thank you for the tips, I'll keep an eye on that!

Can I ask you what is your idea on using the feature from your player managing the number of hearings in a case where there are several files ?

 
Average of ratings: -
Matt Bury
Re: Embed VLC in moodle quiz
Group Particularly helpful Moodlers

Hi Patrick,

There are lots of caveats and limitations, for various reasons, in trying to control the number of times learners can listen to recordings online, e.g. they can refresh the page, they can use a download plugin, etc.

For tests there's usually a time-limit so limiting the number of time a learner can listen is more of a helpful time management device than a restriction. My rule of thumb for mutimedia is to limit it to one item per page as much as possible.

 
Average of ratings: -
Picture of Patrick Juhl
Re: Embed VLC in moodle quiz
 

Hello Matt,

I'm asking directly since you seem to have quite some insight in medias in moodle. I hope you don't mind!

As mentioned, I went for multiple files and a combobox to select the file that should be played. Now, the problem I have is that the media in chrome is not seekable at all. In Firefox, it is but only once the whole file has been loaded.

As it is, I use the <audio> tag which I thought left me a little more flexibility and improved browser compatibility. The result is quite the opposite since they all behave differently.

Here's my code so you can get an idea of what I am trying to achieve:

      <audio tabindex="0" id="audioplayer" controls="controls" loop="loop" preload="auto">

                   <source src="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_1x.mp3" type="audio/mpeg" />

      </audio>

      <form id="myForm">Speed:

      <select id="myAudioSelect" onchange="document.getElementById('audioplayer').src=document.getElementById('myAudioSelect').options[document.getElementById('myAudioSelect').selectedIndex].value;document.getElementById('audioplayer').load()">

            <option value="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_2x.mp3">2x</option>

            <option selected="selected" value="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_1x.mp3">1x</option>

            <option value="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_0.5x.mp3">1/2x</option>

            <option value="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_0.25x.mp3">1/4x</option>

            <option value="http://mymoodle.com/draftfile.php/5/user/draft/255681797/LJUD00_0.125x.mp3">1/8</option>

       </select>

       </form>

I went back to the flow player now, but it seems somewhat harder to achieve this.

Any help is welcome!

Thanks,

 

Patrick

 

 

 

 
Average of ratings: -
Matt Bury
Re: Embed VLC in moodle quiz
Group Particularly helpful Moodlers

Hi Patrick,

I haven't used the FlowPlayer much since it requires Javascript to work at all, preferring the JW Player because it can work either way, but this solution may also be possible with FlowPlayer. I use XML playlists, a subset of the SMIL specification, for instances where I want more than one file available. Here's a demo: http://moodle.matbury.com/mod/mplayer/view.php?id=632 (have a look at the page source code) and here's some documentation: http://code.google.com/p/moodle-mplayer/wiki/Playlists

I hope you'll agree, the playlist option is a bit more elegant and flexible than HTML drop-down lists.

If you're using Moodle 2.x, you'll have to hand-code the Flash embed code, and Moodle 2.x's new file API doesn't support referencing files via XML, so it's better if they're not hosted in moodledata (course files directories).

 
Average of ratings: -
Picture of William Sojo
Re: Embed VLC in moodle quiz
 

Hi Patrick,

I am a dummy for this, but first of all, you may be check the following sentence:

target=

for this one:

target=http://media.w3.org/2010/05/sintel/trailer.gov

Thanks

William

 
Average of ratings: -