Changing playback speed of Audio or Video

mlapl1
mlapl1 Community Member Posts: 350 ♪ Opening Act ♪
Hi everyone

Is it possible to change the playback speed of an imported audio or video file (both slower and faster)? How could one do that?

Thanks

Andrew

Comments

  • mnotermans5114
    mnotermans5114 Community Member Posts: 916 ☆ Roadie ☆
    Guess you know the answer. Using javascript ;-) And some library to get that done.

    Here is a sample i did quite a while ago about spritesheets. In it a character running. Several buttons below it. Among them 2, 1 to slowdown speed and 1 to make him run faster. Click multiple times to see the effect.

    http://community.trivantis.com/shared-content/spritesheet-setup-in-lectora/

    Similar technique(s) will work for video offcourse. As the Lectora mediaplayer is based upon the Mediaelement.

    http://www.mediaelementjs.com/

    It should be possible to enhance Lectoras mediaplayer with javascript or add existing Mediaelement plugins to a project. There is for example a plugin to give the player an extra button to set the playbackspeed.

    https://github.com/mediaelement/mediaelement-plugins/blob/master/docs/speed.md

    Sounds like a interesting option. I got no clue how to add a plugin to an existing mediaelement. HTML5 video has default the playbackRate property.

    https://www.w3schools.com/tags/av_prop_playbackrate.asp

     

    For audio you offcourse need something else.
    You could for example use this audio library.

    http://community.trivantis.com/shared-content/fade-audio-in-lectora/

    Checking the documentation for Buzz
    http://buzz.jaysalvat.com/documentation/sound/

    you quickly find that there is a speed property. So you can speedup/slowdown audio with Buzz.

    Set the playback speed where 1 is normal speed, 2 is double speed, etc.
    mySound.setSpeed(2);

    Enough said i guess. With Javascript you can ;-)

    Kind regards,
    Math
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916 ☆ Roadie ☆
    Checking the default Lectora17 mediaplayer you find a tag called playbackRate in that file ( trivantis-mep.min.js )

    "playbackRate:-1,defaultPlaybackRate:-1"

    Because that is a minified javascript its quite hard to change anything inthere. You could get the mep.js from Mediaelement.com add/change things inthere and replace the trivantis-mep.min.js with that file.. should work..

    Just downloaded both Mediaelement and the plugins i mentioned. There are definately some good samples inthere of working players with speedup/speeddown options. So standalone it works. Now get it working in Lectora ;-)
    Might give that a try this week...
  • mlapl1
    mlapl1 Community Member Posts: 350 ♪ Opening Act ♪
    Terrific. Thanks a lot Math!

    Where do you find the information about the mediaplayer etc.? I would not need to bother you/the community then (maybe ;-)   )

    I don't mind Javascript in this case (or ever actually except in a few special cases - depending on who is using it). The main problem I  have with JS is that it is a client-side language and is a huge security risk when you are trying to protect people's work). It would be better to write in PHP but you would lose at least both functionality and flexibility.

    thanks again!
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916 ☆ Roadie ☆
    These 2 links you should find all needed for Mediaelement.

    http://www.mediaelementjs.com/

    https://github.com/mediaelement/mediaelement-plugins/blob/master/docs/speed.md

    Noticed it can also be used for audio playing. Not sure whether Lectora uses it for both ( i do suspect it does ). I have something i need to test/try with an audioplayer anyway. So i probably doublecheck whether mediaelement.js is used for both video and audio and do some digging...seeing if i can extend the player in L16 and 17.

    Regards,

    Math

    PS. adding a suggestion for the developers. Make it possible to extend/override scripts like this in an easy way
  • wheels
    wheels Community Member, Administrator, Moderator, Rockstar Manager Posts: 702 eLearning ROCKSTAR Admin Team
    We are looking into adding this as an option, but as Math says it can be done in JavaScript.

    I am attaching a Lectora Online Package file which can be imported into either Online or Desktop which shows an example of how you can use scripting to slow down or speed up playback.

    Hope this helps!

    - Joe
  • mlapl1
    mlapl1 Community Member Posts: 350 ♪ Opening Act ♪
    Thank you Joe. For some reason I only saw this now

    Andrew