芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/cms.mgaplay.com.br/lib/Widget/LocalVideo.php
. */ namespace Xibo\Widget; use Illuminate\Support\Str; use Respect\Validation\Validator as v; use Slim\Http\Response as Response; use Slim\Http\ServerRequest as Request; use Xibo\Support\Exception\InvalidArgumentException; /** * Class LocalVideo * @package Xibo\Widget */ class LocalVideo extends ModuleWidget { /** * @inheritDoc */ public function layoutDesignerJavaScript() { return 'localvideo-designer-javascript'; } /** * Edit Widget * * @SWG\Put( * path="/playlist/widget/{widgetId}?localVideo", * operationId="WidgetLocalVideoEdit", * tags={"widget"}, * summary="Edit a Local Video Widget", * description="Edit a Local Video Widget. This call will replace existing Widget object, all not supplied parameters will be set to default.", * @SWG\Parameter( * name="widgetId", * in="path", * description="The WidgetId to Edit", * type="integer", * required=true * ), * @SWG\Parameter( * name="duration", * in="formData", * description="The Widget Duration", * type="integer", * required=false * ), * @SWG\Parameter( * name="useDuration", * in="formData", * description="(0, 1) Select 1 only if you will provide duration parameter as well", * type="integer", * required=false * ), * @SWG\Parameter( * name="uri", * in="formData", * description="A local file path or URL to the video. This can be RTSP stream.", * type="string", * required=true * ), * @SWG\Parameter( * name="scaleTypeId", * in="formData", * description="How should the video be scaled, available options: aspect, stretch", * type="string", * required=false * ), * @SWG\Parameter( * name="mute", * in="formData", * description="Flag (0, 1) Should the video be muted?", * type="integer", * required=false * ), * @SWG\Parameter( * name="showFullScreen", * in="formData", * description="Should the video expand over the top of existing content and show in full screen?", * type="integer", * required=false * ), * @SWG\Parameter( * name="enableStat", * in="formData", * description="The option (On, Off, Inherit) to enable the collection of Widget Proof of Play statistics", * type="string", * required=false * ), * @SWG\Response( * response=204, * description="successful operation" * ) * ) * * @inheritDoc */ public function edit(Request $request, Response $response): Response { $sanitizedParams = $this->getSanitizer($request->getParams()); // Set some options $this->setDuration($sanitizedParams->getInt('duration', ['default' => $this->getDuration()])); $this->setUseDuration($sanitizedParams->getCheckbox('useDuration')); $this->setOption('uri', urlencode($sanitizedParams->getString('uri'))); $this->setOption('scaleType', $sanitizedParams->getString('scaleTypeId', ['default' => 'aspect'])); $this->setOption('mute', $sanitizedParams->getCheckbox('mute')); $this->setOption('showFullScreen', $sanitizedParams->getCheckbox('showFullScreen')); $this->setOption('enableStat', $sanitizedParams->getString('enableStat')); $this->isValid(); // Save the widget $this->saveWidget(); return $response; } /** @inheritdoc */ public function isValid() { // Validate $url = urldecode($this->getOption('uri')); if (!v::stringType()->notEmpty()->validate($url)) { throw new InvalidArgumentException( __('Please enter a full path name giving the location of this video on the client'), 'uri' ); } // Allow a 0 duration for locally stored files, but not for remote streams, etc. if ($this->getUseDuration() == 1 && !v::intType()->min(1)->validate($this->getDuration()) && !Str::startsWith($url, 'file://') && Str::contains($url, '://') ) { throw new InvalidArgumentException(__('You must enter a duration.'), 'duration'); } return self::$STATUS_PLAYER; } /** @inheritdoc */ public function previewAsClient($width, $height, $scaleOverride = 0) { return $this->previewIcon(); } /** @inheritdoc */ public function getResource($displayId = 0) { // Get resource isn't required for this module. return null; } }