Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Feb 11, 2025
1 parent 62fa0bc commit f7213ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions plugin/PlayerSkins/saveThumbnail.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
$videos_id = getVideos_id();
?>
<button class="btn btn-success btn-block btn-lg" id="captureScreenshot" data-toggle="tooltip" title="<?php echo __('Save this moment as Thumbnail'); ?>">
<button class="btn btn-success btn-block btn-lg" id="captureScreenshot" data-toggle="tooltip" title="<?php echo __('Save this moment as Thumbnail'); ?>">
<i class="fa fa-camera"></i> <span class="hidden-md hidden-sm hidden-xs"><?php echo __('Save this moment as Thumbnail'); ?></span>
</button>

<script>
$(document).ready(function () {
$('#captureScreenshot').on('click', async function () {
$(document).ready(function() {
$('#captureScreenshot').on('click', async function() {
player.pause();
const video = $('#mainVideo_html5_api')[0]; // Get the video element

Expand All @@ -31,13 +31,19 @@
const isPortrait = canvas.height > canvas.width;

// Convert canvas content to a data URL
const dataURL = canvas.toDataURL('image/png');
try {
const dataURL = canvas.toDataURL('image/png');
} catch (e) {
console.error("Canvas is tainted due to cross-origin video source.");
avideoAlertError("Cannot capture frame due to CORS restrictions.");
return;
}

// Show confirmation dialog before saving
const imgHtml = `<div style='text-align: center;'>
<img src='${dataURL}' style='max-width: 100%; max-height: 300px; border: 1px solid #ddd;' />
</div>`;
const confirmSave = await avideoConfirm(imgHtml+'Do you want to save this frame as the thumbnail?');
const confirmSave = await avideoConfirm(imgHtml + 'Do you want to save this frame as the thumbnail?');
if (!confirmSave) {
return; // Exit if the user cancels
}
Expand All @@ -52,7 +58,7 @@
portrait: isPortrait ? 1 : 0, // Send portrait flag
},
type: 'post',
success: function (response) {
success: function(response) {
modal.hidePleaseWait();
avideoResponse(response);
}
Expand Down
2 changes: 1 addition & 1 deletion view/managerVideosLight_imageTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$videos_id = getVideos_id();
$video = Video::getVideoLight($videos_id);

$htmlMediaTag = '<video ' . PlayerSkins::getPlaysinline() . ' preload="auto"
$htmlMediaTag = '<video ' . PlayerSkins::getPlaysinline() . ' preload="auto" crossorigin="anonymous"
controls class="embed-responsive-item video-js vjs-default-skin vjs-big-play-centered" id="mainVideo"
data-setup=\'{"techOrder": ["youtube","html5"]}\'>
</video>';
Expand Down

0 comments on commit f7213ee

Please sign in to comment.