Rello
July 25, 2016, 3:26pm
1
Hello,
I can´t find a proper docu and searching & try/error based on github seems not too successfull.
I want to register a “play” fileaction for audioplay and also register it as default-action for mp3s.
I am not sure what to use:
OCA.Files.fileActions.register
or
OCA.Files.fileActions.registerAction
+
OCA.Files.fileActions.setDefault
my current setup does not seem to work:
OCA.Files.fileActions.registerAction({
name: ‘Play’,
displayName: t(‘audioplayer’, ‘Play’),
mime: ‘audio/mpeg’,
permissions: OC.PERMISSION_READ,
icon: function () {
return OC.imagePath(‘core’, ‘actions/sound’);
},
actionHandler: openInMusic
});
OCA.Files.fileActions.setDefault(‘audio/mpeg’, ‘Play’);
in this case, the default action works - but it is not displayed in the context-menu
oparoz
July 25, 2016, 4:22pm
2
Have a look at this file:
/* global oc_requesttoken, FileList, Gallery, SlideShow */
(function ($, OC, OCA, oc_requesttoken) {
"use strict";
var galleryFileAction = {
features: [],
mediaTypes: {},
scrollContainer: null,
slideShow: null,
/**
* Builds a URL pointing to one of the app's controllers
*
* @param {string} endPoint
* @param {undefined|string} path
* @param {Object} params
*
* @returns {string}
*/
buildGalleryUrl: function (endPoint, path, params) {
var extension = '';
This file has been truncated. show original
Specifically this bit:
for (i = 0; i < mediaTypesLength; i++) {
// Each click handler gets the same function and images array and
// is responsible to load the slideshow
OCA.Files.fileActions.register(mediaTypes[i], 'View', OC.PERMISSION_READ, '',
galleryFileAction.onView);
OCA.Files.fileActions.setDefault(mediaTypes[i], 'View');
}
oparoz
July 25, 2016, 5:29pm
3
Just saw this. The context menu requires a different registration.
1 Like
Rello
January 11, 2018, 10:02pm
4
Hello,
I want to bring this up again and ask for help here.
It was working some time, but with the current 12 it is not working again.
OCA.Files.fileActions.registerAction({
name: 'audio',
displayName: 'audio',
mime: mime,
permissions: OC.PERMISSION_READ,
icon: icon_url,
actionHandler: playFile
});
OCA.Files.fileActions.setDefault(mime, 'audio');
as above, the default action is assigned. when I use the console to debug OCA.Files.fileActions
, its also looking good. only the menu item is missing
Object = $1
$el: n [<div class="dummy-fileactions hidden">] (1)
_showMenuClosure: function()
_updateListeners: [] (0)
actions: Object
application/cmd: {Edit: Object}
application/javascript: {Edit: Object}
application/json: {Edit: Object}
application/x-empty: {Edit: Object}
application/x-msdos-program: {Edit: Object}
application/x-pearl: {Edit: Object}
application/x-php: {Edit: Object}
application/x-text: {Edit: Object}
application/xml: {Edit: Object}
application/yaml: {Edit: Object}
audio/flac: {audio: Object}
audio/m4b: {audio: Object}
audio/mp4: {audio: Object}
audio/mpeg: {audio: Object}
audio/wav: {audio: Object}
text: {Edit: Object}
defaults: Object
application/cmd: "Edit"
application/javascript: "Edit"
application/json: "Edit"
application/x-empty: "Edit"
application/x-msdos-program: "Edit"
application/x-pearl: "Edit"
application/x-php: "Edit"
application/x-text: "Edit"
application/xml: "Edit"
application/yaml: "Edit"
audio/flac: "audio"
audio/m4b: "audio"
audio/mp4: "audio"
audio/mpeg: "audio"
audio/wav: "audio"
text: "Edit"
icons: {Edit: function, audio: "/owncloud/core/img/actions/sound.svg"}
Rello
January 12, 2018, 6:42am
5
one additional finding:
when I trigger the fileActions.register
, the items are shown in the entry.
as soon as I trigger the setDefault
, it is being removed again.
Rello
January 21, 2018, 4:37pm
6
bump.
somehow it is really not working
Removing the default action from the menu is actually by intention. Since it is triggered when clicking the file, there is no need to have another entry to perform that action in the menu.
Rello
February 5, 2018, 4:37pm
8
Thank you @juliushaertl for this finding & clarification. Knowing that it was designed to be this way saves the debugging