Editing User:Toad64/SandboxGive feedback
Jump to navigation
Jump to search
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
Using Javascript, It is possible to modify the default audio element used to play audio. | Using Javascript (and a set of ::root colors i had), It is possible to modify the default audio element used to play audio. | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
// In your Common.js | // In your Common.js | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// Find every native audio player generated by the wiki | |||
$('audio').each(function() { | $('audio').each(function() { | ||
const | // Create your custom component | ||
const myPlayer = document.createElement('audio-player'); | |||
// Transfer the source | |||
myPlayer.setAttribute('track', $(this).attr('src')); | |||
// | // Replace the native player with your custom one | ||
$(this).replaceWith(myPlayer); | |||
}); | }); | ||
}); | }); | ||
| Line 40: | Line 33: | ||
align-items: center; | align-items: center; | ||
gap: 12px; | gap: 12px; | ||
width: 100%; | width: 100%; | ||
max-width: 400px; | max-width: 400px; | ||
background: var(--background-color-base-border); | |||
padding: 10px 15px; | |||
border-radius: 50px; | border-radius: 50px; | ||
color: var(--color-base); | color: var(--color-base); | ||
font-family: sans-serif; | font-family: sans-serif; | ||
} | } | ||
.playBtn { | .playBtn { | ||
width: 30px; | width: 30px; | ||
height: 30px; | height: 30px; | ||
background: var(--background-color-interactive); | |||
border: none; | border: none; | ||
color: var(--color-base); | |||
border-radius: 50%; | border-radius: 50%; | ||
cursor: pointer; | cursor: pointer; | ||
flex-shrink: 0; | |||
} | } | ||
.seek { | .seek { | ||
-webkit-appearance: none; | |||
flex: 1; | |||
height: 6px; | height: 6px; | ||
background: var(--color-base); | |||
border-radius: 5px; | border-radius: 5px; | ||
cursor: pointer; | cursor: pointer; | ||
} | } | ||
.seek::-webkit-slider-thumb { | .seek::-webkit-slider-thumb { | ||
-webkit-appearance: none; | -webkit-appearance: none; /* Override default look */ | ||
appearance: none; | appearance: none; | ||
border-radius: 50px; | |||
width: 15px; | width: 15px; | ||
height: 15px; | height: 15px; | ||
background: var(--link-color); | background: var(--link-color); | ||
cursor: pointer; | cursor: pointer; | ||
| Line 99: | Line 71: | ||
.seek::-moz-range-thumb { | .seek::-moz-range-thumb { | ||
border-radius: 50px; | |||
width: 15px; | width: 15px; | ||
height: 15px; | height: 15px; | ||
background: var(--link-color); | background: var(--link-color); | ||
cursor: pointer; | cursor: pointer; | ||
} | } | ||
.time { font-size: 12px; opacity: 0.8; white-space: nowrap; } | |||
.time { | |||
</style> | </style> | ||
| Line 156: | Line 119: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This code creates a styleized media player (in this example the Old Deadlock Title Screen): | |||
[[File:Music menu lp.mp3]] | [[File:Music menu lp.mp3]] | ||