当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaInterface::getBinaryContent方法代码示例

本文整理汇总了PHP中Sonata\MediaBundle\Model\MediaInterface::getBinaryContent方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaInterface::getBinaryContent方法的具体用法?PHP MediaInterface::getBinaryContent怎么用?PHP MediaInterface::getBinaryContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\MediaBundle\Model\MediaInterface的用法示例。


在下文中一共展示了MediaInterface::getBinaryContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (preg_match("/vimeo\\.com\\/(\\d+)/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[1]);
     }
 }
开发者ID:serialken,项目名称:BugTracker,代码行数:12,代码来源:VimeoProvider.php

示例2: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (preg_match("/(?<=v(\\=|\\/))([-a-zA-Z0-9_]+)|(?<=youtu\\.be\\/)([-a-zA-Z0-9_]+)/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[2]);
     }
 }
开发者ID:rmzamora,项目名称:SonataMediaBundle,代码行数:12,代码来源:YouTubeProvider.php

示例3: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (strlen($media->getBinaryContent()) === 11) {
         return;
     }
     if (preg_match("/^(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\\/))([^\\#\\?&\"'>]+)/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[1]);
     }
 }
开发者ID:rapemer,项目名称:init-cms-bundle,代码行数:15,代码来源:YouTubeProvider.php

示例4: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (strlen($media->getBinaryContent()) === 11) {
         return;
     }
     if (preg_match("/videos\\.sapo\\.pt\\/([A-Za-z0-9]+)(\\/mov\\/)?/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[1]);
     }
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:15,代码来源:SoundcloudProvider.php

示例5: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (strpos($media->getBinaryContent(), '|') !== FALSE) {
         return;
     }
     if (preg_match('/(?:config\\.|player\\.)?playwire.com\\/(\\d+)\\/videos\\/v2\\/(\\d+)\\//', $media->getBinaryContent(), $matches)) {
         $binary = sprintf('%d|%d', $matches[1], $matches[2]);
         $media->setBinaryContent($binary);
     }
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:16,代码来源:PlayWireProvider.php

示例6: getMetadata

 /**
  * @throws \RuntimeException
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  * @return mixed|null|string
  */
 public function getMetadata(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return null;
     }
     $url = sprintf('http://www.dailymotion.com/services/oembed?url=http://www.dailymotion.com/video/%s&format=json', $media->getBinaryContent());
     $metadata = @file_get_contents($url);
     if (!$metadata) {
         throw new \RuntimeException('Unable to retrieve dailymotion video information for :' . $url);
     }
     $metadata = json_decode($metadata, true);
     if (!$metadata) {
         throw new \RuntimeException('Unable to decode dailymotion video information for :' . $url);
     }
     return $metadata;
 }
开发者ID:helmer,项目名称:SonataMediaBundle,代码行数:21,代码来源:DailyMotionProvider.php

示例7: transform

 /**
  * {@inheritdoc}
  */
 public final function transform(MediaInterface $media)
 {
     if (null === $media->getBinaryContent()) {
         return;
     }
     $this->doTransform($media);
 }
开发者ID:ingeniorweb,项目名称:symfo3cv,代码行数:10,代码来源:BaseProvider.php

示例8: getMetadata

 public function getMetadata(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     $format = 'reference';
     $getId3 = new GetId3();
     $fileinfo = $getId3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8')->analyze($media->getBinaryContent()->getPathname());
     $metadata = array('src' => $this->generatePublicUrl($media, $format), 'filesize' => $fileinfo['filesize'], 'fileformat' => $fileinfo['fileformat'], 'encoding' => $fileinfo['encoding'], 'mime_type' => $fileinfo['mime_type'], 'playtime_seconds' => $fileinfo['playtime_seconds'], 'playtime_string' => $fileinfo['playtime_string'], 'bitrate' => $fileinfo['bitrate'], 'audio_dataformat' => $fileinfo['audio']['dataformat'], 'audio_codec' => isset($fileinfo['audio']['codec']) ? $fileinfo['audio']['codec'] : '', 'audio_sample_rate' => $fileinfo['audio']['sample_rate'], 'audio_channels' => $fileinfo['audio']['channels'], 'audio_bits_per_sample' => isset($fileinfo['audio']['bits_per_sample']) ? $fileinfo['audio']['bits_per_sample'] : '', 'audio_lossless' => isset($fileinfo['audio']['lossless']) ? $fileinfo['audio']['lossless'] : '', 'audio_channelmode' => isset($fileinfo['audio']['channelmode']) ? $fileinfo['audio']['channelmode'] : '', 'video_dataformat' => $fileinfo['video']['dataformat'], 'video_resolution_x' => $fileinfo['video']['resolution_x'], 'video_resolution_y' => $fileinfo['video']['resolution_y'], 'video_fourcc' => isset($fileinfo['video']['fourcc']) ? $fileinfo['video']['fourcc'] : '', 'video_frame_rate' => $fileinfo['video']['frame_rate'], 'video_codec' => isset($fileinfo['video']['codec']) ? $fileinfo['video']['codec'] : '');
     /*echo "<pre>";
       print_r($metadata);
       print_r($fileinfo);
       echo "</pre>";
       exit();*/
     return $metadata;
 }
开发者ID:estebannovo,项目名称:multimedia,代码行数:16,代码来源:VideoProvider.php

示例9: createQrCode

 protected function createQrCode(MediaInterface $media)
 {
     $path = tempnam(sys_get_temp_dir(), 'sonata_media_qrcode_reference') . '.' . $this->config['extension'];
     $qrCode = new QrCode();
     $qrCode->setText($media->getBinaryContent())->setSize($this->config['size'])->setPadding($this->config['padding'])->setErrorCorrection($this->config['error_correction'])->setForegroundColor($this->config['foreground'])->setBackgroundColor($this->config['background'])->setLabel($this->config['label'])->setLabelFontSize($this->config['label_size'])->setImageType($this->config['extension']);
     if ($this->config['logo'] && is_file($this->config['logo'])) {
         $qrCode->setLogo($this->config['logo']);
     }
     $qrCode->save($path);
     return $path;
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:11,代码来源:QrCodeProvider.php

示例10: updateMetadata

 /**
  * {@inheritdoc}
  */
 public function updateMetadata(MediaInterface $media, $force = true)
 {
     try {
         if (!$media->getBinaryContent() instanceof \SplFileInfo) {
             // this is now optimized at all!!!
             $path = tempnam(sys_get_temp_dir(), 'sonata_update_metadata');
             $fileObject = new \SplFileObject($path, 'w');
             $fileObject->fwrite($this->getReferenceFile($media)->getContent());
         } else {
             $fileObject = $media->getBinaryContent();
         }
         $image = $this->imagineAdapter->open($fileObject->getPathname());
         $size = $image->getSize();
         $media->setSize($fileObject->getSize());
         $media->setWidth($size->getWidth());
         $media->setHeight($size->getHeight());
     } catch (\LogicException $e) {
         $media->setProviderStatus(MediaInterface::STATUS_ERROR);
         $media->setSize(0);
         $media->setWidth(0);
         $media->setHeight(0);
     }
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:26,代码来源:ImageProvider.php

示例11: postPersist

 /**
  * {@inheritdoc}
  */
 public function postPersist(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     $this->generateThumbnails($media);
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:10,代码来源:BaseVideoProvider.php

示例12: postPersist

 /**
  * {@inheritdoc}
  */
 public function postPersist(MediaInterface $media)
 {
     if ($media->getBinaryContent() === null) {
         return;
     }
     $this->setFileContents($media);
     $this->generateThumbnails($media);
 }
开发者ID:estebannovo,项目名称:multimedia,代码行数:11,代码来源:MultimediaBaseProvider.php

示例13: generateBinaryFromRequest

 /**
  * Set media binary content according to request content.
  *
  * @param MediaInterface $media
  */
 protected function generateBinaryFromRequest(MediaInterface $media)
 {
     if (php_sapi_name() === 'cli') {
         throw new \RuntimeException('The current process cannot be executed in cli environment');
     }
     if (!$media->getContentType()) {
         throw new \RuntimeException('You must provide the content type value for your media before setting the binary content');
     }
     $request = $media->getBinaryContent();
     if (!$request instanceof Request) {
         throw new \RuntimeException('Expected Request in binary content');
     }
     $content = $request->getContent();
     // create unique id for media reference
     $guesser = ExtensionGuesser::getInstance();
     $extension = $guesser->guess($media->getContentType());
     if (!$extension) {
         throw new \RuntimeException(sprintf('Unable to guess extension for content type %s', $media->getContentType()));
     }
     $handle = tmpfile();
     fwrite($handle, $content);
     $file = new ApiMediaFile($handle);
     $file->setExtension($extension);
     $file->setMimetype($media->getContentType());
     $media->setBinaryContent($file);
 }
开发者ID:kea,项目名称:SonataMediaBundle,代码行数:31,代码来源:FileProvider.php

示例14: setFileContents

 /**
  * Set the file contents for a video
  *
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  * @param string $contents path to contents, defaults to MediaInterface BinaryContent
  *
  * @return void
  */
 protected function setFileContents(MediaInterface $media, $contents = null)
 {
     if (!$contents) {
         $contents = $media->getBinaryContent()->getRealPath();
     }
     $destination = sprintf('%s/%s/', $this->getFilesystem()->getAdapter()->getDirectory(), $this->generatePath($media));
     if (!is_dir($destination)) {
         mkdir($destination, 775, true);
     }
     if (is_uploaded_file($contents)) {
         move_uploaded_file($contents, $destination . $media->getProviderReference());
     } else {
         copy($contents, $destination . $media->getProviderReference());
     }
 }
开发者ID:mtpmcdermott,项目名称:VideoBundle,代码行数:23,代码来源:VideoProvider.php

示例15: validate

 /**
  * {@inheritdoc}
  */
 public function validate(ErrorElement $errorElement, MediaInterface $media)
 {
     if (!$media->getBinaryContent() instanceof \SplFileInfo) {
         return;
     }
     if ($media->getBinaryContent() instanceof UploadedFile) {
         $fileName = $media->getBinaryContent()->getClientOriginalName();
     } elseif ($media->getBinaryContent() instanceof File) {
         $fileName = $media->getBinaryContent()->getFilename();
     } else {
         throw new \RuntimeException(sprintf('Invalid binary content type: %s', get_class($media->getBinaryContent())));
     }
     if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), $this->allowedExtensions)) {
         $errorElement->with('binaryContent')->addViolation('Invalid extensions')->end();
     }
     if (!in_array($media->getBinaryContent()->getMimeType(), $this->allowedMimeTypes)) {
         $errorElement->with('binaryContent')->addViolation('Invalid mime type : ' . $media->getBinaryContent()->getMimeType())->end();
     }
 }
开发者ID:ingeniorweb,项目名称:symfo3cv,代码行数:22,代码来源:FileProvider.php


注:本文中的Sonata\MediaBundle\Model\MediaInterface::getBinaryContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。