function _video_field_convert_on_save in Video 7.2
Processes video fields that should convert on save.
This is not performed in _video_field_file_autoconversion() because of incompatibilities with Rules and File(field) Paths.
When hook_entity_insert/update are called, all field related operations are complete and the entity is fully saved to the database. This allows Rules to supply a proper entity to the event handlers.
The $entity->video_convert_on_save property is set in _video_field_file_autoconversion().
3 calls to _video_field_convert_on_save()
- video_entity_insert in ./
video.field.inc - Implements hook_entity_insert().
- video_entity_translation_save in ./
video.field.inc - Implements hook_entity_translation_save().
- video_entity_update in ./
video.field.inc - Implements hook_entity_updated().
File
- ./
video.field.inc, line 1374 - Implement a video field, based on the file module's file field.
Code
function _video_field_convert_on_save($entity, $type) {
if (!empty($entity->video_convert_on_save)) {
$transcoder = new Transcoder();
$transcodername = $transcoder
->getTranscoder()
->getName();
foreach ($entity->video_convert_on_save as $videofid) {
$video = video_jobs::load($videofid);
if ($transcoder
->executeConversion($video)) {
if ($video->video_status == VIDEO_RENDERING_COMPLETE) {
drupal_set_message(t('The video %video-name was converted.', array(
'%video-name' => $video->filename,
)));
}
else {
drupal_set_message(t('Transcoding job was successfully submitted to %transcoder-name. The video %video-name will be converted soon.', array(
'%transcoder-name' => $transcodername,
'%video-name' => $video->filename,
)));
}
}
else {
drupal_set_message(t('Something went wrong with transcoding %video-name. Please check your <a href="@log-page">recent log entries</a> for further debugging.', array(
'%video-name' => $video->filename,
'@log-page' => url('admin/reports/dblog'),
)), 'error');
}
}
unset($entity->video_convert_on_save);
}
}