mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 00:20:37 +01:00
MDL-60848 atto_recordrtc: Add recordrtc to core
Thanks also goes to Jacob Prud'homme from Blindside Networks who contributed a vast portion of this code.
This commit is contained in:
parent
2bd2660751
commit
b4bbf31bf1
2
lib/editor/atto/plugins/recordrtc/.eslintignore
Normal file
2
lib/editor/atto/plugins/recordrtc/.eslintignore
Normal file
@ -0,0 +1,2 @@
|
||||
amd/src/adapter.js
|
||||
amd/src/bowser.js
|
2
lib/editor/atto/plugins/recordrtc/.stylelintignore
Normal file
2
lib/editor/atto/plugins/recordrtc/.stylelintignore
Normal file
@ -0,0 +1,2 @@
|
||||
amd/src/adapter.js
|
||||
amd/src/bowser.js
|
101
lib/editor/atto/plugins/recordrtc/.travis.yml
Normal file
101
lib/editor/atto/plugins/recordrtc/.travis.yml
Normal file
@ -0,0 +1,101 @@
|
||||
language: php
|
||||
|
||||
# Workaround for fixing that Selenium server is not running and therefore Behat tests not working
|
||||
sudo: required
|
||||
|
||||
addons:
|
||||
firefox: "47.0.1"
|
||||
postgresql: "9.3"
|
||||
apt:
|
||||
packages:
|
||||
- oracle-java9-installer
|
||||
- oracle-java9-set-default
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
|
||||
env:
|
||||
global:
|
||||
- COVERAGE=false
|
||||
matrix:
|
||||
- MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=MOODLE_32_STABLE DB=pgsql MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=master DB=mysqli MOODLE_PLUGIN_CI=2
|
||||
- MOODLE_BRANCH=master DB=pgsql MOODLE_PLUGIN_CI=2
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.6
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.6
|
||||
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.4
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.5
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
- php: 5.6
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli MOODLE_PLUGIN_CI=1
|
||||
- php: 5.6
|
||||
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=pgsql MOODLE_PLUGIN_CI=1
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- nvm install 8.9.0
|
||||
- nvm use default
|
||||
- cd ../..
|
||||
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^${MOODLE_PLUGIN_CI}
|
||||
# Specific for version 1
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "1" ]; then
|
||||
sudo sed -i "s/ignoreNewlines = false/ignoreNewlines = true/g" "$(find ./ci/vendor -name 'OperatorSpacingSniff.php' )";
|
||||
fi
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
|
||||
script:
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
- moodle-plugin-ci phpmd
|
||||
- moodle-plugin-ci codechecker
|
||||
- moodle-plugin-ci validate
|
||||
- moodle-plugin-ci phpunit
|
||||
# Specific for version 1
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "1" ]; then moodle-plugin-ci csslint; fi
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "1" ]; then moodle-plugin-ci shifter; fi
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "1" ]; then moodle-plugin-ci jshint; fi
|
||||
# Specific for version 2
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "2" ]; then moodle-plugin-ci savepoints; fi
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "2" ]; then moodle-plugin-ci mustache; fi
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "2" ]; then moodle-plugin-ci grunt; fi
|
||||
- if [ ${MOODLE_PLUGIN_CI} = "2" ]; then moodle-plugin-ci behat --dump; fi
|
1
lib/editor/atto/plugins/recordrtc/CHANGES
Normal file
1
lib/editor/atto/plugins/recordrtc/CHANGES
Normal file
@ -0,0 +1 @@
|
||||
Bug: Fixed issue UI not properly rendered in mobiles
|
674
lib/editor/atto/plugins/recordrtc/LICENSE
Normal file
674
lib/editor/atto/plugins/recordrtc/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
86
lib/editor/atto/plugins/recordrtc/README.md
Normal file
86
lib/editor/atto/plugins/recordrtc/README.md
Normal file
@ -0,0 +1,86 @@
|
||||
# RecordRTC Atto plugin for Moodle
|
||||
|
||||
[](https://scrutinizer-ci.com/g/blindsidenetworks/moodle-atto_recordrtc/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/blindsidenetworks/moodle-atto_recordrtc/build-status/master)
|
||||
|
||||
### Features
|
||||
|
||||
Add audio and video annotations to text, anywhere an Atto text editor is present. This plugin adds buttons for recording audio or video (with audio) to the editor's toolbar. Using WebRTC technologies, all recording is done instantly in the browser, using nothing but HTML5 and JavaScript (no Flash!). After recording, users can embed the annotation directly into the text they are currently editing. The recording will appear as an audio or video player in the published writing.
|
||||
|
||||
### Installation
|
||||
|
||||
There are currently two ways to install the plugin:
|
||||
|
||||
1. Installing via zip file:
|
||||
|
||||
* Download the project's repository as a zip archive from GitHub: https://github.com/blindsidenetworks/moodle-atto_recordrtc/archive/master.zip
|
||||
* In Moodle, go to `Site administration` > `Plugins` > `Install plugins`
|
||||
* Under the `Install plugin from ZIP file` section, either select the above archive, or drag and drop it into the specified box on the page
|
||||
* Click the installation button
|
||||
|
||||
|
||||
2. Installing manually (if the user does not have necessary permissions for installing the first way):
|
||||
|
||||
* Navigate to `moodle_root_path/lib/editor/atto/plugins`, where `moodle_root_path` is the location where Moodle is installed (ex.: `/var/www/html/moodle`)
|
||||
* Execute `sudo git clone https://github.com/blindsidenetworks/moodle-atto_recordrtc.git recordrtc`
|
||||
* Log into a Moodle account with administration capabilities
|
||||
* A screen should appear asking the install the plugin, similar to above
|
||||
|
||||
Soon, there will also be the possibility to install easily via the Moodle Plugins Directory.
|
||||
|
||||
### Usage
|
||||
|
||||
To use the plugin, just click on one of the recording buttons (either the microphone or the video camera), and a popup will appear with a big "Start Recording" button. When clicked, the browser will probably ask for permission to use the webcam/microphone.
|
||||
|
||||

|
||||
|
||||
After the recording starts, a timer will begin counting down, indicating how much time is left to record; when the timer hits 0, the recording will automatically stop (this will also happen if approaching the maximum upload size determined in the server settings).
|
||||
|
||||

|
||||
|
||||
When the recording is finished, the user can play it back to see/hear if it is what they want. To embed the file, the user must click "Attach Recording as Annotation". A dialog box will pop up asking the user what the link should appear as in the text editor. After that, the file gets embedded right where the cursor was in the text.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Configuration
|
||||
|
||||
The plugin can be configured during the initial install, and later by navigating to `Site administration` > `Plugins` > `Text editors` > `Atto HTML editor` > `RecordRTC`. The administrator can:
|
||||
|
||||
* Allow the users to record only audio, only video, or both (changing the buttons that appear in the editor toolbar)
|
||||
* Change the target bitrate of recorded audio
|
||||
* Change the target bitrate of recorded video
|
||||
* Set the recording time limit, to control maximum recording size
|
||||
|
||||
### Common problems
|
||||
|
||||
* **For developers**: If trying to update Bowser or Adapter.js dependencies for the project, it is necessary to replace the named definition at the top of the file with an anonymous one, like so (for Bowser):
|
||||
|
||||
*Old code*:
|
||||
```
|
||||
!function (root, name, definition) {
|
||||
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
||||
else if (typeof define == 'function' && define.amd) define(name, definition)
|
||||
else root[name] = definition()
|
||||
}(this, 'bowser', function () {
|
||||
```
|
||||
*New code*:
|
||||
```
|
||||
define([], function() {
|
||||
```
|
||||
|
||||
Or so (for Adapter.js):
|
||||
|
||||
*Old code*
|
||||
```
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.adapter = f()}})(function(){
|
||||
```
|
||||
*New code*
|
||||
```
|
||||
define([], function() {
|
||||
```
|
||||
* The default maximum size of uploads in PHP is very small, it is recommended to set the `upload_max_filesize` setting to `40M` and the `post_max_size` setting to `50M` for a time limit of 2:00 to avoid getting an alert while recording
|
||||
* The filesize of recorded video for Firefox will likely be twice that of other browsers, even with the same settings; this is expected as it uses a different writing library for recording video. The audio filesize should be similar across all browsers
|
5
lib/editor/atto/plugins/recordrtc/RELEASENOTES
Normal file
5
lib/editor/atto/plugins/recordrtc/RELEASENOTES
Normal file
@ -0,0 +1,5 @@
|
||||
1.0-rc1 (2017080104)
|
||||
Bug: Fixed issue UI not properly rendered in mobiles
|
||||
|
||||
1.0-b4 (2017080103)
|
||||
Bug: Fixed issue icons not shown properly in the Clear theme in Moodle 3.3
|
2
lib/editor/atto/plugins/recordrtc/amd/build/adapter.min.js
vendored
Normal file
2
lib/editor/atto/plugins/recordrtc/amd/build/adapter.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
lib/editor/atto/plugins/recordrtc/amd/build/bowser.min.js
vendored
Normal file
1
lib/editor/atto/plugins/recordrtc/amd/build/bowser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3900
lib/editor/atto/plugins/recordrtc/amd/src/adapter.js
Normal file
3900
lib/editor/atto/plugins/recordrtc/amd/src/adapter.js
Normal file
File diff suppressed because it is too large
Load Diff
587
lib/editor/atto/plugins/recordrtc/amd/src/bowser.js
Normal file
587
lib/editor/atto/plugins/recordrtc/amd/src/bowser.js
Normal file
@ -0,0 +1,587 @@
|
||||
// ESLint directives.
|
||||
/* eslint-disable */
|
||||
|
||||
// JSHint directives.
|
||||
/* jshint ignore:start */
|
||||
|
||||
/*!
|
||||
* Bowser - a browser detector
|
||||
* https://github.com/ded/bowser
|
||||
* MIT License | (c) Dustin Diaz 2015
|
||||
*/
|
||||
|
||||
define([], function() {
|
||||
//!function (root, name, definition) {
|
||||
// if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
||||
// else if (typeof define == 'function' && define.amd) define(name, definition)
|
||||
// else root[name] = definition()
|
||||
//}(this, 'bowser', function () {
|
||||
/**
|
||||
* See useragents.js for examples of navigator.userAgent
|
||||
*/
|
||||
|
||||
var t = true;
|
||||
|
||||
function detect(ua) {
|
||||
|
||||
function getFirstMatch(regex) {
|
||||
var match = ua.match(regex);
|
||||
return (match && match.length > 1 && match[1]) || '';
|
||||
}
|
||||
|
||||
function getSecondMatch(regex) {
|
||||
var match = ua.match(regex);
|
||||
return (match && match.length > 1 && match[2]) || '';
|
||||
}
|
||||
|
||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
||||
, likeAndroid = /like android/i.test(ua)
|
||||
, android = !likeAndroid && /android/i.test(ua)
|
||||
, nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
|
||||
, nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
|
||||
, chromeos = /CrOS/.test(ua)
|
||||
, silk = /silk/i.test(ua)
|
||||
, sailfish = /sailfish/i.test(ua)
|
||||
, tizen = /tizen/i.test(ua)
|
||||
, webos = /(web|hpw)os/i.test(ua)
|
||||
, windowsphone = /windows phone/i.test(ua)
|
||||
, samsungBrowser = /SamsungBrowser/i.test(ua)
|
||||
, windows = !windowsphone && /windows/i.test(ua)
|
||||
, mac = !iosdevice && !silk && /macintosh/i.test(ua)
|
||||
, linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
|
||||
, edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i)
|
||||
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
|
||||
, tablet = /tablet/i.test(ua)
|
||||
, mobile = !tablet && /[^-]mobi/i.test(ua)
|
||||
, xbox = /xbox/i.test(ua)
|
||||
, result
|
||||
|
||||
if (/opera/i.test(ua)) {
|
||||
// an old Opera
|
||||
result = {
|
||||
name: 'Opera'
|
||||
, opera: t
|
||||
, version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
} else if (/opr|opios/i.test(ua)) {
|
||||
// a new Opera
|
||||
result = {
|
||||
name: 'Opera'
|
||||
, opera: t
|
||||
, version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (/SamsungBrowser/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Samsung Internet for Android'
|
||||
, samsungBrowser: t
|
||||
, version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/coast/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Opera Coast'
|
||||
, coast: t
|
||||
, version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/yabrowser/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Yandex Browser'
|
||||
, yandexbrowser: t
|
||||
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/ucbrowser/i.test(ua)) {
|
||||
result = {
|
||||
name: 'UC Browser'
|
||||
, ucbrowser: t
|
||||
, version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
|
||||
}
|
||||
}
|
||||
else if (/mxios/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Maxthon'
|
||||
, maxthon: t
|
||||
, version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
|
||||
}
|
||||
}
|
||||
else if (/epiphany/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Epiphany'
|
||||
, epiphany: t
|
||||
, version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
|
||||
}
|
||||
}
|
||||
else if (/puffin/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Puffin'
|
||||
, puffin: t
|
||||
, version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/sleipnir/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Sleipnir'
|
||||
, sleipnir: t
|
||||
, version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
|
||||
}
|
||||
}
|
||||
else if (/k-meleon/i.test(ua)) {
|
||||
result = {
|
||||
name: 'K-Meleon'
|
||||
, kMeleon: t
|
||||
, version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
|
||||
}
|
||||
}
|
||||
else if (windowsphone) {
|
||||
result = {
|
||||
name: 'Windows Phone'
|
||||
, windowsphone: t
|
||||
}
|
||||
if (edgeVersion) {
|
||||
result.msedge = t
|
||||
result.version = edgeVersion
|
||||
}
|
||||
else {
|
||||
result.msie = t
|
||||
result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/msie|trident/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Internet Explorer'
|
||||
, msie: t
|
||||
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
|
||||
}
|
||||
} else if (chromeos) {
|
||||
result = {
|
||||
name: 'Chrome'
|
||||
, chromeos: t
|
||||
, chromeBook: t
|
||||
, chrome: t
|
||||
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
} else if (/chrome.+? edge/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Microsoft Edge'
|
||||
, msedge: t
|
||||
, version: edgeVersion
|
||||
}
|
||||
}
|
||||
else if (/vivaldi/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Vivaldi'
|
||||
, vivaldi: t
|
||||
, version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (sailfish) {
|
||||
result = {
|
||||
name: 'Sailfish'
|
||||
, sailfish: t
|
||||
, version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/seamonkey\//i.test(ua)) {
|
||||
result = {
|
||||
name: 'SeaMonkey'
|
||||
, seamonkey: t
|
||||
, version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/firefox|iceweasel|fxios/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Firefox'
|
||||
, firefox: t
|
||||
, version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
|
||||
result.firefoxos = t
|
||||
}
|
||||
}
|
||||
else if (silk) {
|
||||
result = {
|
||||
name: 'Amazon Silk'
|
||||
, silk: t
|
||||
, version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/phantom/i.test(ua)) {
|
||||
result = {
|
||||
name: 'PhantomJS'
|
||||
, phantom: t
|
||||
, version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/slimerjs/i.test(ua)) {
|
||||
result = {
|
||||
name: 'SlimerJS'
|
||||
, slimer: t
|
||||
, version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
|
||||
result = {
|
||||
name: 'BlackBerry'
|
||||
, blackberry: t
|
||||
, version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (webos) {
|
||||
result = {
|
||||
name: 'WebOS'
|
||||
, webos: t
|
||||
, version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
|
||||
};
|
||||
/touchpad\//i.test(ua) && (result.touchpad = t)
|
||||
}
|
||||
else if (/bada/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Bada'
|
||||
, bada: t
|
||||
, version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
|
||||
};
|
||||
}
|
||||
else if (tizen) {
|
||||
result = {
|
||||
name: 'Tizen'
|
||||
, tizen: t
|
||||
, version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
|
||||
};
|
||||
}
|
||||
else if (/qupzilla/i.test(ua)) {
|
||||
result = {
|
||||
name: 'QupZilla'
|
||||
, qupzilla: t
|
||||
, version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (/chromium/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Chromium'
|
||||
, chromium: t
|
||||
, version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (/chrome|crios|crmo/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Chrome'
|
||||
, chrome: t
|
||||
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (android) {
|
||||
result = {
|
||||
name: 'Android'
|
||||
, version: versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (/safari|applewebkit/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Safari'
|
||||
, safari: t
|
||||
}
|
||||
if (versionIdentifier) {
|
||||
result.version = versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (iosdevice) {
|
||||
result = {
|
||||
name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
|
||||
}
|
||||
// WTF: version is not part of user agent in web apps
|
||||
if (versionIdentifier) {
|
||||
result.version = versionIdentifier
|
||||
}
|
||||
}
|
||||
else if(/googlebot/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Googlebot'
|
||||
, googlebot: t
|
||||
, version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = {
|
||||
name: getFirstMatch(/^(.*)\/(.*) /),
|
||||
version: getSecondMatch(/^(.*)\/(.*) /)
|
||||
};
|
||||
}
|
||||
|
||||
// set webkit or gecko flag for browsers based on these engines
|
||||
if (!result.msedge && /(apple)?webkit/i.test(ua)) {
|
||||
if (/(apple)?webkit\/537\.36/i.test(ua)) {
|
||||
result.name = result.name || "Blink"
|
||||
result.blink = t
|
||||
} else {
|
||||
result.name = result.name || "Webkit"
|
||||
result.webkit = t
|
||||
}
|
||||
if (!result.version && versionIdentifier) {
|
||||
result.version = versionIdentifier
|
||||
}
|
||||
} else if (!result.opera && /gecko\//i.test(ua)) {
|
||||
result.name = result.name || "Gecko"
|
||||
result.gecko = t
|
||||
result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
|
||||
// set OS flags for platforms that have multiple browsers
|
||||
if (!result.windowsphone && !result.msedge && (android || result.silk)) {
|
||||
result.android = t
|
||||
} else if (!result.windowsphone && !result.msedge && iosdevice) {
|
||||
result[iosdevice] = t
|
||||
result.ios = t
|
||||
} else if (mac) {
|
||||
result.mac = t
|
||||
} else if (xbox) {
|
||||
result.xbox = t
|
||||
} else if (windows) {
|
||||
result.windows = t
|
||||
} else if (linux) {
|
||||
result.linux = t
|
||||
}
|
||||
|
||||
// OS version extraction
|
||||
var osVersion = '';
|
||||
if (result.windowsphone) {
|
||||
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
|
||||
} else if (iosdevice) {
|
||||
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
|
||||
osVersion = osVersion.replace(/[_\s]/g, '.');
|
||||
} else if (android) {
|
||||
osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
|
||||
} else if (result.webos) {
|
||||
osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
|
||||
} else if (result.blackberry) {
|
||||
osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
|
||||
} else if (result.bada) {
|
||||
osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
|
||||
} else if (result.tizen) {
|
||||
osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
|
||||
}
|
||||
if (osVersion) {
|
||||
result.osversion = osVersion;
|
||||
}
|
||||
|
||||
// device type extraction
|
||||
var osMajorVersion = osVersion.split('.')[0];
|
||||
if (
|
||||
tablet
|
||||
|| nexusTablet
|
||||
|| iosdevice == 'ipad'
|
||||
|| (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
|
||||
|| result.silk
|
||||
) {
|
||||
result.tablet = t
|
||||
} else if (
|
||||
mobile
|
||||
|| iosdevice == 'iphone'
|
||||
|| iosdevice == 'ipod'
|
||||
|| android
|
||||
|| nexusMobile
|
||||
|| result.blackberry
|
||||
|| result.webos
|
||||
|| result.bada
|
||||
) {
|
||||
result.mobile = t
|
||||
}
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if (result.msedge ||
|
||||
(result.msie && result.version >= 10) ||
|
||||
(result.yandexbrowser && result.version >= 15) ||
|
||||
(result.vivaldi && result.version >= 1.0) ||
|
||||
(result.chrome && result.version >= 20) ||
|
||||
(result.samsungBrowser && result.version >= 4) ||
|
||||
(result.firefox && result.version >= 20.0) ||
|
||||
(result.safari && result.version >= 6) ||
|
||||
(result.opera && result.version >= 10.0) ||
|
||||
(result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
|
||||
(result.blackberry && result.version >= 10.1)
|
||||
|| (result.chromium && result.version >= 20)
|
||||
) {
|
||||
result.a = t;
|
||||
}
|
||||
else if ((result.msie && result.version < 10) ||
|
||||
(result.chrome && result.version < 20) ||
|
||||
(result.firefox && result.version < 20.0) ||
|
||||
(result.safari && result.version < 6) ||
|
||||
(result.opera && result.version < 10.0) ||
|
||||
(result.ios && result.osversion && result.osversion.split(".")[0] < 6)
|
||||
|| (result.chromium && result.version < 20)
|
||||
) {
|
||||
result.c = t
|
||||
} else result.x = t
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
|
||||
|
||||
bowser.test = function (browserList) {
|
||||
for (var i = 0; i < browserList.length; ++i) {
|
||||
var browserItem = browserList[i];
|
||||
if (typeof browserItem=== 'string') {
|
||||
if (browserItem in bowser) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version precisions count
|
||||
*
|
||||
* @example
|
||||
* getVersionPrecision("1.10.3") // 3
|
||||
*
|
||||
* @param {string} version
|
||||
* @return {number}
|
||||
*/
|
||||
function getVersionPrecision(version) {
|
||||
return version.split(".").length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array::map polyfill
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {Function} iterator
|
||||
* @return {Array}
|
||||
*/
|
||||
function map(arr, iterator) {
|
||||
var result = [], i;
|
||||
if (Array.prototype.map) {
|
||||
return Array.prototype.map.call(arr, iterator);
|
||||
}
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
result.push(iterator(arr[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate browser version weight
|
||||
*
|
||||
* @example
|
||||
* compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
|
||||
* compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
|
||||
* compareVersions(['1.10.2.1', '1.10.2.1']); // 0
|
||||
* compareVersions(['1.10.2.1', '1.0800.2']); // -1
|
||||
*
|
||||
* @param {Array<String>} versions versions to compare
|
||||
* @return {Number} comparison result
|
||||
*/
|
||||
function compareVersions(versions) {
|
||||
// 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
|
||||
var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
|
||||
var chunks = map(versions, function (version) {
|
||||
var delta = precision - getVersionPrecision(version);
|
||||
|
||||
// 2) "9" -> "9.0" (for precision = 2)
|
||||
version = version + new Array(delta + 1).join(".0");
|
||||
|
||||
// 3) "9.0" -> ["000000000"", "000000009"]
|
||||
return map(version.split("."), function (chunk) {
|
||||
return new Array(20 - chunk.length).join("0") + chunk;
|
||||
}).reverse();
|
||||
});
|
||||
|
||||
// iterate in reverse order by reversed chunks array
|
||||
while (--precision >= 0) {
|
||||
// 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
|
||||
if (chunks[0][precision] > chunks[1][precision]) {
|
||||
return 1;
|
||||
}
|
||||
else if (chunks[0][precision] === chunks[1][precision]) {
|
||||
if (precision === 0) {
|
||||
// all version chunks are same
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if browser is unsupported
|
||||
*
|
||||
* @example
|
||||
* bowser.isUnsupportedBrowser({
|
||||
* msie: "10",
|
||||
* firefox: "23",
|
||||
* chrome: "29",
|
||||
* safari: "5.1",
|
||||
* opera: "16",
|
||||
* phantom: "534"
|
||||
* });
|
||||
*
|
||||
* @param {Object} minVersions map of minimal version to browser
|
||||
* @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
|
||||
* @param {String} [ua] user agent string
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isUnsupportedBrowser(minVersions, strictMode, ua) {
|
||||
var _bowser = bowser;
|
||||
|
||||
// make strictMode param optional with ua param usage
|
||||
if (typeof strictMode === 'string') {
|
||||
ua = strictMode;
|
||||
strictMode = void(0);
|
||||
}
|
||||
|
||||
if (strictMode === void(0)) {
|
||||
strictMode = false;
|
||||
}
|
||||
if (ua) {
|
||||
_bowser = detect(ua);
|
||||
}
|
||||
|
||||
var version = "" + _bowser.version;
|
||||
for (var browser in minVersions) {
|
||||
if (minVersions.hasOwnProperty(browser)) {
|
||||
if (_bowser[browser]) {
|
||||
if (typeof minVersions[browser] !== 'string') {
|
||||
throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
|
||||
}
|
||||
|
||||
// browser version and min supported version.
|
||||
return compareVersions([version, minVersions[browser]]) < 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strictMode; // not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if browser is supported
|
||||
*
|
||||
* @param {Object} minVersions map of minimal version to browser
|
||||
* @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
|
||||
* @param {String} [ua] user agent string
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function check(minVersions, strictMode, ua) {
|
||||
return !isUnsupportedBrowser(minVersions, strictMode, ua);
|
||||
}
|
||||
|
||||
bowser.isUnsupportedBrowser = isUnsupportedBrowser;
|
||||
bowser.compareVersions = compareVersions;
|
||||
bowser.check = check;
|
||||
|
||||
/*
|
||||
* Set our detect method to the main bowser object so we can
|
||||
* reuse it to test other user agents.
|
||||
* This is needed to implement future tests.
|
||||
*/
|
||||
bowser._detect = detect;
|
||||
|
||||
return bowser;
|
||||
});
|
53
lib/editor/atto/plugins/recordrtc/db/install.php
Normal file
53
lib/editor/atto/plugins/recordrtc/db/install.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Atto install script. Adds recordrtc to the toolbar.
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Enable RecordRTC plugin buttons on installation.
|
||||
*/
|
||||
function xmldb_atto_recordrtc_install() {
|
||||
$toolbar = get_config('editor_atto', 'toolbar');
|
||||
if (strpos($toolbar, 'recordrtc') === false) {
|
||||
// Newline string changed in one of the latest versions from /n to /r/n.
|
||||
$glue = "\r\n";
|
||||
if (strpos($toolbar, $glue) === false) {
|
||||
$glue = "\n";
|
||||
}
|
||||
$groups = explode($glue, $toolbar);
|
||||
// Try to put recordrtc in files group.
|
||||
foreach ($groups as $i => $group) {
|
||||
$parts = explode('=', $group);
|
||||
if (trim($parts[0]) == 'files') {
|
||||
$groups[$i] = 'files = ' . trim($parts[1]) . ', recordrtc';
|
||||
// Update config variable.
|
||||
$toolbar = implode($glue, $groups);
|
||||
set_config('toolbar', $toolbar, 'editor_atto');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
79
lib/editor/atto/plugins/recordrtc/lang/en/atto_recordrtc.php
Executable file
79
lib/editor/atto/plugins/recordrtc/lang/en/atto_recordrtc.php
Executable file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'atto_recordrtc', language 'en'.
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'RecordRTC';
|
||||
$string['settings'] = 'RecordRTC settings';
|
||||
$string['audiortc'] = 'Insert audio recording';
|
||||
$string['videortc'] = 'Insert video recording';
|
||||
|
||||
$string['onlyaudio'] = 'Audio only';
|
||||
$string['onlyvideo'] = 'Video only';
|
||||
$string['both'] = 'Audio and Video';
|
||||
$string['allowedtypes'] = 'Allowed types';
|
||||
$string['allowedtypes_desc'] = 'Which recording buttons should appear in Atto';
|
||||
$string['audiobitrate'] = 'Audio bitrate';
|
||||
$string['audiobitrate_desc'] = 'Quality of audio recording (larger number means higher quality)';
|
||||
$string['videobitrate'] = 'Video bitrate';
|
||||
$string['videobitrate_desc'] = 'Quality of video recording (larger number means higher quality)';
|
||||
$string['timelimit'] = 'Time limit in seconds';
|
||||
$string['timelimit_desc'] = 'Maximum recording length allowed for the audio/video clips';
|
||||
|
||||
$string['nowebrtc_title'] = 'WebRTC not supported';
|
||||
$string['nowebrtc'] = 'Your browser offers limited or no support for WebRTC technologies yet, and cannot be used with this plugin. Please switch or upgrade your browser';
|
||||
$string['gumabort_title'] = 'Something happened';
|
||||
$string['gumabort'] = 'Something strange happened which prevented the webcam/microphone from being used';
|
||||
$string['gumnotallowed_title'] = 'Wrong permissions';
|
||||
$string['gumnotallowed'] = 'The user must allow the browser access to the webcam/microphone';
|
||||
$string['gumnotfound_title'] = 'Device missing';
|
||||
$string['gumnotfound'] = 'There is no input device connected or enabled';
|
||||
$string['gumnotreadable_title'] = 'Hardware error';
|
||||
$string['gumnotreadable'] = 'Something is preventing the browser from accessing the webcam/microphone';
|
||||
$string['gumoverconstrained_title'] = 'Problem with constraints';
|
||||
$string['gumoverconstrained'] = 'The current webcam/microphone can not produce a stream with the required constraints';
|
||||
$string['gumsecurity_title'] = 'No support for insecure connection';
|
||||
$string['gumsecurity'] = 'Your browser does not support recording over an insecure connection and must close the plugin';
|
||||
$string['gumtype_title'] = 'No constraints specified';
|
||||
$string['gumtype'] = 'Tried to get stream from the webcam/microphone, but no constraints were specified';
|
||||
$string['insecurealert_title'] = 'Insecure connection!';
|
||||
$string['insecurealert'] = 'Your browser might not allow this plugin to work unless it is used either over HTTPS or from localhost';
|
||||
$string['browseralert_title'] = 'Warning!';
|
||||
$string['browseralert'] = 'Use Firefox >= 29, Chrome >= 49 or Opera >= 36 for best experience';
|
||||
$string['startrecording'] = 'Start Recording';
|
||||
$string['recordagain'] = 'Record Again';
|
||||
$string['stoprecording'] = 'Stop Recording';
|
||||
$string['recordingfailed'] = 'Recording failed, try again';
|
||||
$string['attachrecording'] = 'Attach Recording as Annotation';
|
||||
$string['norecordingfound_title'] = 'No recording found';
|
||||
$string['norecordingfound'] = 'Something appears to have gone wrong, it seems nothing has been recorded';
|
||||
$string['nearingmaxsize_title'] = 'Recording stopped';
|
||||
$string['nearingmaxsize'] = 'You have attained the maximum size limit for file uploads';
|
||||
$string['uploadprogress'] = 'completed';
|
||||
$string['uploadfailed'] = 'Upload failed:';
|
||||
$string['uploadfailed404'] = 'Upload failed: file too large';
|
||||
$string['uploadaborted'] = 'Upload aborted:';
|
||||
$string['annotationprompt'] = 'What should the annotation appear as?';
|
||||
$string['annotation:audio'] = 'Audio annotation';
|
||||
$string['annotation:video'] = 'Video annotation';
|
126
lib/editor/atto/plugins/recordrtc/lib.php
Normal file
126
lib/editor/atto/plugins/recordrtc/lib.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Set params for this plugin.
|
||||
*
|
||||
* @param string $elementid
|
||||
* @param stdClass $options - the options for the editor, including the context.
|
||||
* @param stdClass $fpoptions - unused.
|
||||
*/
|
||||
function atto_recordrtc_params_for_js($elementid, $options, $fpoptions) {
|
||||
global $CFG;
|
||||
|
||||
$moodleversion = intval($CFG->version, 10);
|
||||
$moodle32 = 2016120500;
|
||||
|
||||
$context = $options['context'];
|
||||
if (!$context) {
|
||||
$context = context_system::instance();
|
||||
}
|
||||
$sesskey = sesskey();
|
||||
$allowedtypes = get_config('atto_recordrtc', 'allowedtypes');
|
||||
$audiobitrate = get_config('atto_recordrtc', 'audiobitrate');
|
||||
$videobitrate = get_config('atto_recordrtc', 'videobitrate');
|
||||
$timelimit = get_config('atto_recordrtc', 'timelimit');
|
||||
$maxrecsize = ini_get('upload_max_filesize');
|
||||
$audiortcicon = 'i/audiortc';
|
||||
$videortcicon = 'i/videortc';
|
||||
$params = array('contextid' => $context->id,
|
||||
'sesskey' => $sesskey,
|
||||
'allowedtypes' => $allowedtypes,
|
||||
'audiobitrate' => $audiobitrate,
|
||||
'videobitrate' => $videobitrate,
|
||||
'timelimit' => $timelimit,
|
||||
'audiortcicon' => $audiortcicon,
|
||||
'videortcicon' => $videortcicon,
|
||||
'oldermoodle' => $moodleversion < $moodle32,
|
||||
'maxrecsize' => $maxrecsize
|
||||
);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the js strings required for this module.
|
||||
*/
|
||||
function atto_recordrtc_strings_for_js() {
|
||||
global $PAGE;
|
||||
|
||||
$strings = array('audiortc',
|
||||
'videortc',
|
||||
'nowebrtc_title',
|
||||
'nowebrtc',
|
||||
'gumabort_title',
|
||||
'gumabort',
|
||||
'gumnotallowed_title',
|
||||
'gumnotallowed',
|
||||
'gumnotfound_title',
|
||||
'gumnotfound',
|
||||
'gumnotreadable_title',
|
||||
'gumnotreadable',
|
||||
'gumoverconstrained_title',
|
||||
'gumoverconstrained',
|
||||
'gumsecurity_title',
|
||||
'gumsecurity',
|
||||
'gumtype_title',
|
||||
'gumtype',
|
||||
'insecurealert_title',
|
||||
'insecurealert',
|
||||
'browseralert_title',
|
||||
'browseralert',
|
||||
'startrecording',
|
||||
'recordagain',
|
||||
'stoprecording',
|
||||
'recordingfailed',
|
||||
'attachrecording',
|
||||
'norecordingfound_title',
|
||||
'norecordingfound',
|
||||
'nearingmaxsize_title',
|
||||
'nearingmaxsize',
|
||||
'uploadprogress',
|
||||
'uploadfailed',
|
||||
'uploadfailed404',
|
||||
'uploadaborted',
|
||||
'annotationprompt',
|
||||
'annotation:audio',
|
||||
'annotation:video'
|
||||
);
|
||||
|
||||
$PAGE->requires->strings_for_js($strings, 'atto_recordrtc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Map icons for font-awesome themes.
|
||||
*/
|
||||
function atto_recordrtc_get_fontawesome_icon_map() {
|
||||
return [
|
||||
'atto_recordrtc:i/audiortc' => 'fa-file-audio-o',
|
||||
'atto_recordrtc:i/videortc' => 'fa-file-video-o'
|
||||
];
|
||||
}
|
BIN
lib/editor/atto/plugins/recordrtc/pix/i/audiortc.png
Normal file
BIN
lib/editor/atto/plugins/recordrtc/pix/i/audiortc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 B |
BIN
lib/editor/atto/plugins/recordrtc/pix/i/videortc.png
Normal file
BIN
lib/editor/atto/plugins/recordrtc/pix/i/videortc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 B |
BIN
lib/editor/atto/plugins/recordrtc/pix/icon.png
Normal file
BIN
lib/editor/atto/plugins/recordrtc/pix/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 644 B |
64
lib/editor/atto/plugins/recordrtc/settings.php
Normal file
64
lib/editor/atto/plugins/recordrtc/settings.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Settings that allow turning on and off recordrtc features
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$ADMIN->add('editoratto', new admin_category('atto_recordrtc', new lang_string('pluginname', 'atto_recordrtc')));
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
// Types allowed.
|
||||
$options = array(
|
||||
'both' => new lang_string('both', 'atto_recordrtc'),
|
||||
'audio' => new lang_string('onlyaudio', 'atto_recordrtc'),
|
||||
'video' => new lang_string('onlyvideo', 'atto_recordrtc')
|
||||
);
|
||||
$name = get_string('allowedtypes', 'atto_recordrtc');
|
||||
$desc = get_string('allowedtypes_desc', 'atto_recordrtc');
|
||||
$default = '';
|
||||
$setting = new admin_setting_configselect('atto_recordrtc/allowedtypes', $name, $desc, $default, $options);
|
||||
$settings->add($setting);
|
||||
|
||||
// Audio bitrate.
|
||||
$name = get_string('audiobitrate', 'atto_recordrtc');
|
||||
$desc = get_string('audiobitrate_desc', 'atto_recordrtc');
|
||||
$default = '128000';
|
||||
$setting = new admin_setting_configtext('atto_recordrtc/audiobitrate', $name, $desc, $default, PARAM_INT, 8);
|
||||
$settings->add($setting);
|
||||
|
||||
// Video bitrate.
|
||||
$name = get_string('videobitrate', 'atto_recordrtc');
|
||||
$desc = get_string('videobitrate_desc', 'atto_recordrtc');
|
||||
$default = '2500000';
|
||||
$setting = new admin_setting_configtext('atto_recordrtc/videobitrate', $name, $desc, $default, PARAM_INT, 8);
|
||||
$settings->add($setting);
|
||||
|
||||
// Recording time limit.
|
||||
$name = get_string('timelimit', 'atto_recordrtc');
|
||||
$desc = get_string('timelimit_desc', 'atto_recordrtc');
|
||||
$default = '120';
|
||||
$setting = new admin_setting_configtext('atto_recordrtc/timelimit', $name, $desc, $default, PARAM_INT, 8);
|
||||
$settings->add($setting);
|
||||
}
|
39
lib/editor/atto/plugins/recordrtc/styles.css
Normal file
39
lib/editor/atto/plugins/recordrtc/styles.css
Normal file
@ -0,0 +1,39 @@
|
||||
.atto_recordrtc,
|
||||
.atto_recordrtc div {
|
||||
font-weight: normal;
|
||||
line-height: 40px;
|
||||
padding: 3px 0 3px 0;
|
||||
}
|
||||
|
||||
.atto_recordrtc .alert {
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.atto_recordrtc audio {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 670px) {
|
||||
.atto_recordrtc video {
|
||||
display: block;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 671px) {
|
||||
.atto_recordrtc video {
|
||||
display: block;
|
||||
height: 480px;
|
||||
margin: 0 auto;
|
||||
width: 640px;
|
||||
}
|
||||
}
|
||||
|
||||
.atto_recordrtc #start-stop,
|
||||
.atto_recordrtc #upload {
|
||||
white-space: normal;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
@editor @editor_atto @atto @recordrtc @atto_recordrtc @atto_recordrtc_installed
|
||||
Feature: Installation succeeds
|
||||
In order to use this plugin
|
||||
As a user
|
||||
I need the installation to work
|
||||
|
||||
Scenario: Check the Plugins overview for the name of this plugin
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins overview" node in "Site administration > Plugins"
|
||||
Then the following should exist in the "plugins-control-panel" table:
|
||||
|RecordRTC|
|
||||
|atto_recordrtc|
|
17
lib/editor/atto/plugins/recordrtc/thirdpartylibs.xml
Normal file
17
lib/editor/atto/plugins/recordrtc/thirdpartylibs.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<libraries>
|
||||
<library>
|
||||
<location>amd/src</location>
|
||||
<name>Bowser</name>
|
||||
<version>1.6.0</version>
|
||||
<license>MIT</license>
|
||||
<licenseversion></licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
<location>amd/src</location>
|
||||
<name>WebRTC adapter</name>
|
||||
<version>4.1.0</version>
|
||||
<license>BSD</license>
|
||||
<licenseversion>3-Clause</licenseversion>
|
||||
</library>
|
||||
</libraries>
|
33
lib/editor/atto/plugins/recordrtc/version.php
Normal file
33
lib/editor/atto/plugins/recordrtc/version.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Atto text editor recordrtc version file.
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2017080104;
|
||||
$plugin->requires = 2015051100;
|
||||
$plugin->component = 'atto_recordrtc';
|
||||
$plugin->maturity = MATURITY_RC;
|
||||
$plugin->release = '1.0-rc';
|
@ -0,0 +1,380 @@
|
||||
YUI.add('moodle-atto_recordrtc-button', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module moodle-atto_recordrtc-button
|
||||
*/
|
||||
|
||||
/**
|
||||
* Atto text editor recordrtc plugin.
|
||||
*
|
||||
* @namespace M.atto_recordrtc
|
||||
* @class button
|
||||
* @extends M.editor_atto.EditorPlugin
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint onevar: false */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: Y */
|
||||
/** global: M */
|
||||
|
||||
var PLUGINNAME = 'atto_recordrtc',
|
||||
TEMPLATE = '' +
|
||||
'<div class="{{PLUGINNAME}} container-fluid">' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-warning" class="alert {{bs_al_warn}}">' +
|
||||
'<strong>{{browseralert_title}}</strong> {{browseralert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-danger" class="alert {{bs_al_dang}}">' +
|
||||
'<strong>{{insecurealert_title}}</strong> {{insecurealert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'{{#if isAudio}}' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<audio id="player"></audio>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'{{else}}' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<video id="player"></video>' +
|
||||
'</div>' +
|
||||
'{{/if}}' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}}">' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<button id="start-stop" class="{{bs_ss_btn}}">{{startrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'<div class="{{bs_col}}6">' +
|
||||
'<button id="upload" class="btn btn-primary btn-block">{{attachrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
|
||||
/**
|
||||
* The current language by default.
|
||||
*/
|
||||
_lang: 'en',
|
||||
|
||||
initializer: function() {
|
||||
if (this.get('host').canShowFilepicker('media')) {
|
||||
// Add audio and/or video buttons depending on the settings.
|
||||
var allowedtypes = this.get('allowedtypes');
|
||||
if (allowedtypes === 'both' || allowedtypes === 'audio') {
|
||||
this._addButton('audio', this._audio);
|
||||
}
|
||||
if (allowedtypes === 'both' || allowedtypes === 'video') {
|
||||
this._addButton('video', this._video);
|
||||
}
|
||||
|
||||
// Initialize the dialogue box.
|
||||
var dialogue = this.getDialogue({
|
||||
width: 1000,
|
||||
focusAfterHide: null
|
||||
});
|
||||
|
||||
// If dialogue is closed during recording, do the following.
|
||||
dialogue.after('visibleChange', function() {
|
||||
var closed = !dialogue.get('visible'),
|
||||
m = M.atto_recordrtc.commonmodule;
|
||||
|
||||
if (closed) {
|
||||
window.clearInterval(m.countdownTicker);
|
||||
|
||||
if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') {
|
||||
m.mediaRecorder.stop();
|
||||
}
|
||||
|
||||
if (m.stream) {
|
||||
m.stream.getTracks().forEach(function(track) {
|
||||
if (track.readyState !== 'ended') {
|
||||
track.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
dialogue.on('click', function() {
|
||||
this.centered();
|
||||
});
|
||||
|
||||
// Require Bowser and adapter.js libraries.
|
||||
window.require(['atto_recordrtc/adapter'], function(adapter) {
|
||||
window.adapter = adapter;
|
||||
});
|
||||
window.require(['atto_recordrtc/bowser'], function(bowser) {
|
||||
window.bowser = bowser;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the buttons to the Atto toolbar.
|
||||
*
|
||||
* @method _addButton
|
||||
* @param {string} type
|
||||
* @param {callback} callback
|
||||
* @private
|
||||
*/
|
||||
_addButton: function(type, callback) {
|
||||
this.addButton({
|
||||
buttonName: type,
|
||||
icon: this.get(type + 'rtcicon'),
|
||||
iconComponent: PLUGINNAME,
|
||||
callback: callback,
|
||||
title: type + 'rtc',
|
||||
tags: type + 'rtc',
|
||||
tagMatchRequiresAll: false
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle audiortc and normal display mode
|
||||
*
|
||||
* @method _audio
|
||||
* @private
|
||||
*/
|
||||
_audio: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('audiortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('audio'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.audiomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle videortc and normal display mode
|
||||
*
|
||||
* @method _video
|
||||
* @private
|
||||
*/
|
||||
_video: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('videortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('video'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.videomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create the HTML to be displayed in the dialogue box
|
||||
*
|
||||
* @method _createContent
|
||||
* @param {string} type
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
_createContent: function(type) {
|
||||
var isAudio = (type === 'audio'),
|
||||
bsRow = this.get('oldermoodle') ? 'row-fluid' : 'row',
|
||||
bsCol = this.get('oldermoodle') ? 'span' : 'col-xs-',
|
||||
bsAlWarn = this.get('oldermoodle') ? '' : 'alert-warning',
|
||||
bsAlDang = this.get('oldermoodle') ? 'alert-error' : 'alert-danger',
|
||||
bsSsBtn = this.get('oldermoodle') ? 'btn btn-large btn-danger btn-block'
|
||||
: 'btn btn-lg btn-outline-danger btn-block';
|
||||
|
||||
var bodyContent = Y.Handlebars.compile(TEMPLATE)({
|
||||
PLUGINNAME: PLUGINNAME,
|
||||
isAudio: isAudio,
|
||||
bs_row: bsRow,
|
||||
bs_col: bsCol,
|
||||
bs_al_warn: bsAlWarn,
|
||||
bs_al_dang: bsAlDang,
|
||||
bs_ss_btn: bsSsBtn,
|
||||
bs_ul_btn: 'btn btn-primary btn-block',
|
||||
browseralert_title: M.util.get_string('browseralert_title', 'atto_recordrtc'),
|
||||
browseralert: M.util.get_string('browseralert', 'atto_recordrtc'),
|
||||
insecurealert_title: M.util.get_string('insecurealert_title', 'atto_recordrtc'),
|
||||
insecurealert: M.util.get_string('insecurealert', 'atto_recordrtc'),
|
||||
startrecording: M.util.get_string('startrecording', 'atto_recordrtc'),
|
||||
attachrecording: M.util.get_string('attachrecording', 'atto_recordrtc')
|
||||
});
|
||||
|
||||
return bodyContent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the dialogue without further action.
|
||||
*
|
||||
* @method closeDialogue
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
*/
|
||||
closeDialogue: function(scope) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert the annotation link in the editor.
|
||||
*
|
||||
* @method setLink
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
* @param {string} annotation The HTML link to the recording.
|
||||
*/
|
||||
setLink: function(scope, annotation) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
scope.get('host').insertContentAtFocusPoint(annotation);
|
||||
scope.markUpdated();
|
||||
}
|
||||
}, {
|
||||
ATTRS: {
|
||||
/**
|
||||
* The contextid to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute contextid
|
||||
* @type String
|
||||
*/
|
||||
contextid: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The sesskey to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute sesskey
|
||||
* @type String
|
||||
*/
|
||||
sesskey: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The allowedtypes to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute allowedtypes
|
||||
* @type String
|
||||
*/
|
||||
allowedtypes: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiobitrate
|
||||
* @type String
|
||||
*/
|
||||
audiobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videobitrate
|
||||
* @type String
|
||||
*/
|
||||
videobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The timelimit to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute timelimit
|
||||
* @type String
|
||||
*/
|
||||
timelimit: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiortcicon
|
||||
* @type String
|
||||
*/
|
||||
audiortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videortcicon
|
||||
* @type String
|
||||
*/
|
||||
videortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* True if Moodle is version < 3.2.
|
||||
*
|
||||
* @attribute oldermoodle
|
||||
* @type Boolean
|
||||
*/
|
||||
oldermoodle: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum upload size set on server, in MB.
|
||||
*
|
||||
* @attribute maxrecsize
|
||||
* @type String
|
||||
*/
|
||||
maxrecsize: {
|
||||
value: null
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin", "moodle-atto_recordrtc-recording"]});
|
@ -0,0 +1 @@
|
||||
YUI.add("moodle-atto_recordrtc-button",function(e,t){var n="atto_recordrtc",r='<div class="{{PLUGINNAME}} container-fluid"><div class="{{bs_row}} hide"><div class="{{bs_col}}12"><div id="alert-warning" class="alert {{bs_al_warn}}"><strong>{{browseralert_title}}</strong> {{browseralert}}</div></div></div><div class="{{bs_row}} hide"><div class="{{bs_col}}12"><div id="alert-danger" class="alert {{bs_al_dang}}"><strong>{{insecurealert_title}}</strong> {{insecurealert}}</div></div></div><div class="{{bs_row}} hide">{{#if isAudio}}<div class="{{bs_col}}1"></div><div class="{{bs_col}}10"><audio id="player"></audio></div><div class="{{bs_col}}1"></div>{{else}}<div class="{{bs_col}}12"><video id="player"></video></div>{{/if}}</div><div class="{{bs_row}}"><div class="{{bs_col}}1"></div><div class="{{bs_col}}10"><button id="start-stop" class="{{bs_ss_btn}}">{{startrecording}}</button></div><div class="{{bs_col}}1"></div></div><div class="{{bs_row}} hide"><div class="{{bs_col}}3"></div><div class="{{bs_col}}6"><button id="upload" class="btn btn-primary btn-block">{{attachrecording}}</button></div><div class="{{bs_col}}3"></div></div></div>';e.namespace("M.atto_recordrtc").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_lang:"en",initializer:function(){if(this.get("host").canShowFilepicker("media")){var e=this.get("allowedtypes");(e==="both"||e==="audio")&&this._addButton("audio",this._audio),(e==="both"||e==="video")&&this._addButton("video",this._video);var t=this.getDialogue({width:1e3,focusAfterHide:null});t.after("visibleChange",function(){var e=!t.get("visible"),n=M.atto_recordrtc.commonmodule;e&&(window.clearInterval(n.countdownTicker),n.mediaRecorder&&n.mediaRecorder.state!=="inactive"&&n.mediaRecorder.stop(),n.stream&&n.stream.getTracks().forEach(function(e){e.readyState!=="ended"&&e.stop()}))}),t.on("click",function(){this.centered()}),window.require(["atto_recordrtc/adapter"],function(e){window.adapter=e}),window.require(["atto_recordrtc/bowser"],function(e){window.bowser=e})}},_addButton:function(e,t){this.addButton({buttonName:e,icon:this.get(e+"rtcicon"),iconComponent:n,callback:t,title:e+"rtc",tags:e+"rtc",tagMatchRequiresAll:!1})},_audio:function(){var e=this.getDialogue();e.set("headerContent",M.util.get_string("audiortc","atto_recordrtc")),e.set("bodyContent",this._createContent("audio")),e.show(),M.atto_recordrtc.audiomodule.init(this)},_video:function(){var e=this.getDialogue();e.set("headerContent",M.util.get_string("videortc","atto_recordrtc")),e.set("bodyContent",this._createContent("video")),e.show(),M.atto_recordrtc.videomodule.init(this)},_createContent:function(t){var i=t==="audio",s=this.get("oldermoodle")?"row-fluid":"row",o=this.get("oldermoodle")?"span":"col-xs-",u=this.get("oldermoodle")?"":"alert-warning",a=this.get("oldermoodle")?"alert-error":"alert-danger",f=this.get("oldermoodle")?"btn btn-large btn-danger btn-block":"btn btn-lg btn-outline-danger btn-block",l=e.Handlebars.compile(r)({PLUGINNAME:n,isAudio:i,bs_row:s,bs_col:o,bs_al_warn:u,bs_al_dang:a,bs_ss_btn:f,bs_ul_btn:"btn btn-primary btn-block",browseralert_title:M.util.get_string("browseralert_title","atto_recordrtc"),browseralert:M.util.get_string("browseralert","atto_recordrtc"),insecurealert_title:M.util.get_string("insecurealert_title","atto_recordrtc"),insecurealert:M.util.get_string("insecurealert","atto_recordrtc"),startrecording:M.util.get_string("startrecording","atto_recordrtc"),attachrecording:M.util.get_string("attachrecording","atto_recordrtc")});return l},closeDialogue:function(e){e.getDialogue().hide(),e.editor.focus()},setLink:function(e,t){e.getDialogue().hide(),e.editor.focus(),e.get("host").insertContentAtFocusPoint(t),e.markUpdated()}},{ATTRS:{contextid:{value:null},sesskey:{value:null},allowedtypes:{value:null},audiobitrate:{value:null},videobitrate:{value:null},timelimit:{value:null},audiortcicon:{value:null},videortcicon:{value:null},oldermoodle:{value:null},maxrecsize:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","moodle-atto_recordrtc-recording"]});
|
@ -0,0 +1,380 @@
|
||||
YUI.add('moodle-atto_recordrtc-button', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module moodle-atto_recordrtc-button
|
||||
*/
|
||||
|
||||
/**
|
||||
* Atto text editor recordrtc plugin.
|
||||
*
|
||||
* @namespace M.atto_recordrtc
|
||||
* @class button
|
||||
* @extends M.editor_atto.EditorPlugin
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint onevar: false */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: Y */
|
||||
/** global: M */
|
||||
|
||||
var PLUGINNAME = 'atto_recordrtc',
|
||||
TEMPLATE = '' +
|
||||
'<div class="{{PLUGINNAME}} container-fluid">' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-warning" class="alert {{bs_al_warn}}">' +
|
||||
'<strong>{{browseralert_title}}</strong> {{browseralert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-danger" class="alert {{bs_al_dang}}">' +
|
||||
'<strong>{{insecurealert_title}}</strong> {{insecurealert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'{{#if isAudio}}' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<audio id="player"></audio>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'{{else}}' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<video id="player"></video>' +
|
||||
'</div>' +
|
||||
'{{/if}}' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}}">' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<button id="start-stop" class="{{bs_ss_btn}}">{{startrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'<div class="{{bs_col}}6">' +
|
||||
'<button id="upload" class="btn btn-primary btn-block">{{attachrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
|
||||
/**
|
||||
* The current language by default.
|
||||
*/
|
||||
_lang: 'en',
|
||||
|
||||
initializer: function() {
|
||||
if (this.get('host').canShowFilepicker('media')) {
|
||||
// Add audio and/or video buttons depending on the settings.
|
||||
var allowedtypes = this.get('allowedtypes');
|
||||
if (allowedtypes === 'both' || allowedtypes === 'audio') {
|
||||
this._addButton('audio', this._audio);
|
||||
}
|
||||
if (allowedtypes === 'both' || allowedtypes === 'video') {
|
||||
this._addButton('video', this._video);
|
||||
}
|
||||
|
||||
// Initialize the dialogue box.
|
||||
var dialogue = this.getDialogue({
|
||||
width: 1000,
|
||||
focusAfterHide: null
|
||||
});
|
||||
|
||||
// If dialogue is closed during recording, do the following.
|
||||
dialogue.after('visibleChange', function() {
|
||||
var closed = !dialogue.get('visible'),
|
||||
m = M.atto_recordrtc.commonmodule;
|
||||
|
||||
if (closed) {
|
||||
window.clearInterval(m.countdownTicker);
|
||||
|
||||
if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') {
|
||||
m.mediaRecorder.stop();
|
||||
}
|
||||
|
||||
if (m.stream) {
|
||||
m.stream.getTracks().forEach(function(track) {
|
||||
if (track.readyState !== 'ended') {
|
||||
track.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
dialogue.on('click', function() {
|
||||
this.centered();
|
||||
});
|
||||
|
||||
// Require Bowser and adapter.js libraries.
|
||||
window.require(['atto_recordrtc/adapter'], function(adapter) {
|
||||
window.adapter = adapter;
|
||||
});
|
||||
window.require(['atto_recordrtc/bowser'], function(bowser) {
|
||||
window.bowser = bowser;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the buttons to the Atto toolbar.
|
||||
*
|
||||
* @method _addButton
|
||||
* @param {string} type
|
||||
* @param {callback} callback
|
||||
* @private
|
||||
*/
|
||||
_addButton: function(type, callback) {
|
||||
this.addButton({
|
||||
buttonName: type,
|
||||
icon: this.get(type + 'rtcicon'),
|
||||
iconComponent: PLUGINNAME,
|
||||
callback: callback,
|
||||
title: type + 'rtc',
|
||||
tags: type + 'rtc',
|
||||
tagMatchRequiresAll: false
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle audiortc and normal display mode
|
||||
*
|
||||
* @method _audio
|
||||
* @private
|
||||
*/
|
||||
_audio: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('audiortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('audio'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.audiomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle videortc and normal display mode
|
||||
*
|
||||
* @method _video
|
||||
* @private
|
||||
*/
|
||||
_video: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('videortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('video'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.videomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create the HTML to be displayed in the dialogue box
|
||||
*
|
||||
* @method _createContent
|
||||
* @param {string} type
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
_createContent: function(type) {
|
||||
var isAudio = (type === 'audio'),
|
||||
bsRow = this.get('oldermoodle') ? 'row-fluid' : 'row',
|
||||
bsCol = this.get('oldermoodle') ? 'span' : 'col-xs-',
|
||||
bsAlWarn = this.get('oldermoodle') ? '' : 'alert-warning',
|
||||
bsAlDang = this.get('oldermoodle') ? 'alert-error' : 'alert-danger',
|
||||
bsSsBtn = this.get('oldermoodle') ? 'btn btn-large btn-danger btn-block'
|
||||
: 'btn btn-lg btn-outline-danger btn-block';
|
||||
|
||||
var bodyContent = Y.Handlebars.compile(TEMPLATE)({
|
||||
PLUGINNAME: PLUGINNAME,
|
||||
isAudio: isAudio,
|
||||
bs_row: bsRow,
|
||||
bs_col: bsCol,
|
||||
bs_al_warn: bsAlWarn,
|
||||
bs_al_dang: bsAlDang,
|
||||
bs_ss_btn: bsSsBtn,
|
||||
bs_ul_btn: 'btn btn-primary btn-block',
|
||||
browseralert_title: M.util.get_string('browseralert_title', 'atto_recordrtc'),
|
||||
browseralert: M.util.get_string('browseralert', 'atto_recordrtc'),
|
||||
insecurealert_title: M.util.get_string('insecurealert_title', 'atto_recordrtc'),
|
||||
insecurealert: M.util.get_string('insecurealert', 'atto_recordrtc'),
|
||||
startrecording: M.util.get_string('startrecording', 'atto_recordrtc'),
|
||||
attachrecording: M.util.get_string('attachrecording', 'atto_recordrtc')
|
||||
});
|
||||
|
||||
return bodyContent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the dialogue without further action.
|
||||
*
|
||||
* @method closeDialogue
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
*/
|
||||
closeDialogue: function(scope) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert the annotation link in the editor.
|
||||
*
|
||||
* @method setLink
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
* @param {string} annotation The HTML link to the recording.
|
||||
*/
|
||||
setLink: function(scope, annotation) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
scope.get('host').insertContentAtFocusPoint(annotation);
|
||||
scope.markUpdated();
|
||||
}
|
||||
}, {
|
||||
ATTRS: {
|
||||
/**
|
||||
* The contextid to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute contextid
|
||||
* @type String
|
||||
*/
|
||||
contextid: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The sesskey to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute sesskey
|
||||
* @type String
|
||||
*/
|
||||
sesskey: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The allowedtypes to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute allowedtypes
|
||||
* @type String
|
||||
*/
|
||||
allowedtypes: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiobitrate
|
||||
* @type String
|
||||
*/
|
||||
audiobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videobitrate
|
||||
* @type String
|
||||
*/
|
||||
videobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The timelimit to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute timelimit
|
||||
* @type String
|
||||
*/
|
||||
timelimit: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiortcicon
|
||||
* @type String
|
||||
*/
|
||||
audiortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videortcicon
|
||||
* @type String
|
||||
*/
|
||||
videortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* True if Moodle is version < 3.2.
|
||||
*
|
||||
* @attribute oldermoodle
|
||||
* @type Boolean
|
||||
*/
|
||||
oldermoodle: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum upload size set on server, in MB.
|
||||
*
|
||||
* @attribute maxrecsize
|
||||
* @type String
|
||||
*/
|
||||
maxrecsize: {
|
||||
value: null
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin", "moodle-atto_recordrtc-recording"]});
|
@ -0,0 +1,832 @@
|
||||
YUI.add('moodle-atto_recordrtc-recording', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, no-alert, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint es5: true */
|
||||
/*jshint onevar: false */
|
||||
/*jshint shadow: true */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to M.atto_recordrtc.commonmodule namespace.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.commonmodule = {
|
||||
// Unitialized variables to be used by the other modules.
|
||||
editorScope: null,
|
||||
alertWarning: null,
|
||||
alertDanger: null,
|
||||
player: null,
|
||||
playerDOM: null, // Used to manipulate DOM directly.
|
||||
startStopBtn: null,
|
||||
uploadBtn: null,
|
||||
countdownSeconds: null,
|
||||
countdownTicker: null,
|
||||
recType: null,
|
||||
stream: null,
|
||||
mediaRecorder: null,
|
||||
chunks: null,
|
||||
blobSize: null,
|
||||
olderMoodle: null,
|
||||
maxUploadSize: null,
|
||||
|
||||
// Capture webcam/microphone stream.
|
||||
capture_user_media: function(mediaConstraints, successCallback, errorCallback) {
|
||||
window.navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
|
||||
},
|
||||
|
||||
// Add chunks of audio/video to array when made available.
|
||||
handle_data_available: function(event) {
|
||||
// Push recording slice to array.
|
||||
cm.chunks.push(event.data);
|
||||
// Size of all recorded data so far.
|
||||
cm.blobSize += event.data.size;
|
||||
|
||||
// If total size of recording so far exceeds max upload limit, stop recording.
|
||||
// An extra condition exists to avoid displaying alert twice.
|
||||
if (cm.blobSize >= cm.maxUploadSize) {
|
||||
if (!window.localStorage.getItem('alerted')) {
|
||||
window.localStorage.setItem('alerted', 'true');
|
||||
|
||||
cm.startStopBtn.simulate('click');
|
||||
am.show_alert('nearingmaxsize');
|
||||
} else {
|
||||
window.localStorage.removeItem('alerted');
|
||||
}
|
||||
|
||||
cm.chunks.pop();
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording end.
|
||||
handle_stop: function() {
|
||||
// Set source of audio player.
|
||||
var blob = new window.Blob(cm.chunks, {type: cm.mediaRecorder.mimeType});
|
||||
cm.player.set('src', window.URL.createObjectURL(blob));
|
||||
|
||||
// Show audio player with controls enabled, and unmute.
|
||||
cm.player.set('muted', false);
|
||||
cm.player.set('controls', true);
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
// Show upload button.
|
||||
cm.uploadBtn.ancestor().ancestor().removeClass('hide');
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
|
||||
// Handle when upload button is clicked.
|
||||
cm.uploadBtn.on('click', function() {
|
||||
// Trigger error if no recording has been made.
|
||||
if (cm.chunks.length === 0) {
|
||||
am.show_alert('norecordingfound');
|
||||
} else {
|
||||
cm.uploadBtn.set('disabled', true);
|
||||
|
||||
// Upload recording to server.
|
||||
cm.upload_to_server(cm.recType, function(progress, fileURLOrError) {
|
||||
if (progress === 'ended') { // Insert annotation in text.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.insert_annotation(cm.recType, fileURLOrError);
|
||||
} else if (progress === 'upload-failed') { // Show error message in upload button.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadfailed', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else if (progress === 'upload-failed-404') { // 404 error = File too large in Moodle.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('uploadfailed404', 'atto_recordrtc'));
|
||||
} else if (progress === 'upload-aborted') {
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadaborted', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else {
|
||||
cm.uploadBtn.set('textContent', progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Get everything set up to start recording.
|
||||
start_recording: function(type, stream) {
|
||||
// The options for the recording codecs and bitrates.
|
||||
var options = am.select_rec_options(type);
|
||||
cm.mediaRecorder = new window.MediaRecorder(stream, options);
|
||||
|
||||
// Initialize MediaRecorder events and start recording.
|
||||
cm.mediaRecorder.ondataavailable = cm.handle_data_available;
|
||||
cm.mediaRecorder.onstop = cm.handle_stop;
|
||||
cm.mediaRecorder.start(1000); // Capture in 1s chunks. Must be set to work with Firefox.
|
||||
|
||||
// Mute audio, distracting while recording.
|
||||
cm.player.set('muted', true);
|
||||
|
||||
// Set recording timer to the time specified in the settings.
|
||||
cm.countdownSeconds = cm.editorScope.get('timelimit');
|
||||
cm.countdownSeconds++;
|
||||
var timerText = M.util.get_string('stoprecording', 'atto_recordrtc');
|
||||
timerText += ' (<span id="minutes"></span>:<span id="seconds"></span>)';
|
||||
cm.startStopBtn.setHTML(timerText);
|
||||
cm.set_time();
|
||||
cm.countdownTicker = window.setInterval(cm.set_time, 1000);
|
||||
|
||||
// Make button clickable again, to allow stopping recording.
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
},
|
||||
|
||||
// Get everything set up to stop recording.
|
||||
stop_recording: function(stream) {
|
||||
// Stop recording stream.
|
||||
cm.mediaRecorder.stop();
|
||||
|
||||
// Stop each individual MediaTrack.
|
||||
var tracks = stream.getTracks();
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
tracks[i].stop();
|
||||
}
|
||||
},
|
||||
|
||||
// Upload recorded audio/video to server.
|
||||
upload_to_server: function(type, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
// Get src media of audio/video tag.
|
||||
xhr.open('GET', cm.player.get('src'), true);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) { // If src media was successfully retrieved.
|
||||
// blob is now the media that the audio/video tag's src pointed to.
|
||||
var blob = this.response;
|
||||
|
||||
// Generate filename with random ID and file extension.
|
||||
var fileName = (Math.random() * 1000).toString().replace('.', '');
|
||||
fileName += (type === 'audio') ? '-audio.ogg'
|
||||
: '-video.webm';
|
||||
|
||||
// Create FormData to send to PHP filepicker-upload script.
|
||||
var formData = new window.FormData(),
|
||||
filepickerOptions = cm.editorScope.get('host').get('filepickeroptions').link,
|
||||
repositoryKeys = window.Object.keys(filepickerOptions.repositories);
|
||||
|
||||
formData.append('repo_upload_file', blob, fileName);
|
||||
formData.append('itemid', filepickerOptions.itemid);
|
||||
|
||||
for (var i = 0; i < repositoryKeys.length; i++) {
|
||||
if (filepickerOptions.repositories[repositoryKeys[i]].type === 'upload') {
|
||||
formData.append('repo_id', filepickerOptions.repositories[repositoryKeys[i]].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
formData.append('env', filepickerOptions.env);
|
||||
formData.append('sesskey', M.cfg.sesskey);
|
||||
formData.append('client_id', filepickerOptions.client_id);
|
||||
formData.append('savepath', '/');
|
||||
formData.append('ctx_id', filepickerOptions.context.id);
|
||||
|
||||
// Pass FormData to PHP script using XHR.
|
||||
var uploadEndpoint = M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload';
|
||||
cm.make_xmlhttprequest(uploadEndpoint, formData,
|
||||
function(progress, responseText) {
|
||||
if (progress === 'upload-ended') {
|
||||
callback('ended', window.JSON.parse(responseText).url);
|
||||
} else {
|
||||
callback(progress);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
// Handle XHR sending/receiving/status.
|
||||
make_xmlhttprequest: function(url, data, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if ((xhr.readyState === 4) && (xhr.status === 200)) { // When request is finished and successful.
|
||||
callback('upload-ended', xhr.responseText);
|
||||
} else if (xhr.status === 404) { // When request returns 404 Not Found.
|
||||
callback('upload-failed-404');
|
||||
}
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = function(event) {
|
||||
callback(Math.round(event.loaded / event.total * 100) + "% " + M.util.get_string('uploadprogress', 'atto_recordrtc'));
|
||||
};
|
||||
|
||||
xhr.upload.onerror = function(error) {
|
||||
callback('upload-failed', error);
|
||||
};
|
||||
|
||||
xhr.upload.onabort = function(error) {
|
||||
callback('upload-aborted', error);
|
||||
};
|
||||
|
||||
// POST FormData to PHP script that handles uploading/saving.
|
||||
xhr.open('POST', url);
|
||||
xhr.send(data);
|
||||
},
|
||||
|
||||
// Makes 1min and 2s display as 1:02 on timer instead of 1:2, for example.
|
||||
pad: function(val) {
|
||||
var valString = val + "";
|
||||
|
||||
if (valString.length < 2) {
|
||||
return "0" + valString;
|
||||
} else {
|
||||
return valString;
|
||||
}
|
||||
},
|
||||
|
||||
// Functionality to make recording timer count down.
|
||||
// Also makes recording stop when time limit is hit.
|
||||
set_time: function() {
|
||||
cm.countdownSeconds--;
|
||||
|
||||
cm.startStopBtn.one('span#seconds').set('textContent', cm.pad(cm.countdownSeconds % 60));
|
||||
cm.startStopBtn.one('span#minutes').set('textContent', cm.pad(window.parseInt(cm.countdownSeconds / 60, 10)));
|
||||
|
||||
if (cm.countdownSeconds === 0) {
|
||||
cm.startStopBtn.simulate('click');
|
||||
}
|
||||
},
|
||||
|
||||
// Generates link to recorded annotation to be inserted.
|
||||
create_annotation: function(type, recording_url) {
|
||||
var linkText = window.prompt(M.util.get_string('annotationprompt', 'atto_recordrtc'),
|
||||
M.util.get_string('annotation:' + type, 'atto_recordrtc'));
|
||||
|
||||
// Return HTML for annotation link, if user did not press "Cancel".
|
||||
if (!linkText) {
|
||||
return undefined;
|
||||
} else {
|
||||
var annotation = '<a target="_blank" href="' + recording_url + '">' + linkText + '</a>';
|
||||
return annotation;
|
||||
}
|
||||
},
|
||||
|
||||
// Inserts link to annotation in editor text area.
|
||||
insert_annotation: function(type, recording_url) {
|
||||
var annotation = cm.create_annotation(type, recording_url);
|
||||
|
||||
// Insert annotation link.
|
||||
// If user pressed "Cancel", just go back to main recording screen.
|
||||
if (!annotation) {
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
} else {
|
||||
cm.editorScope.setLink(cm.editorScope, annotation);
|
||||
}
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for checking browser compatibility
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.compatcheckmodule = {
|
||||
// Show alert and close plugin if browser does not support WebRTC at all.
|
||||
check_has_gum: function() {
|
||||
if (!(navigator.mediaDevices && window.MediaRecorder)) {
|
||||
am.show_alert('nowebrtc', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Notify and redirect user if plugin is used from insecure location.
|
||||
check_secure: function() {
|
||||
var isSecureOrigin = (window.location.protocol === 'https:') ||
|
||||
(window.location.host.indexOf('localhost') !== -1);
|
||||
|
||||
if (!isSecureOrigin) {
|
||||
cm.alertDanger.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
if (window.bowser.chrome || window.bowser.opera) {
|
||||
am.show_alert('gumsecurity', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Display "consider switching browsers" message if not using:
|
||||
// - Firefox 29+;
|
||||
// - Chrome 49+;
|
||||
// - Opera 36+.
|
||||
check_browser: function() {
|
||||
if (!((window.bowser.firefox && window.bowser.version >= 29) ||
|
||||
(window.bowser.chrome && window.bowser.version >= 49) ||
|
||||
(window.bowser.opera && window.bowser.version >= 36))) {
|
||||
cm.alertWarning.ancestor().ancestor().removeClass('hide');
|
||||
}
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for function abstractions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.abstractmodule = {
|
||||
// A helper for making a Moodle alert appear.
|
||||
// Subject is the content of the alert (which error ther alert is for).
|
||||
// Possibility to add on-alert-close event.
|
||||
show_alert: function(subject, onCloseEvent) {
|
||||
Y.use('moodle-core-notification-alert', function() {
|
||||
var dialogue = new M.core.alert({
|
||||
title: M.util.get_string(subject + '_title', 'atto_recordrtc'),
|
||||
message: M.util.get_string(subject, 'atto_recordrtc')
|
||||
});
|
||||
|
||||
if (onCloseEvent) {
|
||||
dialogue.after('complete', onCloseEvent);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Handle getUserMedia errors.
|
||||
handle_gum_errors: function(error, commonConfig) {
|
||||
var btnLabel = M.util.get_string('recordingfailed', 'atto_recordrtc'),
|
||||
treatAsStopped = function() {
|
||||
commonConfig.onMediaStopped(btnLabel);
|
||||
};
|
||||
|
||||
// Changes 'CertainError' -> 'gumcertain' to match language string names.
|
||||
var stringName = 'gum' + error.name.replace('Error', '').toLowerCase();
|
||||
|
||||
// After alert, proceed to treat as stopped recording, or close dialogue.
|
||||
if (stringName !== 'gumsecurity') {
|
||||
am.show_alert(stringName, treatAsStopped);
|
||||
} else {
|
||||
am.show_alert(stringName, function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Select best options for the recording codec.
|
||||
select_rec_options: function(recType) {
|
||||
var types, options;
|
||||
|
||||
if (recType === 'audio') {
|
||||
types = [
|
||||
'audio/webm;codecs=opus',
|
||||
'audio/ogg;codecs=opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate'))
|
||||
};
|
||||
} else {
|
||||
types = [
|
||||
'video/webm;codecs=vp9,opus',
|
||||
'video/webm;codecs=h264,opus',
|
||||
'video/webm;codecs=vp8,opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate')),
|
||||
videoBitsPerSecond: window.parseInt(cm.editorScope.get('videobitrate'))
|
||||
};
|
||||
}
|
||||
|
||||
var compatTypes = types.filter(function(type) {
|
||||
return window.MediaRecorder.isTypeSupported(type);
|
||||
});
|
||||
|
||||
if (compatTypes.length !== 0) {
|
||||
options.mimeType = compatTypes[0];
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.audiomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('audio#player');
|
||||
cm.playerDOM = document.querySelector('audio#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'audio';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the audio player and upload button are not shown.
|
||||
cm.player.ancestor().ancestor().addClass('hide');
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make audio stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Capture audio stream from microphone.
|
||||
M.atto_recordrtc.audiomodule.capture_audio(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio stream from microphone.
|
||||
capture_audio: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioStream) {
|
||||
// Set audio player source to microphone stream.
|
||||
cm.playerDOM.srcObject = audioStream;
|
||||
|
||||
config.onMediaCaptured(audioStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.videomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('video#player');
|
||||
cm.playerDOM = document.querySelector('video#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'video';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the upload button is not shown.
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make video stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Show video tag without controls to view webcam stream.
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
cm.player.set('controls', false);
|
||||
|
||||
// Capture audio+video stream from webcam/microphone.
|
||||
M.atto_recordrtc.videomodule.capture_audio_video(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio+video stream from microphone/webcam.
|
||||
capture_audio_video: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true,
|
||||
video: {
|
||||
width: {ideal: 640},
|
||||
height: {ideal: 480}
|
||||
}
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioVideoStream) {
|
||||
// Set video player source to microphone+webcam stream, and play it back as it's recording.
|
||||
cm.playerDOM.srcObject = audioVideoStream;
|
||||
cm.playerDOM.play();
|
||||
|
||||
config.onMediaCaptured(audioVideoStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-atto_recordrtc-button"]});
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,832 @@
|
||||
YUI.add('moodle-atto_recordrtc-recording', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, no-alert, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint es5: true */
|
||||
/*jshint onevar: false */
|
||||
/*jshint shadow: true */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to M.atto_recordrtc.commonmodule namespace.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.commonmodule = {
|
||||
// Unitialized variables to be used by the other modules.
|
||||
editorScope: null,
|
||||
alertWarning: null,
|
||||
alertDanger: null,
|
||||
player: null,
|
||||
playerDOM: null, // Used to manipulate DOM directly.
|
||||
startStopBtn: null,
|
||||
uploadBtn: null,
|
||||
countdownSeconds: null,
|
||||
countdownTicker: null,
|
||||
recType: null,
|
||||
stream: null,
|
||||
mediaRecorder: null,
|
||||
chunks: null,
|
||||
blobSize: null,
|
||||
olderMoodle: null,
|
||||
maxUploadSize: null,
|
||||
|
||||
// Capture webcam/microphone stream.
|
||||
capture_user_media: function(mediaConstraints, successCallback, errorCallback) {
|
||||
window.navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
|
||||
},
|
||||
|
||||
// Add chunks of audio/video to array when made available.
|
||||
handle_data_available: function(event) {
|
||||
// Push recording slice to array.
|
||||
cm.chunks.push(event.data);
|
||||
// Size of all recorded data so far.
|
||||
cm.blobSize += event.data.size;
|
||||
|
||||
// If total size of recording so far exceeds max upload limit, stop recording.
|
||||
// An extra condition exists to avoid displaying alert twice.
|
||||
if (cm.blobSize >= cm.maxUploadSize) {
|
||||
if (!window.localStorage.getItem('alerted')) {
|
||||
window.localStorage.setItem('alerted', 'true');
|
||||
|
||||
cm.startStopBtn.simulate('click');
|
||||
am.show_alert('nearingmaxsize');
|
||||
} else {
|
||||
window.localStorage.removeItem('alerted');
|
||||
}
|
||||
|
||||
cm.chunks.pop();
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording end.
|
||||
handle_stop: function() {
|
||||
// Set source of audio player.
|
||||
var blob = new window.Blob(cm.chunks, {type: cm.mediaRecorder.mimeType});
|
||||
cm.player.set('src', window.URL.createObjectURL(blob));
|
||||
|
||||
// Show audio player with controls enabled, and unmute.
|
||||
cm.player.set('muted', false);
|
||||
cm.player.set('controls', true);
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
// Show upload button.
|
||||
cm.uploadBtn.ancestor().ancestor().removeClass('hide');
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
|
||||
// Handle when upload button is clicked.
|
||||
cm.uploadBtn.on('click', function() {
|
||||
// Trigger error if no recording has been made.
|
||||
if (cm.chunks.length === 0) {
|
||||
am.show_alert('norecordingfound');
|
||||
} else {
|
||||
cm.uploadBtn.set('disabled', true);
|
||||
|
||||
// Upload recording to server.
|
||||
cm.upload_to_server(cm.recType, function(progress, fileURLOrError) {
|
||||
if (progress === 'ended') { // Insert annotation in text.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.insert_annotation(cm.recType, fileURLOrError);
|
||||
} else if (progress === 'upload-failed') { // Show error message in upload button.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadfailed', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else if (progress === 'upload-failed-404') { // 404 error = File too large in Moodle.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('uploadfailed404', 'atto_recordrtc'));
|
||||
} else if (progress === 'upload-aborted') {
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadaborted', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else {
|
||||
cm.uploadBtn.set('textContent', progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Get everything set up to start recording.
|
||||
start_recording: function(type, stream) {
|
||||
// The options for the recording codecs and bitrates.
|
||||
var options = am.select_rec_options(type);
|
||||
cm.mediaRecorder = new window.MediaRecorder(stream, options);
|
||||
|
||||
// Initialize MediaRecorder events and start recording.
|
||||
cm.mediaRecorder.ondataavailable = cm.handle_data_available;
|
||||
cm.mediaRecorder.onstop = cm.handle_stop;
|
||||
cm.mediaRecorder.start(1000); // Capture in 1s chunks. Must be set to work with Firefox.
|
||||
|
||||
// Mute audio, distracting while recording.
|
||||
cm.player.set('muted', true);
|
||||
|
||||
// Set recording timer to the time specified in the settings.
|
||||
cm.countdownSeconds = cm.editorScope.get('timelimit');
|
||||
cm.countdownSeconds++;
|
||||
var timerText = M.util.get_string('stoprecording', 'atto_recordrtc');
|
||||
timerText += ' (<span id="minutes"></span>:<span id="seconds"></span>)';
|
||||
cm.startStopBtn.setHTML(timerText);
|
||||
cm.set_time();
|
||||
cm.countdownTicker = window.setInterval(cm.set_time, 1000);
|
||||
|
||||
// Make button clickable again, to allow stopping recording.
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
},
|
||||
|
||||
// Get everything set up to stop recording.
|
||||
stop_recording: function(stream) {
|
||||
// Stop recording stream.
|
||||
cm.mediaRecorder.stop();
|
||||
|
||||
// Stop each individual MediaTrack.
|
||||
var tracks = stream.getTracks();
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
tracks[i].stop();
|
||||
}
|
||||
},
|
||||
|
||||
// Upload recorded audio/video to server.
|
||||
upload_to_server: function(type, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
// Get src media of audio/video tag.
|
||||
xhr.open('GET', cm.player.get('src'), true);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) { // If src media was successfully retrieved.
|
||||
// blob is now the media that the audio/video tag's src pointed to.
|
||||
var blob = this.response;
|
||||
|
||||
// Generate filename with random ID and file extension.
|
||||
var fileName = (Math.random() * 1000).toString().replace('.', '');
|
||||
fileName += (type === 'audio') ? '-audio.ogg'
|
||||
: '-video.webm';
|
||||
|
||||
// Create FormData to send to PHP filepicker-upload script.
|
||||
var formData = new window.FormData(),
|
||||
filepickerOptions = cm.editorScope.get('host').get('filepickeroptions').link,
|
||||
repositoryKeys = window.Object.keys(filepickerOptions.repositories);
|
||||
|
||||
formData.append('repo_upload_file', blob, fileName);
|
||||
formData.append('itemid', filepickerOptions.itemid);
|
||||
|
||||
for (var i = 0; i < repositoryKeys.length; i++) {
|
||||
if (filepickerOptions.repositories[repositoryKeys[i]].type === 'upload') {
|
||||
formData.append('repo_id', filepickerOptions.repositories[repositoryKeys[i]].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
formData.append('env', filepickerOptions.env);
|
||||
formData.append('sesskey', M.cfg.sesskey);
|
||||
formData.append('client_id', filepickerOptions.client_id);
|
||||
formData.append('savepath', '/');
|
||||
formData.append('ctx_id', filepickerOptions.context.id);
|
||||
|
||||
// Pass FormData to PHP script using XHR.
|
||||
var uploadEndpoint = M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload';
|
||||
cm.make_xmlhttprequest(uploadEndpoint, formData,
|
||||
function(progress, responseText) {
|
||||
if (progress === 'upload-ended') {
|
||||
callback('ended', window.JSON.parse(responseText).url);
|
||||
} else {
|
||||
callback(progress);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
// Handle XHR sending/receiving/status.
|
||||
make_xmlhttprequest: function(url, data, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if ((xhr.readyState === 4) && (xhr.status === 200)) { // When request is finished and successful.
|
||||
callback('upload-ended', xhr.responseText);
|
||||
} else if (xhr.status === 404) { // When request returns 404 Not Found.
|
||||
callback('upload-failed-404');
|
||||
}
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = function(event) {
|
||||
callback(Math.round(event.loaded / event.total * 100) + "% " + M.util.get_string('uploadprogress', 'atto_recordrtc'));
|
||||
};
|
||||
|
||||
xhr.upload.onerror = function(error) {
|
||||
callback('upload-failed', error);
|
||||
};
|
||||
|
||||
xhr.upload.onabort = function(error) {
|
||||
callback('upload-aborted', error);
|
||||
};
|
||||
|
||||
// POST FormData to PHP script that handles uploading/saving.
|
||||
xhr.open('POST', url);
|
||||
xhr.send(data);
|
||||
},
|
||||
|
||||
// Makes 1min and 2s display as 1:02 on timer instead of 1:2, for example.
|
||||
pad: function(val) {
|
||||
var valString = val + "";
|
||||
|
||||
if (valString.length < 2) {
|
||||
return "0" + valString;
|
||||
} else {
|
||||
return valString;
|
||||
}
|
||||
},
|
||||
|
||||
// Functionality to make recording timer count down.
|
||||
// Also makes recording stop when time limit is hit.
|
||||
set_time: function() {
|
||||
cm.countdownSeconds--;
|
||||
|
||||
cm.startStopBtn.one('span#seconds').set('textContent', cm.pad(cm.countdownSeconds % 60));
|
||||
cm.startStopBtn.one('span#minutes').set('textContent', cm.pad(window.parseInt(cm.countdownSeconds / 60, 10)));
|
||||
|
||||
if (cm.countdownSeconds === 0) {
|
||||
cm.startStopBtn.simulate('click');
|
||||
}
|
||||
},
|
||||
|
||||
// Generates link to recorded annotation to be inserted.
|
||||
create_annotation: function(type, recording_url) {
|
||||
var linkText = window.prompt(M.util.get_string('annotationprompt', 'atto_recordrtc'),
|
||||
M.util.get_string('annotation:' + type, 'atto_recordrtc'));
|
||||
|
||||
// Return HTML for annotation link, if user did not press "Cancel".
|
||||
if (!linkText) {
|
||||
return undefined;
|
||||
} else {
|
||||
var annotation = '<a target="_blank" href="' + recording_url + '">' + linkText + '</a>';
|
||||
return annotation;
|
||||
}
|
||||
},
|
||||
|
||||
// Inserts link to annotation in editor text area.
|
||||
insert_annotation: function(type, recording_url) {
|
||||
var annotation = cm.create_annotation(type, recording_url);
|
||||
|
||||
// Insert annotation link.
|
||||
// If user pressed "Cancel", just go back to main recording screen.
|
||||
if (!annotation) {
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
} else {
|
||||
cm.editorScope.setLink(cm.editorScope, annotation);
|
||||
}
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for checking browser compatibility
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.compatcheckmodule = {
|
||||
// Show alert and close plugin if browser does not support WebRTC at all.
|
||||
check_has_gum: function() {
|
||||
if (!(navigator.mediaDevices && window.MediaRecorder)) {
|
||||
am.show_alert('nowebrtc', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Notify and redirect user if plugin is used from insecure location.
|
||||
check_secure: function() {
|
||||
var isSecureOrigin = (window.location.protocol === 'https:') ||
|
||||
(window.location.host.indexOf('localhost') !== -1);
|
||||
|
||||
if (!isSecureOrigin) {
|
||||
cm.alertDanger.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
if (window.bowser.chrome || window.bowser.opera) {
|
||||
am.show_alert('gumsecurity', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Display "consider switching browsers" message if not using:
|
||||
// - Firefox 29+;
|
||||
// - Chrome 49+;
|
||||
// - Opera 36+.
|
||||
check_browser: function() {
|
||||
if (!((window.bowser.firefox && window.bowser.version >= 29) ||
|
||||
(window.bowser.chrome && window.bowser.version >= 49) ||
|
||||
(window.bowser.opera && window.bowser.version >= 36))) {
|
||||
cm.alertWarning.ancestor().ancestor().removeClass('hide');
|
||||
}
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for function abstractions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.abstractmodule = {
|
||||
// A helper for making a Moodle alert appear.
|
||||
// Subject is the content of the alert (which error ther alert is for).
|
||||
// Possibility to add on-alert-close event.
|
||||
show_alert: function(subject, onCloseEvent) {
|
||||
Y.use('moodle-core-notification-alert', function() {
|
||||
var dialogue = new M.core.alert({
|
||||
title: M.util.get_string(subject + '_title', 'atto_recordrtc'),
|
||||
message: M.util.get_string(subject, 'atto_recordrtc')
|
||||
});
|
||||
|
||||
if (onCloseEvent) {
|
||||
dialogue.after('complete', onCloseEvent);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Handle getUserMedia errors.
|
||||
handle_gum_errors: function(error, commonConfig) {
|
||||
var btnLabel = M.util.get_string('recordingfailed', 'atto_recordrtc'),
|
||||
treatAsStopped = function() {
|
||||
commonConfig.onMediaStopped(btnLabel);
|
||||
};
|
||||
|
||||
// Changes 'CertainError' -> 'gumcertain' to match language string names.
|
||||
var stringName = 'gum' + error.name.replace('Error', '').toLowerCase();
|
||||
|
||||
// After alert, proceed to treat as stopped recording, or close dialogue.
|
||||
if (stringName !== 'gumsecurity') {
|
||||
am.show_alert(stringName, treatAsStopped);
|
||||
} else {
|
||||
am.show_alert(stringName, function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Select best options for the recording codec.
|
||||
select_rec_options: function(recType) {
|
||||
var types, options;
|
||||
|
||||
if (recType === 'audio') {
|
||||
types = [
|
||||
'audio/webm;codecs=opus',
|
||||
'audio/ogg;codecs=opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate'))
|
||||
};
|
||||
} else {
|
||||
types = [
|
||||
'video/webm;codecs=vp9,opus',
|
||||
'video/webm;codecs=h264,opus',
|
||||
'video/webm;codecs=vp8,opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate')),
|
||||
videoBitsPerSecond: window.parseInt(cm.editorScope.get('videobitrate'))
|
||||
};
|
||||
}
|
||||
|
||||
var compatTypes = types.filter(function(type) {
|
||||
return window.MediaRecorder.isTypeSupported(type);
|
||||
});
|
||||
|
||||
if (compatTypes.length !== 0) {
|
||||
options.mimeType = compatTypes[0];
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.audiomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('audio#player');
|
||||
cm.playerDOM = document.querySelector('audio#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'audio';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the audio player and upload button are not shown.
|
||||
cm.player.ancestor().ancestor().addClass('hide');
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make audio stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Capture audio stream from microphone.
|
||||
M.atto_recordrtc.audiomodule.capture_audio(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio stream from microphone.
|
||||
capture_audio: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioStream) {
|
||||
// Set audio player source to microphone stream.
|
||||
cm.playerDOM.srcObject = audioStream;
|
||||
|
||||
config.onMediaCaptured(audioStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.videomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('video#player');
|
||||
cm.playerDOM = document.querySelector('video#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'video';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the upload button is not shown.
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make video stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Show video tag without controls to view webcam stream.
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
cm.player.set('controls', false);
|
||||
|
||||
// Capture audio+video stream from webcam/microphone.
|
||||
M.atto_recordrtc.videomodule.capture_audio_video(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio+video stream from microphone/webcam.
|
||||
capture_audio_video: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true,
|
||||
video: {
|
||||
width: {ideal: 640},
|
||||
height: {ideal: 480}
|
||||
}
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioVideoStream) {
|
||||
// Set video player source to microphone+webcam stream, and play it back as it's recording.
|
||||
cm.playerDOM.srcObject = audioVideoStream;
|
||||
cm.playerDOM.play();
|
||||
|
||||
config.onMediaCaptured(audioVideoStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-atto_recordrtc-button"]});
|
10
lib/editor/atto/plugins/recordrtc/yui/src/button/build.json
Executable file
10
lib/editor/atto/plugins/recordrtc/yui/src/button/build.json
Executable file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "moodle-atto_recordrtc-button",
|
||||
"builds": {
|
||||
"moodle-atto_recordrtc-button": {
|
||||
"jsfiles": [
|
||||
"button.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
375
lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js
vendored
Executable file
375
lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js
vendored
Executable file
@ -0,0 +1,375 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module moodle-atto_recordrtc-button
|
||||
*/
|
||||
|
||||
/**
|
||||
* Atto text editor recordrtc plugin.
|
||||
*
|
||||
* @namespace M.atto_recordrtc
|
||||
* @class button
|
||||
* @extends M.editor_atto.EditorPlugin
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint onevar: false */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: Y */
|
||||
/** global: M */
|
||||
|
||||
var PLUGINNAME = 'atto_recordrtc',
|
||||
TEMPLATE = '' +
|
||||
'<div class="{{PLUGINNAME}} container-fluid">' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-warning" class="alert {{bs_al_warn}}">' +
|
||||
'<strong>{{browseralert_title}}</strong> {{browseralert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<div id="alert-danger" class="alert {{bs_al_dang}}">' +
|
||||
'<strong>{{insecurealert_title}}</strong> {{insecurealert}}' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'{{#if isAudio}}' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<audio id="player"></audio>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'{{else}}' +
|
||||
'<div class="{{bs_col}}12">' +
|
||||
'<video id="player"></video>' +
|
||||
'</div>' +
|
||||
'{{/if}}' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}}">' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'<div class="{{bs_col}}10">' +
|
||||
'<button id="start-stop" class="{{bs_ss_btn}}">{{startrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}1"></div>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_row}} hide">' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'<div class="{{bs_col}}6">' +
|
||||
'<button id="upload" class="btn btn-primary btn-block">{{attachrecording}}</button>' +
|
||||
'</div>' +
|
||||
'<div class="{{bs_col}}3"></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
|
||||
/**
|
||||
* The current language by default.
|
||||
*/
|
||||
_lang: 'en',
|
||||
|
||||
initializer: function() {
|
||||
if (this.get('host').canShowFilepicker('media')) {
|
||||
// Add audio and/or video buttons depending on the settings.
|
||||
var allowedtypes = this.get('allowedtypes');
|
||||
if (allowedtypes === 'both' || allowedtypes === 'audio') {
|
||||
this._addButton('audio', this._audio);
|
||||
}
|
||||
if (allowedtypes === 'both' || allowedtypes === 'video') {
|
||||
this._addButton('video', this._video);
|
||||
}
|
||||
|
||||
// Initialize the dialogue box.
|
||||
var dialogue = this.getDialogue({
|
||||
width: 1000,
|
||||
focusAfterHide: null
|
||||
});
|
||||
|
||||
// If dialogue is closed during recording, do the following.
|
||||
dialogue.after('visibleChange', function() {
|
||||
var closed = !dialogue.get('visible'),
|
||||
m = M.atto_recordrtc.commonmodule;
|
||||
|
||||
if (closed) {
|
||||
window.clearInterval(m.countdownTicker);
|
||||
|
||||
if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') {
|
||||
m.mediaRecorder.stop();
|
||||
}
|
||||
|
||||
if (m.stream) {
|
||||
m.stream.getTracks().forEach(function(track) {
|
||||
if (track.readyState !== 'ended') {
|
||||
track.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
dialogue.on('click', function() {
|
||||
this.centered();
|
||||
});
|
||||
|
||||
// Require Bowser and adapter.js libraries.
|
||||
window.require(['atto_recordrtc/adapter'], function(adapter) {
|
||||
window.adapter = adapter;
|
||||
});
|
||||
window.require(['atto_recordrtc/bowser'], function(bowser) {
|
||||
window.bowser = bowser;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the buttons to the Atto toolbar.
|
||||
*
|
||||
* @method _addButton
|
||||
* @param {string} type
|
||||
* @param {callback} callback
|
||||
* @private
|
||||
*/
|
||||
_addButton: function(type, callback) {
|
||||
this.addButton({
|
||||
buttonName: type,
|
||||
icon: this.get(type + 'rtcicon'),
|
||||
iconComponent: PLUGINNAME,
|
||||
callback: callback,
|
||||
title: type + 'rtc',
|
||||
tags: type + 'rtc',
|
||||
tagMatchRequiresAll: false
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle audiortc and normal display mode
|
||||
*
|
||||
* @method _audio
|
||||
* @private
|
||||
*/
|
||||
_audio: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('audiortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('audio'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.audiomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle videortc and normal display mode
|
||||
*
|
||||
* @method _video
|
||||
* @private
|
||||
*/
|
||||
_video: function() {
|
||||
var dialogue = this.getDialogue();
|
||||
|
||||
dialogue.set('headerContent', M.util.get_string('videortc', 'atto_recordrtc'));
|
||||
dialogue.set('bodyContent', this._createContent('video'));
|
||||
|
||||
dialogue.show();
|
||||
|
||||
M.atto_recordrtc.videomodule.init(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create the HTML to be displayed in the dialogue box
|
||||
*
|
||||
* @method _createContent
|
||||
* @param {string} type
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
_createContent: function(type) {
|
||||
var isAudio = (type === 'audio'),
|
||||
bsRow = this.get('oldermoodle') ? 'row-fluid' : 'row',
|
||||
bsCol = this.get('oldermoodle') ? 'span' : 'col-xs-',
|
||||
bsAlWarn = this.get('oldermoodle') ? '' : 'alert-warning',
|
||||
bsAlDang = this.get('oldermoodle') ? 'alert-error' : 'alert-danger',
|
||||
bsSsBtn = this.get('oldermoodle') ? 'btn btn-large btn-danger btn-block'
|
||||
: 'btn btn-lg btn-outline-danger btn-block';
|
||||
|
||||
var bodyContent = Y.Handlebars.compile(TEMPLATE)({
|
||||
PLUGINNAME: PLUGINNAME,
|
||||
isAudio: isAudio,
|
||||
bs_row: bsRow,
|
||||
bs_col: bsCol,
|
||||
bs_al_warn: bsAlWarn,
|
||||
bs_al_dang: bsAlDang,
|
||||
bs_ss_btn: bsSsBtn,
|
||||
bs_ul_btn: 'btn btn-primary btn-block',
|
||||
browseralert_title: M.util.get_string('browseralert_title', 'atto_recordrtc'),
|
||||
browseralert: M.util.get_string('browseralert', 'atto_recordrtc'),
|
||||
insecurealert_title: M.util.get_string('insecurealert_title', 'atto_recordrtc'),
|
||||
insecurealert: M.util.get_string('insecurealert', 'atto_recordrtc'),
|
||||
startrecording: M.util.get_string('startrecording', 'atto_recordrtc'),
|
||||
attachrecording: M.util.get_string('attachrecording', 'atto_recordrtc')
|
||||
});
|
||||
|
||||
return bodyContent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the dialogue without further action.
|
||||
*
|
||||
* @method closeDialogue
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
*/
|
||||
closeDialogue: function(scope) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert the annotation link in the editor.
|
||||
*
|
||||
* @method setLink
|
||||
* @param {Object} scope The "this" context of the editor.
|
||||
* @param {string} annotation The HTML link to the recording.
|
||||
*/
|
||||
setLink: function(scope, annotation) {
|
||||
scope.getDialogue().hide();
|
||||
|
||||
scope.editor.focus();
|
||||
scope.get('host').insertContentAtFocusPoint(annotation);
|
||||
scope.markUpdated();
|
||||
}
|
||||
}, {
|
||||
ATTRS: {
|
||||
/**
|
||||
* The contextid to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute contextid
|
||||
* @type String
|
||||
*/
|
||||
contextid: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The sesskey to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute sesskey
|
||||
* @type String
|
||||
*/
|
||||
sesskey: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The allowedtypes to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute allowedtypes
|
||||
* @type String
|
||||
*/
|
||||
allowedtypes: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiobitrate
|
||||
* @type String
|
||||
*/
|
||||
audiobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videobitrate to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videobitrate
|
||||
* @type String
|
||||
*/
|
||||
videobitrate: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The timelimit to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute timelimit
|
||||
* @type String
|
||||
*/
|
||||
timelimit: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The audiortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute audiortcicon
|
||||
* @type String
|
||||
*/
|
||||
audiortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The videortcicon to use when generating this recordrtc.
|
||||
*
|
||||
* @attribute videortcicon
|
||||
* @type String
|
||||
*/
|
||||
videortcicon: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* True if Moodle is version < 3.2.
|
||||
*
|
||||
* @attribute oldermoodle
|
||||
* @type Boolean
|
||||
*/
|
||||
oldermoodle: {
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum upload size set on server, in MB.
|
||||
*
|
||||
* @attribute maxrecsize
|
||||
* @type String
|
||||
*/
|
||||
maxrecsize: {
|
||||
value: null
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"moodle-atto_recordrtc-button": {
|
||||
"requires": [
|
||||
"moodle-editor_atto-plugin",
|
||||
"moodle-atto_recordrtc-recording"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "moodle-atto_recordrtc-recording",
|
||||
"builds": {
|
||||
"moodle-atto_recordrtc-recording": {
|
||||
"jsfiles": [
|
||||
"commonmodule.js",
|
||||
"compatcheckmodule.js",
|
||||
"abstractmodule.js",
|
||||
"audiomodule.js",
|
||||
"videomodule.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
111
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/abstractmodule.js
vendored
Normal file
111
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/abstractmodule.js
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for function abstractions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.abstractmodule = {
|
||||
// A helper for making a Moodle alert appear.
|
||||
// Subject is the content of the alert (which error ther alert is for).
|
||||
// Possibility to add on-alert-close event.
|
||||
show_alert: function(subject, onCloseEvent) {
|
||||
Y.use('moodle-core-notification-alert', function() {
|
||||
var dialogue = new M.core.alert({
|
||||
title: M.util.get_string(subject + '_title', 'atto_recordrtc'),
|
||||
message: M.util.get_string(subject, 'atto_recordrtc')
|
||||
});
|
||||
|
||||
if (onCloseEvent) {
|
||||
dialogue.after('complete', onCloseEvent);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Handle getUserMedia errors.
|
||||
handle_gum_errors: function(error, commonConfig) {
|
||||
var btnLabel = M.util.get_string('recordingfailed', 'atto_recordrtc'),
|
||||
treatAsStopped = function() {
|
||||
commonConfig.onMediaStopped(btnLabel);
|
||||
};
|
||||
|
||||
// Changes 'CertainError' -> 'gumcertain' to match language string names.
|
||||
var stringName = 'gum' + error.name.replace('Error', '').toLowerCase();
|
||||
|
||||
// After alert, proceed to treat as stopped recording, or close dialogue.
|
||||
if (stringName !== 'gumsecurity') {
|
||||
am.show_alert(stringName, treatAsStopped);
|
||||
} else {
|
||||
am.show_alert(stringName, function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Select best options for the recording codec.
|
||||
select_rec_options: function(recType) {
|
||||
var types, options;
|
||||
|
||||
if (recType === 'audio') {
|
||||
types = [
|
||||
'audio/webm;codecs=opus',
|
||||
'audio/ogg;codecs=opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate'))
|
||||
};
|
||||
} else {
|
||||
types = [
|
||||
'video/webm;codecs=vp9,opus',
|
||||
'video/webm;codecs=h264,opus',
|
||||
'video/webm;codecs=vp8,opus'
|
||||
];
|
||||
options = {
|
||||
audioBitsPerSecond: window.parseInt(cm.editorScope.get('audiobitrate')),
|
||||
videoBitsPerSecond: window.parseInt(cm.editorScope.get('videobitrate'))
|
||||
};
|
||||
}
|
||||
|
||||
var compatTypes = types.filter(function(type) {
|
||||
return window.MediaRecorder.isTypeSupported(type);
|
||||
});
|
||||
|
||||
if (compatTypes.length !== 0) {
|
||||
options.mimeType = compatTypes[0];
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
};
|
157
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/audiomodule.js
vendored
Normal file
157
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/audiomodule.js
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.audiomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('audio#player');
|
||||
cm.playerDOM = document.querySelector('audio#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'audio';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the audio player and upload button are not shown.
|
||||
cm.player.ancestor().ancestor().addClass('hide');
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make audio stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Capture audio stream from microphone.
|
||||
M.atto_recordrtc.audiomodule.capture_audio(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio stream from microphone.
|
||||
capture_audio: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioStream) {
|
||||
// Set audio player source to microphone stream.
|
||||
cm.playerDOM.srcObject = audioStream;
|
||||
|
||||
config.onMediaCaptured(audioStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
318
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/commonmodule.js
vendored
Normal file
318
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/commonmodule.js
vendored
Normal file
@ -0,0 +1,318 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, no-alert, spaced-comment */
|
||||
|
||||
// JSHint directives.
|
||||
/*global M */
|
||||
/*jshint es5: true */
|
||||
/*jshint onevar: false */
|
||||
/*jshint shadow: true */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to M.atto_recordrtc.commonmodule namespace.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.commonmodule = {
|
||||
// Unitialized variables to be used by the other modules.
|
||||
editorScope: null,
|
||||
alertWarning: null,
|
||||
alertDanger: null,
|
||||
player: null,
|
||||
playerDOM: null, // Used to manipulate DOM directly.
|
||||
startStopBtn: null,
|
||||
uploadBtn: null,
|
||||
countdownSeconds: null,
|
||||
countdownTicker: null,
|
||||
recType: null,
|
||||
stream: null,
|
||||
mediaRecorder: null,
|
||||
chunks: null,
|
||||
blobSize: null,
|
||||
olderMoodle: null,
|
||||
maxUploadSize: null,
|
||||
|
||||
// Capture webcam/microphone stream.
|
||||
capture_user_media: function(mediaConstraints, successCallback, errorCallback) {
|
||||
window.navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
|
||||
},
|
||||
|
||||
// Add chunks of audio/video to array when made available.
|
||||
handle_data_available: function(event) {
|
||||
// Push recording slice to array.
|
||||
cm.chunks.push(event.data);
|
||||
// Size of all recorded data so far.
|
||||
cm.blobSize += event.data.size;
|
||||
|
||||
// If total size of recording so far exceeds max upload limit, stop recording.
|
||||
// An extra condition exists to avoid displaying alert twice.
|
||||
if (cm.blobSize >= cm.maxUploadSize) {
|
||||
if (!window.localStorage.getItem('alerted')) {
|
||||
window.localStorage.setItem('alerted', 'true');
|
||||
|
||||
cm.startStopBtn.simulate('click');
|
||||
am.show_alert('nearingmaxsize');
|
||||
} else {
|
||||
window.localStorage.removeItem('alerted');
|
||||
}
|
||||
|
||||
cm.chunks.pop();
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording end.
|
||||
handle_stop: function() {
|
||||
// Set source of audio player.
|
||||
var blob = new window.Blob(cm.chunks, {type: cm.mediaRecorder.mimeType});
|
||||
cm.player.set('src', window.URL.createObjectURL(blob));
|
||||
|
||||
// Show audio player with controls enabled, and unmute.
|
||||
cm.player.set('muted', false);
|
||||
cm.player.set('controls', true);
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
// Show upload button.
|
||||
cm.uploadBtn.ancestor().ancestor().removeClass('hide');
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
|
||||
// Handle when upload button is clicked.
|
||||
cm.uploadBtn.on('click', function() {
|
||||
// Trigger error if no recording has been made.
|
||||
if (cm.chunks.length === 0) {
|
||||
am.show_alert('norecordingfound');
|
||||
} else {
|
||||
cm.uploadBtn.set('disabled', true);
|
||||
|
||||
// Upload recording to server.
|
||||
cm.upload_to_server(cm.recType, function(progress, fileURLOrError) {
|
||||
if (progress === 'ended') { // Insert annotation in text.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.insert_annotation(cm.recType, fileURLOrError);
|
||||
} else if (progress === 'upload-failed') { // Show error message in upload button.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadfailed', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else if (progress === 'upload-failed-404') { // 404 error = File too large in Moodle.
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('uploadfailed404', 'atto_recordrtc'));
|
||||
} else if (progress === 'upload-aborted') {
|
||||
cm.uploadBtn.set('disabled', false);
|
||||
cm.uploadBtn.set('textContent',
|
||||
M.util.get_string('uploadaborted', 'atto_recordrtc') + ' ' + fileURLOrError);
|
||||
} else {
|
||||
cm.uploadBtn.set('textContent', progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Get everything set up to start recording.
|
||||
start_recording: function(type, stream) {
|
||||
// The options for the recording codecs and bitrates.
|
||||
var options = am.select_rec_options(type);
|
||||
cm.mediaRecorder = new window.MediaRecorder(stream, options);
|
||||
|
||||
// Initialize MediaRecorder events and start recording.
|
||||
cm.mediaRecorder.ondataavailable = cm.handle_data_available;
|
||||
cm.mediaRecorder.onstop = cm.handle_stop;
|
||||
cm.mediaRecorder.start(1000); // Capture in 1s chunks. Must be set to work with Firefox.
|
||||
|
||||
// Mute audio, distracting while recording.
|
||||
cm.player.set('muted', true);
|
||||
|
||||
// Set recording timer to the time specified in the settings.
|
||||
cm.countdownSeconds = cm.editorScope.get('timelimit');
|
||||
cm.countdownSeconds++;
|
||||
var timerText = M.util.get_string('stoprecording', 'atto_recordrtc');
|
||||
timerText += ' (<span id="minutes"></span>:<span id="seconds"></span>)';
|
||||
cm.startStopBtn.setHTML(timerText);
|
||||
cm.set_time();
|
||||
cm.countdownTicker = window.setInterval(cm.set_time, 1000);
|
||||
|
||||
// Make button clickable again, to allow stopping recording.
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
},
|
||||
|
||||
// Get everything set up to stop recording.
|
||||
stop_recording: function(stream) {
|
||||
// Stop recording stream.
|
||||
cm.mediaRecorder.stop();
|
||||
|
||||
// Stop each individual MediaTrack.
|
||||
var tracks = stream.getTracks();
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
tracks[i].stop();
|
||||
}
|
||||
},
|
||||
|
||||
// Upload recorded audio/video to server.
|
||||
upload_to_server: function(type, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
// Get src media of audio/video tag.
|
||||
xhr.open('GET', cm.player.get('src'), true);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) { // If src media was successfully retrieved.
|
||||
// blob is now the media that the audio/video tag's src pointed to.
|
||||
var blob = this.response;
|
||||
|
||||
// Generate filename with random ID and file extension.
|
||||
var fileName = (Math.random() * 1000).toString().replace('.', '');
|
||||
fileName += (type === 'audio') ? '-audio.ogg'
|
||||
: '-video.webm';
|
||||
|
||||
// Create FormData to send to PHP filepicker-upload script.
|
||||
var formData = new window.FormData(),
|
||||
filepickerOptions = cm.editorScope.get('host').get('filepickeroptions').link,
|
||||
repositoryKeys = window.Object.keys(filepickerOptions.repositories);
|
||||
|
||||
formData.append('repo_upload_file', blob, fileName);
|
||||
formData.append('itemid', filepickerOptions.itemid);
|
||||
|
||||
for (var i = 0; i < repositoryKeys.length; i++) {
|
||||
if (filepickerOptions.repositories[repositoryKeys[i]].type === 'upload') {
|
||||
formData.append('repo_id', filepickerOptions.repositories[repositoryKeys[i]].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
formData.append('env', filepickerOptions.env);
|
||||
formData.append('sesskey', M.cfg.sesskey);
|
||||
formData.append('client_id', filepickerOptions.client_id);
|
||||
formData.append('savepath', '/');
|
||||
formData.append('ctx_id', filepickerOptions.context.id);
|
||||
|
||||
// Pass FormData to PHP script using XHR.
|
||||
var uploadEndpoint = M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload';
|
||||
cm.make_xmlhttprequest(uploadEndpoint, formData,
|
||||
function(progress, responseText) {
|
||||
if (progress === 'upload-ended') {
|
||||
callback('ended', window.JSON.parse(responseText).url);
|
||||
} else {
|
||||
callback(progress);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
// Handle XHR sending/receiving/status.
|
||||
make_xmlhttprequest: function(url, data, callback) {
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if ((xhr.readyState === 4) && (xhr.status === 200)) { // When request is finished and successful.
|
||||
callback('upload-ended', xhr.responseText);
|
||||
} else if (xhr.status === 404) { // When request returns 404 Not Found.
|
||||
callback('upload-failed-404');
|
||||
}
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = function(event) {
|
||||
callback(Math.round(event.loaded / event.total * 100) + "% " + M.util.get_string('uploadprogress', 'atto_recordrtc'));
|
||||
};
|
||||
|
||||
xhr.upload.onerror = function(error) {
|
||||
callback('upload-failed', error);
|
||||
};
|
||||
|
||||
xhr.upload.onabort = function(error) {
|
||||
callback('upload-aborted', error);
|
||||
};
|
||||
|
||||
// POST FormData to PHP script that handles uploading/saving.
|
||||
xhr.open('POST', url);
|
||||
xhr.send(data);
|
||||
},
|
||||
|
||||
// Makes 1min and 2s display as 1:02 on timer instead of 1:2, for example.
|
||||
pad: function(val) {
|
||||
var valString = val + "";
|
||||
|
||||
if (valString.length < 2) {
|
||||
return "0" + valString;
|
||||
} else {
|
||||
return valString;
|
||||
}
|
||||
},
|
||||
|
||||
// Functionality to make recording timer count down.
|
||||
// Also makes recording stop when time limit is hit.
|
||||
set_time: function() {
|
||||
cm.countdownSeconds--;
|
||||
|
||||
cm.startStopBtn.one('span#seconds').set('textContent', cm.pad(cm.countdownSeconds % 60));
|
||||
cm.startStopBtn.one('span#minutes').set('textContent', cm.pad(window.parseInt(cm.countdownSeconds / 60, 10)));
|
||||
|
||||
if (cm.countdownSeconds === 0) {
|
||||
cm.startStopBtn.simulate('click');
|
||||
}
|
||||
},
|
||||
|
||||
// Generates link to recorded annotation to be inserted.
|
||||
create_annotation: function(type, recording_url) {
|
||||
var linkText = window.prompt(M.util.get_string('annotationprompt', 'atto_recordrtc'),
|
||||
M.util.get_string('annotation:' + type, 'atto_recordrtc'));
|
||||
|
||||
// Return HTML for annotation link, if user did not press "Cancel".
|
||||
if (!linkText) {
|
||||
return undefined;
|
||||
} else {
|
||||
var annotation = '<a target="_blank" href="' + recording_url + '">' + linkText + '</a>';
|
||||
return annotation;
|
||||
}
|
||||
},
|
||||
|
||||
// Inserts link to annotation in editor text area.
|
||||
insert_annotation: function(type, recording_url) {
|
||||
var annotation = cm.create_annotation(type, recording_url);
|
||||
|
||||
// Insert annotation link.
|
||||
// If user pressed "Cancel", just go back to main recording screen.
|
||||
if (!annotation) {
|
||||
cm.uploadBtn.set('textContent', M.util.get_string('attachrecording', 'atto_recordrtc'));
|
||||
} else {
|
||||
cm.editorScope.setLink(cm.editorScope, annotation);
|
||||
}
|
||||
}
|
||||
};
|
76
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/compatcheckmodule.js
vendored
Normal file
76
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/compatcheckmodule.js
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions for checking browser compatibility
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule;
|
||||
|
||||
M.atto_recordrtc.compatcheckmodule = {
|
||||
// Show alert and close plugin if browser does not support WebRTC at all.
|
||||
check_has_gum: function() {
|
||||
if (!(navigator.mediaDevices && window.MediaRecorder)) {
|
||||
am.show_alert('nowebrtc', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Notify and redirect user if plugin is used from insecure location.
|
||||
check_secure: function() {
|
||||
var isSecureOrigin = (window.location.protocol === 'https:') ||
|
||||
(window.location.host.indexOf('localhost') !== -1);
|
||||
|
||||
if (!isSecureOrigin) {
|
||||
cm.alertDanger.ancestor().ancestor().removeClass('hide');
|
||||
|
||||
if (window.bowser.chrome || window.bowser.opera) {
|
||||
am.show_alert('gumsecurity', function() {
|
||||
cm.editorScope.closeDialogue(cm.editorScope);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Display "consider switching browsers" message if not using:
|
||||
// - Firefox 29+;
|
||||
// - Chrome 49+;
|
||||
// - Opera 36+.
|
||||
check_browser: function() {
|
||||
if (!((window.bowser.firefox && window.bowser.version >= 29) ||
|
||||
(window.bowser.chrome && window.bowser.version >= 49) ||
|
||||
(window.bowser.opera && window.bowser.version >= 36))) {
|
||||
cm.alertWarning.ancestor().ancestor().removeClass('hide');
|
||||
}
|
||||
}
|
||||
};
|
165
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/videomodule.js
vendored
Normal file
165
lib/editor/atto/plugins/recordrtc/yui/src/recording/js/videomodule.js
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
/**
|
||||
* Atto recordrtc library functions
|
||||
*
|
||||
* @package atto_recordrtc
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
* @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
|
||||
* @copyright 2017 Blindside Networks Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// ESLint directives.
|
||||
/* eslint-disable camelcase, spaced-comment */
|
||||
|
||||
// Scrutinizer CI directives.
|
||||
/** global: M */
|
||||
/** global: Y */
|
||||
|
||||
M.atto_recordrtc = M.atto_recordrtc || {};
|
||||
|
||||
// Shorten access to module namespaces.
|
||||
var cm = M.atto_recordrtc.commonmodule,
|
||||
am = M.atto_recordrtc.abstractmodule,
|
||||
ccm = M.atto_recordrtc.compatcheckmodule;
|
||||
|
||||
M.atto_recordrtc.videomodule = {
|
||||
init: function(scope) {
|
||||
// Assignment of global variables.
|
||||
cm.editorScope = scope; // Allows access to the editor's "this" context.
|
||||
cm.alertWarning = Y.one('div#alert-warning');
|
||||
cm.alertDanger = Y.one('div#alert-danger');
|
||||
cm.player = Y.one('video#player');
|
||||
cm.playerDOM = document.querySelector('video#player');
|
||||
cm.startStopBtn = Y.one('button#start-stop');
|
||||
cm.uploadBtn = Y.one('button#upload');
|
||||
cm.recType = 'video';
|
||||
cm.olderMoodle = scope.get('oldermoodle');
|
||||
// Extract the numbers from the string, and convert to bytes.
|
||||
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
|
||||
|
||||
// Show alert and close plugin if WebRTC is not supported.
|
||||
ccm.check_has_gum();
|
||||
// Show alert and redirect user if connection is not secure.
|
||||
ccm.check_secure();
|
||||
// Show alert if using non-ideal browser.
|
||||
ccm.check_browser();
|
||||
|
||||
// Run when user clicks on "record" button.
|
||||
cm.startStopBtn.on('click', function() {
|
||||
cm.startStopBtn.set('disabled', true);
|
||||
|
||||
// If button is displaying "Start Recording" or "Record Again".
|
||||
if ((cm.startStopBtn.get('textContent') === M.util.get_string('startrecording', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordagain', 'atto_recordrtc')) ||
|
||||
(cm.startStopBtn.get('textContent') === M.util.get_string('recordingfailed', 'atto_recordrtc'))) {
|
||||
// Make sure the upload button is not shown.
|
||||
cm.uploadBtn.ancestor().ancestor().addClass('hide');
|
||||
|
||||
// Change look of recording button.
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-outline-danger', 'btn-danger');
|
||||
}
|
||||
|
||||
// Empty the array containing the previously recorded chunks.
|
||||
cm.chunks = [];
|
||||
cm.blobSize = 0;
|
||||
|
||||
// Initialize common configurations.
|
||||
var commonConfig = {
|
||||
// When the stream is captured from the microphone/webcam.
|
||||
onMediaCaptured: function(stream) {
|
||||
// Make video stream available at a higher level by making it a property of the common module.
|
||||
cm.stream = stream;
|
||||
|
||||
cm.start_recording(cm.recType, cm.stream);
|
||||
},
|
||||
|
||||
// Revert button to "Record Again" when recording is stopped.
|
||||
onMediaStopped: function(btnLabel) {
|
||||
cm.startStopBtn.set('textContent', btnLabel);
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
},
|
||||
|
||||
// Handle recording errors.
|
||||
onMediaCapturingFailed: function(error) {
|
||||
am.handle_gum_errors(error, commonConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// Show video tag without controls to view webcam stream.
|
||||
cm.player.ancestor().ancestor().removeClass('hide');
|
||||
cm.player.set('controls', false);
|
||||
|
||||
// Capture audio+video stream from webcam/microphone.
|
||||
M.atto_recordrtc.videomodule.capture_audio_video(commonConfig);
|
||||
} else { // If button is displaying "Stop Recording".
|
||||
// First of all clears the countdownTicker.
|
||||
window.clearInterval(cm.countdownTicker);
|
||||
|
||||
// Disable "Record Again" button for 1s to allow background processing (closing streams).
|
||||
window.setTimeout(function() {
|
||||
cm.startStopBtn.set('disabled', false);
|
||||
}, 1000);
|
||||
|
||||
// Stop recording.
|
||||
cm.stop_recording(cm.stream);
|
||||
|
||||
// Change button to offer to record again.
|
||||
cm.startStopBtn.set('textContent', M.util.get_string('recordagain', 'atto_recordrtc'));
|
||||
if (!cm.olderMoodle) {
|
||||
cm.startStopBtn.replaceClass('btn-danger', 'btn-outline-danger');
|
||||
}
|
||||
}
|
||||
|
||||
// Get dialogue centered.
|
||||
cm.editorScope.getDialogue().centered();
|
||||
});
|
||||
},
|
||||
|
||||
// Setup to get audio+video stream from microphone/webcam.
|
||||
capture_audio_video: function(config) {
|
||||
cm.capture_user_media(
|
||||
// Media constraints.
|
||||
{
|
||||
audio: true,
|
||||
video: {
|
||||
width: {ideal: 640},
|
||||
height: {ideal: 480}
|
||||
}
|
||||
},
|
||||
|
||||
// Success callback.
|
||||
function(audioVideoStream) {
|
||||
// Set video player source to microphone+webcam stream, and play it back as it's recording.
|
||||
cm.playerDOM.srcObject = audioVideoStream;
|
||||
cm.playerDOM.play();
|
||||
|
||||
config.onMediaCaptured(audioVideoStream);
|
||||
},
|
||||
|
||||
// Error callback.
|
||||
function(error) {
|
||||
config.onMediaCapturingFailed(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"moodle-atto_recordrtc-recording": {
|
||||
"requires": [
|
||||
"moodle-atto_recordrtc-button"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user