Skip to content

Commit

Permalink
Add two custom metrics for video using source elements with media que…
Browse files Browse the repository at this point in the history
…ries (#137)

* Add two custom metrics for video using source elements with media queries

The first metric returns the number of video elements that have a source element using media. The second is an array of all video source media attribute values in play.

* Update dist/media.js

---------

Co-authored-by: Rick Viscomi <[email protected]>
Co-authored-by: Max Ostapenko <[email protected]>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent bde34cd commit 6cb50e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ return JSON.stringify({
'video_display_style' : Array.from(document.querySelectorAll('video')).map(video => {
return getComputedStyle(video, null).getPropertyValue('display');
}),
//Returns the number of video elements that contain a source element that uses a media attribute
'video_using_source_media_count': document.querySelectorAll('video:has(source[media])').length,
//Returns the media attribute values in use on video source elements
'video_source_media_values': Array.from(document.querySelectorAll('video source[media]')).map(source => {
return source.getAttribute('media');
}),
//returns an array of the number of source files per video tag.
'video_source_format_count': Array.from(document.querySelectorAll('video')).map(video => video.querySelectorAll('source').length),
//Returns all of the video types for each source file
Expand Down

0 comments on commit 6cb50e0

Please sign in to comment.