| 244 | | $result = db_query("INSERT INTO {acidfree_cmml_clips} (`nid`, `a_href`, `a_text`, `img`, `desc`, `start`, `end`, `id`, `track`) VALUES('{$node->nid}', '{$attributes['a_href']}', '{$attributes['a_text']}', '{$attributes['img']}', '{$attributes['desc']}', $start, ".(float)$attributes['end'].",'{$attributes['id']}', '{$attributes['track']}');"); |
|---|
| | 245 | |
|---|
| | 246 | $img = add_clip_png( $node, $attributes['id'], $start ); |
|---|
| | 247 | |
|---|
| | 248 | $result = db_query("INSERT INTO {acidfree_cmml_clips} (`nid`, `a_href`, `a_text`, `img`, `desc`, `start`, `end`, `id`, `track`) VALUES('{$node->nid}', '{$attributes['a_href']}', '{$attributes['a_text']}', '$img', '{$attributes['desc']}', $start, ".(float)$attributes['end'].",'{$attributes['id']}', '{$attributes['track']}');"); |
|---|
| | 295 | |
|---|
| | 296 | function add_clip_png( $node, $id, $time) { |
|---|
| | 297 | |
|---|
| | 298 | $mplayer = variable_get('acidfree_path_to_mplayer', '/usr/bin/mplayer'); |
|---|
| | 299 | $tmpdir = acidfree_mktmpdir('mplayer'); |
|---|
| | 300 | $path = realpath(_acidfree_get_large_path( $node, true )); |
|---|
| | 301 | $command = "$mplayer -vo png:z=6 -vf scale -zoom -xy 120 -ao null -ss $time -frames 1 $path"; |
|---|
| | 302 | chdir($tmpdir); |
|---|
| | 303 | $mplayeroutput = shell_exec($command); |
|---|
| | 304 | if ($oldcwd) { |
|---|
| | 305 | chdir($oldcwd); |
|---|
| | 306 | } |
|---|
| | 307 | $mplayer_out = $tmpdir.DIRECTORY_SEPARATOR."00000002.png"; |
|---|
| | 308 | if (!file_exists($mplayer_out)) { |
|---|
| | 309 | drupal_set_message("file $mplayer_out does not exist", 'error'); |
|---|
| | 310 | } else if(!is_readable($mplayer_out)) { |
|---|
| | 311 | drupal_set_message("file $mplayer_out is not readable", 'error'); |
|---|
| | 312 | } else { |
|---|
| | 313 | $filename = "{$node->nid}_$id.png"; |
|---|
| | 314 | $png = acidfree_add_file($node, $mplayer_out, $filename, "image/png", true); |
|---|
| | 315 | } |
|---|
| | 316 | |
|---|
| | 317 | //FIXME This will only work if an absolute path is given for |
|---|
| | 318 | //filemanager. This is a hack to get around the mess that giving |
|---|
| | 319 | //absolute path to filemanager wreaks with the URLs. |
|---|
| | 320 | if( $png->working ) { |
|---|
| | 321 | $area = "working"; |
|---|
| | 322 | } else if ( $png->active ) { |
|---|
| | 323 | $area = "active"; |
|---|
| | 324 | } |
|---|
| | 325 | if( $path->dir ) { |
|---|
| | 326 | $dir = "1"; |
|---|
| | 327 | } else { |
|---|
| | 328 | $dir = "0"; |
|---|
| | 329 | } |
|---|
| | 330 | $path = "files/$area/$dir/{$png->filename}"; |
|---|
| | 331 | $bad_url = url($path,null,null,true); |
|---|
| | 332 | $base_url = explode( "/?q", $bad_url ); |
|---|
| | 333 | $path = "{$base_url[0]}/$path"; |
|---|
| | 334 | return $path; |
|---|
| | 335 | } |
|---|