amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Allow dynamic change of src in video element

Open koshka opened this issue 10 years ago • 8 comments

Short description:

The page embeds a video element. Depending on the platform (mobile vs. desktop mainly), the video source element points to specific CDN assets, in that case either a high-resolution MP4 or a low-res MP4 version.

An "HD" button allows the user to toggle between the different sources.

Currently, this is only doable through JS. We'd like an AMP version of that functionality to allow users/developers to change src

As an example, please refer to https://gfycat.com/OldfashionedShrillBorderterrier

koshka avatar Sep 07 '16 23:09 koshka

You can do resolution dependent video with media queries on the <source> tag. It won't give you manual HD switching but it will give you the ability to switch automatically based on screen res.

   <source src="video-small.mp4" type="video/mp4" media="all and (max-width: 480px)"> 
   <source src="video-small.webm" type="video/webm" media="all and (max-width: 480px)"> 
   <source src="video.mp4" type="video/mp4"> 
   <source src="video.webm" type="video/webm">

jpettitt avatar Sep 08 '16 02:09 jpettitt

/cc @ericlindley-g @rudygalfi /cc @aghassemi for context

dvoytenko avatar Sep 08 '16 17:09 dvoytenko

Has some similarity to image-src-swapping based on thumbnail clicks in https://github.com/ampproject/amphtml/issues/4500. The UI is different, so it may strengthen the case for a generalized way of doing this.

ericlindley-g avatar Sep 08 '16 17:09 ericlindley-g

Do we still need this FR? Thanks

adelinamart avatar Feb 14 '17 00:02 adelinamart

yes, let's keep it.

aghassemi avatar Feb 14 '17 02:02 aghassemi

+1 to keeping this for now. I should note that I think amp-bind covers this, using the amp-video component (you can see a demo in the last example on this page). Note that amp-bind is currently experimental, so it is not yet in production.

ericlindley-g avatar Feb 14 '17 03:02 ericlindley-g

@ericlindley-g Can we close this issue? Looks like bind covers this use-case, as you mentioned.

kmh287 avatar May 12 '17 20:05 kmh287

+1 Closing

ericlindley-g avatar May 12 '17 23:05 ericlindley-g