Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add celery integration and upgrade javascript #52

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Features
- Be able to add video from TinyMCE by adding a link to the audio or video
objects and then adding one of the available Audio and Video TinyMCE styles.
- Integration with `plone.app.async`_ for conversions if installed
- Integration wtih `collective.celery`_ for conversion if installed
- Plone 4.3 syndication support
- Transcript data
- Youtube URL (in case you want the video streamed from Youtube)
Expand Down
19 changes: 18 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@ Changelog
unreleased
----------

- nothing yet
- collective.celery integration

- upgrade mediaelementsjs

- Retry on POSKeyError when using celery

- #2610885: Sleep for a few seconds in convert task because retry isn't working
with collective.celery tasks.
[JL 2019-02-28]

- #2610885: Remove sleep and restore retry on POSKeyError
[JL 2019-03-05]

- Fix tests.
[JL 2019-06-24]

- Add names to async tasks.


2.0.4 (2017-12-18)
------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
target = plone

[celery_tasks]
meida = wildcard.media.tasks
media = wildcard.media.tasks
""",
)
10 changes: 6 additions & 4 deletions wildcard/media/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@

from wildcard.media import pasync
from wildcard.media import convert
from wildcard.media import config as media_config
try:
from wildcard.media import youtube
except ImportError:
youtube = None
from wildcard.media.config import ASYNC_DELAY

from plone import api
from zope.globalrequest import getRequest


def _run(obj, func):
# return func(obj)
if tasks:
if media_config.USE_ASYNC and tasks:
# collective.celery is installed
tfunc = getattr(tasks, func.__name__)
tfunc.delay(obj)
elif pasync.asyncInstalled():
tfunc.apply_async(args=[obj], kwargs={}, countdown=ASYNC_DELAY)
elif media_config.USE_ASYNC and pasync.asyncInstalled():
# plone.app.async installed
pasync.queueJob(obj, func)
else:
Expand Down
9 changes: 9 additions & 0 deletions wildcard/media/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class IVideo(model.Schema):
constraint=valid_video
)

form.omitted(IAddForm, 'video_file_original')
form.omitted(IEditForm, 'video_file_original')
form.widget(video_file_original=StreamNamedFileFieldWidget)
video_file_original = namedfile.NamedBlobFile(
required=False,
)

if youtube:
upload_video_to_youtube = schema.Bool(
title=_(u'Upload to youtube'),
Expand Down Expand Up @@ -247,6 +254,7 @@ def _set_video_file(self, value):
self.context.video_file = None
self.context.video_file_ogv = None
self.context.video_file_webm = None
self.context.video_file_original = None
elif value != getattr(self.context, 'video_file', _marker):
self.context.video_converted = False
self.context.video_file = value
Expand All @@ -272,6 +280,7 @@ def get_youtube_id_from_url(self):

video_file_ogv = UnsettableProperty(IVideo['video_file_ogv'])
video_file_webm = UnsettableProperty(IVideo['video_file_webm'])
video_file_original = UnsettableProperty(IVideo['video_file_original'])
image = UnsettableProperty(IVideo['image'])

if youtube:
Expand Down
2 changes: 1 addition & 1 deletion wildcard/media/browser/static/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"description": "",
"dependencies": {
"mediaelement": "2.18.2",
"mediaelement": "4.2.9",
"mockup": "2.1.0",
"patternslib": "2.0.11",
"select2": "3.5.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mediaelement",
"homepage": "https://github.com/herby/mediaelement",
"homepage": "https://github.com/mediaelement/mediaelement",
"description": "HTML5 <video> and <audio> made easy.",
"moduleType": [
"globals"
Expand All @@ -23,14 +23,14 @@
"./build/mediaelement-and-player.js",
"./build/mediaelementplayer.css"
],
"version": "2.18.2",
"_release": "2.18.2",
"version": "4.2.9",
"_release": "4.2.9",
"_resolution": {
"type": "version",
"tag": "2.18.2",
"commit": "d23d3035176e7a3e205d57b806885804cbd64132"
"tag": "4.2.9",
"commit": "6d665634da067ac075cd49631e646c7b16f25510"
},
"_source": "git://github.com/johndyer/mediaelement.git",
"_target": "2.18.2",
"_source": "https://github.com/johndyer/mediaelement.git",
"_target": "4.2.9",
"_originalSource": "mediaelement"
}
189 changes: 98 additions & 91 deletions wildcard/media/browser/static/components/mediaelement/README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,127 @@
# `<video>` and `<audio>` made easy.
# ![MediaElementJS](https://cloud.githubusercontent.com/assets/910829/22357262/e6cf32b4-e404-11e6-876b-59afa009f65c.png)

One file. Any browser. Same UI.

* Author: John Dyer [http://j.hn/](http://j.hn/)
* Website: [http://mediaelementjs.com/](http://mediaelementjs.com/)
* License: [MIT](http://johndyer.mit-license.org/)
* License: [MIT](http://mediaelement.mit-license.org/)
* Meaning: Use everywhere, keep copyright, it'd be swell if you'd link back here.
* Thanks: my employer, [Dallas Theological Seminary](http://www.dts.edu/)
* Contributors: [mikesten](https://github.com/mikesten), [sylvinus](https://github.com/sylvinus), [mattfarina](https://github.com/mattfarina), [romaninsh](https://github.com/romaninsh), [fmalk](https://github.com/fmalk), [jeffrafter](https://github.com/jeffrafter), [sompylasar](https://github.com/sompylasar), [andyfowler](https://github.com/andyfowler), [RobRoy](https://github.com/RobRoy), [jakearchibald](https://github.com/jakearchibald), [seanhellwig](https://github.com/seanhellwig), [CJ-Jackson](https://github.com/CJ-Jackson), [kaichen](https://github.com/kaichen), [gselva](https://github.com/gselva), [erktime](https://github.com/erktime), [bradleyboy](https://github.com/bradleyboy), [kristerkari](https://github.com/kristerkari), [rmhall](https://github.com/rmhall), [tantalic](https://github.com/tantalic), [madesign](http://github.com/madesign), [aschempp](http://github.com/aschempp), [gavinlynch](https://github.com/gavinlynch), [Birol2010](http://github.com/Birol2010), tons of others (see [pulls](https://github.com/johndyer/mediaelement/pulls))
* Contributors: [all contributors](https://github.com/mediaelement/mediaelement/graphs/contributors)

[![GitHub Version](https://img.shields.io/npm/v/mediaelement.svg)](https://github.com/mediaelement/mediaelement)
[![Build Status](https://img.shields.io/travis/mediaelement/mediaelement.svg)](https://travis-ci.org/mediaelement/mediaelement)
[![Coverage Status](https://img.shields.io/coveralls/mediaelement/mediaelement.svg)](https://coveralls.io/github/mediaelement/mediaelement)
[![MIT License](https://img.shields.io/npm/l/mediaelement.svg)](https://mediaelement.mit-license.org/)
[![CDNJS](https://img.shields.io/cdnjs/v/mediaelement.svg)](https://cdnjs.com/libraries/mediaelement)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/mediaelement/badge?style=rounded)](https://www.jsdelivr.com/package/npm/mediaelement)

## Installation and Usage
# Table of Contents

* [Introduction](#intro)
* [Migrating from `2.x` to `4.x` version](#migration)
* [Installation and Usage](#installation)
* [API and Configuration](#api)
* [Guidelines for Contributors](#guidelines)
* [Change Log](#changelog)
* [TODO list](#todo)

<a id="intro"></a>
## Introduction

_MediaElementPlayer: HTML5 `<video>` and `<audio>` player_

A complete HTML/CSS audio/video player built on top `MediaElement.js` and `jQuery`. Many great HTML5 players have a completely separate Flash UI in fallback mode, but MediaElementPlayer.js uses the same HTML/CSS for all players.
A complete HTML/CSS audio/video player built on top `MediaElement.js`. Many great HTML5 players have a completely separate Flash UI in fallback mode, but MediaElementPlayer.js uses the same HTML/CSS for all players.

## Change Log
`MediaElement.js` is a set of custom Flash plugins that mimic the HTML5 MediaElement API for browsers that don't support HTML5 or don't support the media codecs you're using.
Instead of using Flash as a _fallback_, Flash is used to make the browser seem HTML5 compliant and enable codecs like H.264 (via Flash) on all browsers.

Changes available at [Change Log](changelog.md)
In general, `MediaElement.js` supports **IE11+, MS Edge, Chrome, Firefox, Safari, iOS 8+** and **Android 4.0+**.

### 1. Add Script and Stylesheet
```html
<script src="jquery.js"></script>
<script src="mediaelement-and-player.min.js"></script>
<link rel="stylesheet" href="mediaelementplayer.css" />
```
### 2. Add `<video>` or `<audio>` tags
If your users have JavaScript and/or Flash, the easiest route for all browsers and mobile devices is to use a single MP4 or MP3 file.
**It is strongly recommended to read the entire documentation and check the `demo` folder to get the most out of this package**. Visit [here](docs) to start.

```html
<video src="myvideo.mp4" width="320" height="240"></video>
```
```html
<audio src="myaudio.mp3"></audio>
```
## * IMPORTANT NOTE for Safari users (Jun 8, 2017)

#### Optional: multiple codecs
This includes multiple codecs for various browsers (H.264 for IE9+, Safari, and Chrome, WebM for Firefox 4 and Opera, Ogg for Firefox 3).
Since Sierra version, `autoplay` policies have changed. You may experience an error if you try to execute `play` programatically or via `autoplay` attribute with MediaElement, unless `muted` attribute is specified.

```html
<video width="320" height="240" poster="poster.jpg" controls="controls" preload="none">
<source type="video/mp4" src="myvideo.mp4" />
<source type="video/webm" src="myvideo.webm" />
<source type="video/ogg" src="myvideo.ogv" />
</video>
```
For more information, read https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/

#### Optional: Browsers with JavaScript disabled
In very rare cases, you might have an non-HTML5 browser with Flash turned on and JavaScript turned off. In that specific case, you can also include the Flash `<object>` code.
```html
<video width="320" height="240" poster="poster.jpg" controls="controls" preload="none">
<source type="video/mp4" src="myvideo.mp4" />
<source type="video/webm" src="myvideo.webm" />
<source type="video/ogg" src="myvideo.ogv" />
<object width="320" height="240" type="application/x-shockwave-flash" data="flashmediaelement.swf">
<param name="movie" value="flashmediaelement.swf" />
<param name="flashvars" value="controls=true&amp;poster=myvideo.jpg&amp;file=myvideo.mp4" />
<img src="myvideo.jpg" width="320" height="240" title="No video playback capabilities" />
</object>
</video>
```

### 3. Startup
## * IMPORTANT CHANGES on `4.2.0` version

#### Automatic start
You can avoid running any startup scripts by added `class="mejs-player"` to the `<video>` or `<audio>` tag. Options can be added using the `data-mejsoptions` attribute
```html
<video src="myvideo.mp4" width="320" height="240"
class="mejs-player"
data-mejsoptions='{"alwaysShowControls": true}'></video>
```
As part of the continuous improvements the player, we have decided to drop completely support for IE9 and IE10, since market share of those browsers together is 0.4%, according to http://caniuse.com/usage-table.

This change is for `MediaElement` and `MediaElement Plugins` repositories.

#### Normal JavaScript
```html
<script>
var player = new MediaElementPlayer('#player', {success: function(mediaElement, originalNode) {
// do things
}});
</script>
```
<a id="migration"></a>
## * IMPORTANT: Migrating from `2.x` to `4.x` version

#### jQuery plugin
```html
<script>
$('video').mediaelementplayer({success: function(mediaElement, originalNode) {
// do things
}});
</script>
```
**NOTE:** `3.x` version has jQuery in the code base, and `4.x` is framework-agnostic. So for either `3.x` or `4.x` versions, the following steps are valid, but it is highly recommended to upgrade to `4.x`.

In order to successfully install `4.x` in an existing setup, you must consider the following guidelines:

1. If your installation relies on the legacy player classes (i.e., `mejs-player`, `mejs-container`, etc.), you **must** set up the proper namespace. In `2.x`, the default namespace is `mejs-` but now is `mejs__`. In order to set up a new namespace (or the legacy one), use the `classPrefix` configuration, and make sure you use the `mediaelementplayer-legacy` stylesheet provided in the `/build/` folder.

2. By default, `MediaElement` has bundled native renderers, such as HLS, M(PEG)-DASH and FLV, as well as YouTube and Flash shims. **If you want to use any other renderer, you MUST refer to the `build/renderers` folder and add as many as you want**. Check `demo/index.html` for a better reference.

3. You **must** set up now the path for the Flash shims if they are not in the same folder as the JS files. To do this, set the path via the `pluginPath` configuration. In the same topic, if you need to support browsers with Javascript disabled, you **must** reference the correct Flash shim, since in `2.x` there was only a single Flash shim and in `3.x` it was split to target specific media types. Check the [Browsers with JavaScript disabled](docs/installation.md#disabled-javascript) section for more details.

4. If you want to use Flash shims from a CDN, do the change related to `pluginPath` setting the CDN's URL, and also setting `shimScriptAccess` configuration as **`always`**.

5. If you need to force the Flash shim, the way to do it in `3.x` version is to use the `renderers` configuration and list them in an array.

## How it Works:
_MediaElement.js: HTML5 `<video>` and `<audio>` shim_

`MediaElement.js` is a set of custom Flash and Silverlight plugins that mimic the HTML5 MediaElement API for browsers that don't support HTML5 or don't support the media codecs you're using.
Instead of using Flash as a _fallback_, Flash is used to make the browser seem HTML5 compliant and enable codecs like H.264 (via Flash) and even WMV (via Silverlight) on all browsers.
```html
<script src="mediaelement.js"></script>
<video src="myvideo.mp4" width="320" height="240"></video>

<script>
var v = document.getElementsByTagName("video")[0];
new MediaElement(v, {success: function(media) {
media.play();
}});
</script>
6. `pluginType` was removed to favor `rendererName`. If you rely on that element, just create conditionals based on the renderer ID (all listed [here](docs/usage.md#renderers-list)). For example:

```javascript
$('video, audio').mediaelementplayer({
// Configuration
success: function(media) {
var isNative = /html5|native/i.test(media.rendererName);

var isYoutube = ~media.rendererName.indexOf('youtube');

// etc.
}
});
```
You can use this as a standalone library if you wish, or just stick with the full MediaElementPlayer.

## Building MediaElement.js
<a id="installation"></a>
## Installation and Usage

The full documentation on how to install `MediaElement.js` is available at [Installation](docs/installation.md).

A brief guide on how to create and use instances of `MediaElement` available at [Usage](docs/usage.md).

Additional features can be found at https://github.com/mediaelement/mediaelement-plugins.

<a id="api"></a>
## API and Configuration

`MediaElement.js` has many options that you can take advantage from. Visit [API and Configuration](docs/api.md) for more details.

Also, a `Utilities/Features` guide is available for development. Visit [Utilities/Features](docs/utils.md) for more details.

<a id="guidelines"></a>
## Guidelines for Contributors

If you want to contribute to improve this package, please read [Guidelines](docs/guidelines.md).

**NOTE**: If you would like to contribute with translations, make sure that you also check https://github.com/mediaelement/mediaelement-plugins, and perform the
translations for the files suffixed as `-i18n`.

<a id="sources"></a>
## Useful resources

A compilation of useful articles can be found [here](docs/resources.md).

<a id="changelog"></a>
## Change Log

Changes available at [Change Log](changelog.md).

When developing MediaElement, make changes to the files in the `/src/` directory (not `/build/`) and test the changes with `/test/test.html`.
<a id="todo"></a>
## TODO list

To compile the changes
**IMPORTANT:** Before posting an issue, it is strongly encouraged to read the whole documentation since it covers the majority of scenarios exposed in prior issues.

1. Install `node.js` with `npm` https://nodejs.org/
2. At the command prompt type `npm install` which will download all the necessary tools
3. Type `grunt` to build MediaElement.js
4. To compile the Flash swf, you'll need to install Flex 4.6. See instructions in grunt.js for details.
New features and pending bugs can be found at [TODO list](TODO.md).
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mediaelement",
"homepage": "https://github.com/herby/mediaelement",
"homepage": "https://github.com/mediaelement/mediaelement",
"description": "HTML5 <video> and <audio> made easy.",
"moduleType": [
"globals"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading