BxBaseFileHandlerSoundsViewer.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Sounds viewer (player) preview sound files.
  11. * @see BxDolFileHandler
  12. */
  13. class BxBaseFileHandlerSoundsViewer extends BxBaseFileHandler
  14. {
  15. protected $_oTranscoder;
  16. public function __construct ($aObject, $oTemplate)
  17. {
  18. parent::__construct ($aObject, $oTemplate);
  19. $this->_oTranscoder = null;
  20. }
  21. public function setTranscoder($oTranscoder)
  22. {
  23. $this->_oTranscoder = $oTranscoder;
  24. }
  25. public function display ($sFileUrl, $aFile)
  26. {
  27. $this->addCssJs();
  28. return $this->_oTranscoder && ($oPlayer = BxDolPlayer::getObjectInstance()) ? BxDolTemplate::getInstance()->parseHtmlByName('file_handler_sound.html', [
  29. 'file_name' => $aFile['file_name'],
  30. 'file_url' => $this->_oTranscoder->getFileUrl($aFile['id']),
  31. 'player' => $this->_oTranscoder->isFileReady($aFile['id']) ?
  32. $oPlayer->getCodeAudio (BX_PLAYER_STANDARD, array(
  33. 'mp3' => $this->_oTranscoder->getFileUrl($aFile['id']),
  34. )) : MsgBox(_t('_sys_txt_err_sound_not_transcoded_yet')),
  35. ]) : '';
  36. }
  37. }
  38. /** @} */