Skip to content

Commit

Permalink
Audio asset type: preview (using HTML5 browser native player) - resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
brusch committed Jun 28, 2016
1 parent c9a8425 commit dc46836
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
4 changes: 0 additions & 4 deletions pimcore/config/texts/en.json
Expand Up @@ -1028,10 +1028,6 @@
"term": "style_editor",
"definition": "Style Editor"
},
{
"term": "preview_and_styles",
"definition": "Preview & Styles"
},
{
"term": "absolute_path_to_wkhtmltoimage_binary",
"definition": "Absolute path to wkhtmltoimage binary"
Expand Down
2 changes: 2 additions & 0 deletions pimcore/modules/admin/views/scripts/index/index6.php
Expand Up @@ -332,6 +332,7 @@
"pimcore/asset/image.js",
"pimcore/asset/document.js",
"pimcore/asset/video.js",
"pimcore/asset/audio.js",
"pimcore/asset/text.js",
"pimcore/asset/folder.js",
"pimcore/asset/listfolder.js",
Expand All @@ -344,6 +345,7 @@
"pimcore/object/helpers/edit.js",
"pimcore/object/classes/class.js",
"pimcore/object/class.js",
"pimcore/object/classes/data/block.js",
"pimcore/object/bulk-export.js",
"pimcore/object/bulk-import.js",
"pimcore/object/classes/data/data.js", // THIS MUST BE THE FIRST FILE, DO NOT MOVE THIS DOWN !!!
Expand Down
5 changes: 5 additions & 0 deletions pimcore/static6/css/admin.css
Expand Up @@ -1150,6 +1150,11 @@ span.warning {
padding: 0 5px;
}

.pimcore_panel_body_centered .x-autocontainer-innerCt {
text-align: center;
vertical-align: middle;
}

.pimcore_navigation_flyout.x-menu-default {
border-color: #000;
}
Expand Down
101 changes: 101 additions & 0 deletions pimcore/static6/js/pimcore/asset/audio.js
@@ -0,0 +1,101 @@
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) 2009-2016 pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/

pimcore.registerNS("pimcore.asset.audio");
pimcore.asset.audio = Class.create(pimcore.asset.asset, {

initialize: function(id) {

this.id = intval(id);
this.setType("audio");
this.addLoadingPanel();

pimcore.plugin.broker.fireEvent("preOpenAsset", this, "audio");

this.properties = new pimcore.element.properties(this, "asset");
this.versions = new pimcore.asset.versions(this);
this.scheduler = new pimcore.element.scheduler(this, "asset");
this.dependencies = new pimcore.element.dependencies(this, "asset");
this.notes = new pimcore.element.notes(this, "asset");
this.tagAssignment = new pimcore.element.tag.assignment(this, "asset");
this.metadata = new pimcore.asset.metadata(this);

this.getData();
},

getTabPanel: function () {

var items = [];

items.push(this.getEditPanel());

if (this.isAllowed("publish")) {
items.push(this.metadata.getLayout());
}
if (this.isAllowed("properties")) {
items.push(this.properties.getLayout());
}

if (this.isAllowed("versions")) {
items.push(this.versions.getLayout());
}
if (this.isAllowed("settings")) {
items.push(this.scheduler.getLayout());
}

items.push(this.dependencies.getLayout());

if (this.isAllowed("settings")) {
items.push(this.notes.getLayout());
}

var user = pimcore.globalmanager.get("user");
if (user.isAllowed("tags_assignment")) {
items.push(this.tagAssignment.getLayout());
}

this.tabbar = new Ext.TabPanel({
tabPosition: "top",
region:'center',
deferredRender:true,
enableTabScroll:true,
border: false,
items: items,
activeTab: 0
});

return this.tabbar;
},

getEditPanel: function () {

if (!this.editPanel) {

var html = t("preview_not_available");

if(this.data.filename.match(/\.(mp3)$/)) {
html = '<audio controls><source src="' + this.data.path + this.data.filename + '" type="audio/mpeg"></audio>';
}

this.editPanel = new Ext.Panel({
title: t("preview"),
html: html,
bodyCls: "pimcore_panel_body_centered",
iconCls: "pimcore_icon_edit"
});
}

return this.editPanel;
}
});

0 comments on commit dc46836

Please sign in to comment.