Unable to seek to a video point #2923
Unanswered
FarhadShirmardi
asked this question in
Q&A
Replies: 1 comment
-
Hello, I know this question is quite old, but in case someone else faces the same issue, here's how I solved it: /**
* Serves private media files from the storage.
*
* This function handles the serving of private media files stored in the application's storage.
* It validates the incoming request using a signature and checks the requested filename against the media file's name.
* Depending on the presence of the 'download' parameter in the request, the function either returns a streamed response for downloading
* or an inline response for viewing the media file in the browser.
*
* @param Request $request The incoming request.
* @param Media $media The media file to be served.
* @param string $filename The expected filename of the media file.
*
* @return StreamedResponse|Response The response containing the media file.
*
*/
public function show(Request $request, Media $media, $filename): StreamedResponse|Response
{
$this->validateRequest($request, $media, $filename);
$mimeType = $media->mime_type; // Get the mime type of the media
$conversion = null;
if ($request->has('conversion')) {
$conversion = $request->input('conversion', null);
}
if (!is_null($conversion)) {
if ($media->hasGeneratedConversion($conversion)) {
// Return the converted file
return response()->file($media->getPath($conversion));
} else {
// Handle the case where the conversion doesn't exist
abort(404, 'Requested conversion not available');
}
}
$response = $request->has('download')
? $media->toResponse($request)
: $media->toInlineResponse($request);
// Add the 'Accept-Ranges' header if the media is a video
if (str_starts_with($mimeType, 'video/')) {
$response->headers->set('Accept-Ranges', 'bytes');
}
return $response;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been struggling with rendering video files. Using docs the video is successfully rendered but there's problem in seeking to a point in video in chrome.
Beta Was this translation helpful? Give feedback.
All reactions