Page 1 of 1

Auto-play videos, but with no download allowed

Posted: 16 Jun 2024, 02:41
by JMM
  • X3.32.0
  • PHP 8.3.8
Hello again, Karl,

I have been holding off since last year posting this question, because I didn't know how to explain my question  :thinking:.

First of all, on all my X3 sites, I have downloads disabled in Settings|Advanced.

On all my X3 sites, 99.9% of my content are images, but I do have a few videos.

In some of my galleries, I am using the <video> method in those galleries' Settings|Content field.  I love this method as it is so customizable, and I am using this method for most of my videos.

On my X3 test site, I've created a folder HERE to help illustrate my question in this post.

The top item on the page is by using the Settings|Content method, and I can prevent downloads by adding nodownload to the controlslist:
Code
<video class="x3-style-frame" preload="metadata" controls controlslist="nodownload noplaybackrate" width="100%"
 poster="{{path}}monkees_bars.png">
<source src="{{path}}monkees_no_audio.mp4" type="video/mp4">
That method works great for having multiple videos to choose from to play.

However, I have a very few galleries of videos where the Settings|Content method is not preferable, and where I wish to have images displayed normally, but when a user clicks on the picture it displays the video instead of the picture itself.  I have been using this method successfully for the past year or more, and it basically works (almost) perfectly.  I say almost, because I wish to be able to have the video automatically start playing when the picture is clicked on, which using some methods it works, but I also wish for those videos to not be downloadable.

So the requirements would be:
  1. start playing automatically when the picture is clicked on; and
  2. not to show the download selection when the video is playing
The 4 identical pictures on the lower part of the page all play the same video, but using 4 different methods, as indicated in the description below each picture:
  1. (_self) with the #autoplay tag
  2. (popup window) with the #autoplay tag
  3. (X3 popup) with the #autoplay tag
  4. (X3 popup) with the ?autoplay tag
Each of those methods either autoplays or prevents download, but not both  :upside_down:.

Of the 4 above methods, I would prefer to use the X3 popup method in #4.  But although Download is not shown (as I wish), the video does not start playing automatically.  And if I use #3, the video starts playing automatically (as I wish), but Download is shown.

Maybe the # and ? tags (or whatever they're called) are not the correct ones to use, and I should be using something different?

And maybe there's no way, when using X3 popup, to prevent the videos from being downloaded?

Thanks in advance.

Regards,
John

Re: Auto-play videos, but with no download allowed

Posted: 16 Jun 2024, 23:18
by mjau-mjau
When you are embedding the <video> tag yourself, you are in control of all options of course. However, when using any external option, like browser popup/self, the video will use the browsers default options ... It might support something like ?autoplay=1, but you certainly can't control other options of the video, like download options. It's same with the X3 popup video, which takes the video src, and plays it ... You can't forward external options in the url that control the <video> tag ...

I'm actually having problems testing your videos, as they aren't loading here, but it doesn't seem like much point. You can't control the <video> tag by ?url parameters, so your tests are at best coincidental, and might not even yield the same results  on different browsers and connection speeds. Especially autoplay, which you can't expect to work on all devices and browsers.

The only way to fully control the video, would be to control the <video> tag. To achieve this and open in a popup window, you would for example need to create and code your own video.html or video.php. Then forward url video.php?v=path/to/video.mp4. In the video, you would have your own <video> tag with downloads disabled and auto play enabled. Then you could open "video.php" as popup window (or self or new tab) or even the X3 popup. This would require some effort of course.

Re: Auto-play videos, but with no download allowed

Posted: 17 Jun 2024, 02:43
by JMM
Thanks for the explanation & confirmation, Karl.  I didn't think it would be possible, but in the past it turns out that X3 was capable of doing things that I didn't think would be possible, so I thought I would ask anyway.

... and might not even yield the same results on different browsers and connection speeds. Especially autoplay, which you can't expect to work on all devices and browsers.
I didn't even think to try a different browser, and was basing things on my use of my Chrome-based Brave browser.  I just tried that test page just now using Firefox, and some things look completely different.

The only way to fully control the video, would be to control the <video> tag. To achieve this and open in a popup window, you would for example need to create and code your own video.html or video.php. Then forward url video.php?v=path/to/video.mp4. In the video, you would have your own <video> tag with downloads disabled and auto play enabled. Then you could open "video.php" as popup window (or self or new tab) or even the X3 popup.
That is too far above my level of knowledge & expertise.

I'm perfectly happy & satisfied with the embedding of the <video> tags with Settings|Content that I'm using for 99% of my videos, so I'll just use that method for all of them.

Thanks again for your reply.

Regards,
John