Mathias Markl 6 years ago
parent
commit
c353706435
  1. 7
      muk_web_preview_audio/README.md
  2. 2
      muk_web_preview_audio/__init__.py
  3. 14
      muk_web_preview_audio/__manifest__.py
  4. 6
      muk_web_preview_audio/doc/changelog.rst
  5. 51
      muk_web_preview_audio/doc/index.rst
  6. 38
      muk_web_preview_audio/static/description/index.html
  7. 112
      muk_web_preview_audio/static/lib/visualizer/visualizer.js
  8. 4
      muk_web_preview_audio/static/src/js/preview_handler.js

7
muk_web_preview_audio/README.md

@ -1,7 +0,0 @@
# MuK Preview Audio
Extendes the Preview Dialog to support audio. Currently the following audio extensions are supported:
* Wav (*.wav, audio/wav)
* Ogg Theora Vorbis (*.ogg, audio/ogg)
* MP3 (*.mp3, audio/mpeg)

2
muk_web_preview_audio/__init__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH

14
muk_web_preview_audio/__manifest__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
@ -22,17 +20,11 @@
{
"name": "MuK Preview Audio",
"summary": """Audio Preview""",
"description": """
Extendes the Preview Dialog to support audio.
Currently the following audio extensions are supported:
- Wav (*.wav, audio/wav)
- Ogg Theora Vorbis (*.ogg, audio/ogg)
- MP3 (*.mp3, audio/mpeg)
""",
"version": "11.0.1.1.0",
"version": "11.0.2.0.0",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",
"live_test_url": "https://demo.mukit.at/web/login",
"author": "MuK IT",
"contributors": [
"Mathias Markl <mathias.markl@mukit.at>",
@ -43,8 +35,6 @@
"data": [
"template/assets.xml",
],
"demo": [
],
"qweb": [
"static/src/xml/*.xml",
],

6
muk_web_preview_audio/doc/changelog.rst

@ -1,9 +1,13 @@
`2.0.0`
-------
- Migrated to Python 3
`1.1.0`
-------
- Lazy load javascript
`1.0.0`
-------

51
muk_web_preview_audio/doc/index.rst

@ -0,0 +1,51 @@
=================
MuK Preview Audio
=================
Extendes the Preview Dialog to support images. Currently the following image extensions
are supported:
* Wav (\*.wav, audio/wav)
* Ogg Theora Vorbis (\*.ogg, audio/ogg)
* MP3 (\*.mp3, audio/mpeg)
Installation
============
To install this module, you need to:
Download the module and add it to your Odoo addons folder. Afterward, log on to
your Odoo server and go to the Apps menu. Trigger the debug modus and update the
list by clicking on the "Update Apps List" link. Now install the module by
clicking on the install button.
Configuration
=============
No additional configuration is needed to use this module.
Usage
=============
Go to a binary that contains an audio file and open the preview dialog to view
the preview.
Credits
=======
Contributors
------------
* Mathias Markl <mathias.markl@mukit.at>
Author & Maintainer
-------------------
This module is maintained by the `MuK IT GmbH <https://www.mukit.at/>`_.
MuK IT is an Austrian company specialized in customizing and extending Odoo.
We develop custom solutions for your individual needs to help you focus on
your strength and expertise to grow your business.
If you want to get in touch please contact us via mail
(sale@mukit.at) or visit our website (https://mukit.at).

38
muk_web_preview_audio/static/description/index.html

@ -4,15 +4,15 @@
<h3 class="oe_slogan">Preview your audio files directly in Odoo.</h3>
<h4 class="oe_slogan" style="font-size: 23px;">MuK IT GmbH -
www.mukit.at</h4>
<div class="oe_demo oe_screenshot">
<div class="oe_demo oe_screenshot" style="max-width: 84%; margin: 16px 8%;">
<img src="screenshot.png">
</div>
</div>
</section>
<section class="oe_container" style="padding-top: 25px;">
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<div style="max-width: 84%; margin: 16px 8%;">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">Extendes the Preview Dialog to support audio.
Currently the following audio extensions are supported:</p>
@ -25,14 +25,46 @@
</div>
</section>
<section class="oe_container oe_dark"
style="margin-bottom: 20px; border-top: 5px solid #797979; border-bottom: 5px solid #797979;">
<h3 class="oe_slogan" style="margin-bottom: 10px;">Demo</h3>
<div class="row" style="margin: auto; max-width: 200px;">
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">User:</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">apps</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">Password:</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">demo</h5>
</div>
</div>
<div class="oe_slogan" style="margin-top: 5px;">
<a class="btn btn-primary btn-lg mt8"
href="https://demo.mukit.at/web/login"
style="position: relative; overflow: hidden;"><span
class="o_ripple"
style="height: 138px; width: 138px; top: -35.2969px; left: -8.17188px;"></span>
<i class="fa fa-video-camera"></i> Live Preview </a>
</div>
</section>
<section class="oe_container oe_dark">
<h3 class="oe_slogan">Help and Support</h3>
<h5 class="oe_slogan" style="font-size: 20px;">Feel free to
contact us, if you need any help with your Odoo integration or
addiontal features.</h5>
<div class="oe_slogan">
<a class="btn btn-primary btn-lg mt8" href="mailto:sale@mukit.at">
<i class="fa fa-envelope"></i> Email
</a> <a class="btn btn-primary btn-lg mt8"
href="https://mukit.at/page/contactus"> <i class="fa fa-phone"></i>
Contact
</a> <a class="btn btn-primary btn-lg mt8" href="mailto:support@mukit.at">
<i class="fa fa-life-ring"></i> Support
</a>
</div>
<img src="logo.png" style="width: 200px; margin-bottom: 20px;"

112
muk_web_preview_audio/static/lib/visualizer/visualizer.js

@ -1,112 +0,0 @@
/**********************************************************************************
*
* Copyright (C) 2017 MuK IT GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
window.AudioContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext;
function Visualizer($audio, $container, $canvas) {
var _this = this;
this.$audio = $audio;
this.$container = $container;
this.$canvas = $canvas;
this.audio = $audio.get(0);
this.canvas = $canvas.get(0);
this.audioCtx = new AudioContext();
this.analyser = this.audioCtx.createAnalyser();
this.audioSrc = this.audioCtx.createMediaElementSource(this.audio);
this.frequencyData = new Uint8Array(this.analyser.frequencyBinCount);
this.smoothEndingCounter = 0;
this.audioSrc.connect(this.analyser);
this.analyser.connect(this.audioCtx.destination);
this.ctx = this.canvas.getContext('2d'),
this.capYPositionArray = [];
this.$audio.bind('play', function (e) {
_this.smoothEndingCounter = 0;
_this.calcCanvas();
_this.renderFrame();
});
this.map = function (num, in_min, in_max, out_min, out_max) {
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
this.calcCanvas = function() {
_this.canvas.width = _this.$container.width() !== 0 ? _this.$container.width() : 650;
_this.canvas.height = _this.$container.height() !== 0 ? _this.$container.height() : 360;
_this.cwidth = _this.canvas.width;
_this.cheight = _this.canvas.height - 4;
_this.meterWidth = 10;
_this.capHeight = 4;
_this.capStyle = '#FFF';
_this.meterNum = (_this.$container.width() !== 0 ? _this.$container.width() : 650) / (10 + 2);
_this.gradient = _this.ctx.createLinearGradient(0, 0, 0, _this.cheight);
_this.gradient.addColorStop(1, '#1CD5FB');
_this.gradient.addColorStop(0.75, '#19DECA');
_this.gradient.addColorStop(0.5, '#28F5A6');
_this.gradient.addColorStop(0.25, '#19DE5A');
_this.gradient.addColorStop(0, '#1CFB27');
}
this.renderFrame = function() {
if(_this.$container.width() !== _this.cwidth) {
_this.calcCanvas();
}
_this.ctx.clearRect(0, 0, _this.cwidth, _this.cheight);
_this.analyser.getByteFrequencyData(_this.frequencyData);
var step = Math.round(_this.frequencyData.length / _this.meterNum);
for (var i = 0; i < _this.meterNum; i++) {
var valueBar = _this.map(_this.frequencyData[i * step], 0, 255, 0, _this.cheight);
var valueCap = _this.map(_this.frequencyData[i * step], 0, 255, 0, _this.canvas.height);
if (_this.capYPositionArray.length < Math.round(_this.meterNum)) {
_this.capYPositionArray.push(valueCap);
};
_this.ctx.fillStyle = _this.gradient;
_this.ctx.fillRect(i * 12, _this.cheight - valueBar, _this.meterWidth, _this.cheight);
_this.ctx.fillStyle = _this.capStyle;
if (valueCap < _this.capYPositionArray[i]) {
_this.ctx.fillRect(i * 12, _this.canvas.height - (--_this.capYPositionArray[i]), _this.meterWidth, _this.capHeight);
} else {
_this.ctx.fillRect(i * 12, _this.canvas.height - valueCap, _this.meterWidth, _this.capHeight);
_this.capYPositionArray[i] = valueCap;
};
}
if(!_this.audio.paused) {
requestAnimationFrame(_this.renderFrame);
} else {
if(_this.smoothEndingCounter < 500) {
requestAnimationFrame(_this.renderFrame);
}
_this.smoothEndingCounter++;
}
}
};

4
muk_web_preview_audio/static/src/js/preview_handler.js

@ -32,7 +32,7 @@ var AudioHandler = PreviewHandler.BaseHandler.extend({
cssLibs: [
],
jsLibs: [
'/muk_web_preview_audio/static/lib/visualizer/visualizer.js',
'/muk_web_utils/static/lib/visualizer/visualizer.js',
],
mimetypeMap: {
'.wav': 'audio/wav', '.ogg': 'audio/ogg', '.mp3': 'audio/mpeg',
@ -61,6 +61,6 @@ var AudioHandler = PreviewHandler.BaseHandler.extend({
return {
AudioHandler: AudioHandler,
}
};
});
Loading…
Cancel
Save