html5 set border color with javascript when playingWhen to use double or single quotes in JavaScript?How to execute a JavaScript function when I have its name as a stringSet a default parameter value for a JavaScript functionChange an HTML5 input's placeholder color with CSSUsing HTML5/Canvas/JavaScript to take in-browser screenshotsColors in JavaScript consolePlaying audio with Javascript?HTML5 Audio - Progress BarJavaScript set object key by variableFireFox have two audio when play the mp4 with HTML5
Would a "Permanence" spell in 5e be overpowered?
Is throwing dice a stochastic or a deterministic process?
Does running exec do anything?
What to do when scriptures go against conscience?
Is disk brake effectiveness mitigated by tyres losing traction under strong braking?
In Futurama, how many beings has Leela slept with?
no sense/need/point
Is any special diet an effective treatment of autism?
Is 'contemporary' ambiguous and if so is there a better word?
Looking for sci-fi book based on Hinduism/Buddhism
Is there a word for food that's gone 'bad', but is still edible?
Is there an age requirement to play in Adventurers League?
Is there a proof that the set of real numbers can exactly represent distances?
What's the 2-minute timer on mobile Deutsche Bahn tickets?
Why does sound not move through a wall?
How do I allocate more memory to an app on Sheepshaver running Mac OS 9?
All of my Firefox add-ons been disabled suddenly, how can I re-enable them?
Piano: quaver triplets in RH v dotted quaver and semiquaver in LH
My first C++ game (snake console game)
Game artist computer workstation set-up – is this overkill?
What was the first story to feature the plot "the monsters were human all along"?
Why would a military not separate its forces into different branches?
Krull dimension of the ring of global sections
Motion-trail-like lines
html5
When to use double or single quotes in JavaScript?How to execute a JavaScript function when I have its name as a stringSet a default parameter value for a JavaScript functionChange an HTML5 input's placeholder color with CSSUsing HTML5/Canvas/JavaScript to take in-browser screenshotsColors in JavaScript consolePlaying audio with Javascript?HTML5 Audio - Progress BarJavaScript set object key by variableFireFox have two audio when play the mp4 with HTML5
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
digital store with mp3 files:
- html5 'audio' tag is used, with 'controls'; works superb
- since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);
it is django project (python); with bootstrap 4
- audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
ok, crimson. lol.
html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:
- play Fires when the audio/video has been started or is no longer paused
html:
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- onplay="player_border();" -->
<audio id="sample-player"
controls
loop
play="player_border();"
class="btn btn-sm my-auto ">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
audio tag also has 'paused' property:
- paused Returns whether the audio/video is paused or not
script:
<!-- scripts -->
<script type="text/javascript">
function player_border()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
playContainer.style.borderColor = 'orange'; // ko
player.style.borderColor = 'green'; // ko
var isPlaying = (!player.paused);
//document.getElementById("play_sample").play = function()
// elem = document.getElementById('#play_sample')
// var elem = document.getElementById('play_sample').innerHTML; # for inner text
// var player = document.getElementById('#play_sample');
// var play_container = document.getElementById('#play_container');
// play_container.style.color = 'orange;'
// play_container.style = 'border-color:orange;'
// play_container.style.borderColor = 'color:orange;'
// player.style.borderColor = 'color:green;'
// if (elem.audio.play)
// if (!elem.paused)
// if (!elem.audio.paused)
// if (!player.paused)
// if (player.play)
if (isPlaying)
playContainer.style = 'border-color:green';
player.style.borderColor = 'orange';
// player.style = 'borderColor:orange';
// play_container.style = 'border-color:border-warning'
// player.setAttribute('style', 'borderColor:orange;')
// play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
// elem.style = 'border:orange;'
// elem.setAttribute('style', 'border: 1px solid orange;'
// elem.style = 'border:border-warning'
;
</script>
say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;
sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.
thx for help,
bow,
s love nia
javascript html5 audio border
add a comment |
digital store with mp3 files:
- html5 'audio' tag is used, with 'controls'; works superb
- since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);
it is django project (python); with bootstrap 4
- audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
ok, crimson. lol.
html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:
- play Fires when the audio/video has been started or is no longer paused
html:
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- onplay="player_border();" -->
<audio id="sample-player"
controls
loop
play="player_border();"
class="btn btn-sm my-auto ">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
audio tag also has 'paused' property:
- paused Returns whether the audio/video is paused or not
script:
<!-- scripts -->
<script type="text/javascript">
function player_border()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
playContainer.style.borderColor = 'orange'; // ko
player.style.borderColor = 'green'; // ko
var isPlaying = (!player.paused);
//document.getElementById("play_sample").play = function()
// elem = document.getElementById('#play_sample')
// var elem = document.getElementById('play_sample').innerHTML; # for inner text
// var player = document.getElementById('#play_sample');
// var play_container = document.getElementById('#play_container');
// play_container.style.color = 'orange;'
// play_container.style = 'border-color:orange;'
// play_container.style.borderColor = 'color:orange;'
// player.style.borderColor = 'color:green;'
// if (elem.audio.play)
// if (!elem.paused)
// if (!elem.audio.paused)
// if (!player.paused)
// if (player.play)
if (isPlaying)
playContainer.style = 'border-color:green';
player.style.borderColor = 'orange';
// player.style = 'borderColor:orange';
// play_container.style = 'border-color:border-warning'
// player.setAttribute('style', 'borderColor:orange;')
// play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
// elem.style = 'border:orange;'
// elem.setAttribute('style', 'border: 1px solid orange;'
// elem.style = 'border:border-warning'
;
</script>
say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;
sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.
thx for help,
bow,
s love nia
javascript html5 audio border
add a comment |
digital store with mp3 files:
- html5 'audio' tag is used, with 'controls'; works superb
- since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);
it is django project (python); with bootstrap 4
- audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
ok, crimson. lol.
html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:
- play Fires when the audio/video has been started or is no longer paused
html:
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- onplay="player_border();" -->
<audio id="sample-player"
controls
loop
play="player_border();"
class="btn btn-sm my-auto ">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
audio tag also has 'paused' property:
- paused Returns whether the audio/video is paused or not
script:
<!-- scripts -->
<script type="text/javascript">
function player_border()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
playContainer.style.borderColor = 'orange'; // ko
player.style.borderColor = 'green'; // ko
var isPlaying = (!player.paused);
//document.getElementById("play_sample").play = function()
// elem = document.getElementById('#play_sample')
// var elem = document.getElementById('play_sample').innerHTML; # for inner text
// var player = document.getElementById('#play_sample');
// var play_container = document.getElementById('#play_container');
// play_container.style.color = 'orange;'
// play_container.style = 'border-color:orange;'
// play_container.style.borderColor = 'color:orange;'
// player.style.borderColor = 'color:green;'
// if (elem.audio.play)
// if (!elem.paused)
// if (!elem.audio.paused)
// if (!player.paused)
// if (player.play)
if (isPlaying)
playContainer.style = 'border-color:green';
player.style.borderColor = 'orange';
// player.style = 'borderColor:orange';
// play_container.style = 'border-color:border-warning'
// player.setAttribute('style', 'borderColor:orange;')
// play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
// elem.style = 'border:orange;'
// elem.setAttribute('style', 'border: 1px solid orange;'
// elem.style = 'border:border-warning'
;
</script>
say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;
sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.
thx for help,
bow,
s love nia
javascript html5 audio border
digital store with mp3 files:
- html5 'audio' tag is used, with 'controls'; works superb
- since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);
it is django project (python); with bootstrap 4
- audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
ok, crimson. lol.
html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:
- play Fires when the audio/video has been started or is no longer paused
html:
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- onplay="player_border();" -->
<audio id="sample-player"
controls
loop
play="player_border();"
class="btn btn-sm my-auto ">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
audio tag also has 'paused' property:
- paused Returns whether the audio/video is paused or not
script:
<!-- scripts -->
<script type="text/javascript">
function player_border()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
playContainer.style.borderColor = 'orange'; // ko
player.style.borderColor = 'green'; // ko
var isPlaying = (!player.paused);
//document.getElementById("play_sample").play = function()
// elem = document.getElementById('#play_sample')
// var elem = document.getElementById('play_sample').innerHTML; # for inner text
// var player = document.getElementById('#play_sample');
// var play_container = document.getElementById('#play_container');
// play_container.style.color = 'orange;'
// play_container.style = 'border-color:orange;'
// play_container.style.borderColor = 'color:orange;'
// player.style.borderColor = 'color:green;'
// if (elem.audio.play)
// if (!elem.paused)
// if (!elem.audio.paused)
// if (!player.paused)
// if (player.play)
if (isPlaying)
playContainer.style = 'border-color:green';
player.style.borderColor = 'orange';
// player.style = 'borderColor:orange';
// play_container.style = 'border-color:border-warning'
// player.setAttribute('style', 'borderColor:orange;')
// play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
// elem.style = 'border:orange;'
// elem.setAttribute('style', 'border: 1px solid orange;'
// elem.style = 'border:border-warning'
;
</script>
say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;
sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.
thx for help,
bow,
s love nia
javascript html5 audio border
javascript html5 audio border
asked Mar 23 at 2:50
chistabochistabo
34
34
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Event listeners in HTML start with the on prefix
Your code is correct, however, you need to use the attribute onplay not play
<audio onplay="callYourFunc()"></audio>
Another note:
You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the functionplayer_borderever run? Try placing aconsole.log('test')ordebugger;at the top to see if it hits that point
– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
add a comment |
this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- play="player_border();" -->
<!-- style="background:crimson; border-radius:27px;" -->
<audio id="sample-player"
controls
loop
onplay="sample_play();"
onpause="sample_pause()"
class="btn btn-sm my-auto">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
<div class="col-auto my-auto">
<span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
</div>
</div>
<!-- song description -->
<div class="row my-auto pb-2 text-justify">
<span class="text my-auto"> instance.description </span>
</div>
<!-- scripts -->
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (isPlaying)
player.style = 'background:crimson; border-radius:27px';
;
function sample_pause()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (!isPlaying)
player.style = 'background:none; border-radius:27px';
</script>
thx for help, i need somebody, help, not just anybody, lol, beatles.
this is the main loop (django/python) that populates items on page, it is in another file:
% for obj in object_list %
<div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
<div class="col my-auto ">
% include 'products/snippets/card.html' with instance=obj %
</div>
</div>
% endfor %
what now?
add a comment |
making slow progress:
audio tag has two events, same function call:
onplay="sample_play()"
onpause="sample_play()"
function sample_play() has been simplified:
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player')
if (!player.paused)
player.style = 'background:crimson; border-radius:27px'
else
player.style = 'background:none; border-radius:27px'
</script>
but, still, it only works on first audio element on page. weird, i say.
thx for help.
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310157%2fhtml5-audio-set-border-color-with-javascript-when-playing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Event listeners in HTML start with the on prefix
Your code is correct, however, you need to use the attribute onplay not play
<audio onplay="callYourFunc()"></audio>
Another note:
You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the functionplayer_borderever run? Try placing aconsole.log('test')ordebugger;at the top to see if it hits that point
– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
add a comment |
Event listeners in HTML start with the on prefix
Your code is correct, however, you need to use the attribute onplay not play
<audio onplay="callYourFunc()"></audio>
Another note:
You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the functionplayer_borderever run? Try placing aconsole.log('test')ordebugger;at the top to see if it hits that point
– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
add a comment |
Event listeners in HTML start with the on prefix
Your code is correct, however, you need to use the attribute onplay not play
<audio onplay="callYourFunc()"></audio>
Another note:
You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.
Event listeners in HTML start with the on prefix
Your code is correct, however, you need to use the attribute onplay not play
<audio onplay="callYourFunc()"></audio>
Another note:
You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.
answered Mar 23 at 2:57
ChrisBrownie55ChrisBrownie55
2,0071823
2,0071823
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the functionplayer_borderever run? Try placing aconsole.log('test')ordebugger;at the top to see if it hits that point
– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
add a comment |
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the functionplayer_borderever run? Try placing aconsole.log('test')ordebugger;at the top to see if it hits that point
– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol
– chistabo
Mar 23 at 3:22
Does the function
player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point– ChrisBrownie55
Mar 23 at 3:25
Does the function
player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point– ChrisBrownie55
Mar 23 at 3:25
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.
– chistabo
Mar 23 at 3:35
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.
– ChrisBrownie55
Mar 23 at 3:39
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.
– chistabo
Mar 23 at 3:55
add a comment |
this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- play="player_border();" -->
<!-- style="background:crimson; border-radius:27px;" -->
<audio id="sample-player"
controls
loop
onplay="sample_play();"
onpause="sample_pause()"
class="btn btn-sm my-auto">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
<div class="col-auto my-auto">
<span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
</div>
</div>
<!-- song description -->
<div class="row my-auto pb-2 text-justify">
<span class="text my-auto"> instance.description </span>
</div>
<!-- scripts -->
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (isPlaying)
player.style = 'background:crimson; border-radius:27px';
;
function sample_pause()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (!isPlaying)
player.style = 'background:none; border-radius:27px';
</script>
thx for help, i need somebody, help, not just anybody, lol, beatles.
this is the main loop (django/python) that populates items on page, it is in another file:
% for obj in object_list %
<div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
<div class="col my-auto ">
% include 'products/snippets/card.html' with instance=obj %
</div>
</div>
% endfor %
what now?
add a comment |
this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- play="player_border();" -->
<!-- style="background:crimson; border-radius:27px;" -->
<audio id="sample-player"
controls
loop
onplay="sample_play();"
onpause="sample_pause()"
class="btn btn-sm my-auto">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
<div class="col-auto my-auto">
<span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
</div>
</div>
<!-- song description -->
<div class="row my-auto pb-2 text-justify">
<span class="text my-auto"> instance.description </span>
</div>
<!-- scripts -->
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (isPlaying)
player.style = 'background:crimson; border-radius:27px';
;
function sample_pause()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (!isPlaying)
player.style = 'background:none; border-radius:27px';
</script>
thx for help, i need somebody, help, not just anybody, lol, beatles.
this is the main loop (django/python) that populates items on page, it is in another file:
% for obj in object_list %
<div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
<div class="col my-auto ">
% include 'products/snippets/card.html' with instance=obj %
</div>
</div>
% endfor %
what now?
add a comment |
this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- play="player_border();" -->
<!-- style="background:crimson; border-radius:27px;" -->
<audio id="sample-player"
controls
loop
onplay="sample_play();"
onpause="sample_pause()"
class="btn btn-sm my-auto">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
<div class="col-auto my-auto">
<span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
</div>
</div>
<!-- song description -->
<div class="row my-auto pb-2 text-justify">
<span class="text my-auto"> instance.description </span>
</div>
<!-- scripts -->
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (isPlaying)
player.style = 'background:crimson; border-radius:27px';
;
function sample_pause()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (!isPlaying)
player.style = 'background:none; border-radius:27px';
</script>
thx for help, i need somebody, help, not just anybody, lol, beatles.
this is the main loop (django/python) that populates items on page, it is in another file:
% for obj in object_list %
<div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
<div class="col my-auto ">
% include 'products/snippets/card.html' with instance=obj %
</div>
</div>
% endfor %
what now?
this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.
<div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->
<!-- style="border-color:crimson" -->
<!-- play="player_border();" -->
<!-- style="background:crimson; border-radius:27px;" -->
<audio id="sample-player"
controls
loop
onplay="sample_play();"
onpause="sample_pause()"
class="btn btn-sm my-auto">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>
<div class="col-auto my-auto">
<span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
</div>
</div>
<!-- song description -->
<div class="row my-auto pb-2 text-justify">
<span class="text my-auto"> instance.description </span>
</div>
<!-- scripts -->
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (isPlaying)
player.style = 'background:crimson; border-radius:27px';
;
function sample_pause()
var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
var isPlaying = (!player.paused);
if (!isPlaying)
player.style = 'background:none; border-radius:27px';
</script>
thx for help, i need somebody, help, not just anybody, lol, beatles.
this is the main loop (django/python) that populates items on page, it is in another file:
% for obj in object_list %
<div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
<div class="col my-auto ">
% include 'products/snippets/card.html' with instance=obj %
</div>
</div>
% endfor %
what now?
answered Mar 23 at 3:48
chistabochistabo
34
34
add a comment |
add a comment |
making slow progress:
audio tag has two events, same function call:
onplay="sample_play()"
onpause="sample_play()"
function sample_play() has been simplified:
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player')
if (!player.paused)
player.style = 'background:crimson; border-radius:27px'
else
player.style = 'background:none; border-radius:27px'
</script>
but, still, it only works on first audio element on page. weird, i say.
thx for help.
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
add a comment |
making slow progress:
audio tag has two events, same function call:
onplay="sample_play()"
onpause="sample_play()"
function sample_play() has been simplified:
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player')
if (!player.paused)
player.style = 'background:crimson; border-radius:27px'
else
player.style = 'background:none; border-radius:27px'
</script>
but, still, it only works on first audio element on page. weird, i say.
thx for help.
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
add a comment |
making slow progress:
audio tag has two events, same function call:
onplay="sample_play()"
onpause="sample_play()"
function sample_play() has been simplified:
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player')
if (!player.paused)
player.style = 'background:crimson; border-radius:27px'
else
player.style = 'background:none; border-radius:27px'
</script>
but, still, it only works on first audio element on page. weird, i say.
thx for help.
making slow progress:
audio tag has two events, same function call:
onplay="sample_play()"
onpause="sample_play()"
function sample_play() has been simplified:
<script type="text/javascript">
function sample_play()
var player = document.getElementById('sample-player')
if (!player.paused)
player.style = 'background:crimson; border-radius:27px'
else
player.style = 'background:none; border-radius:27px'
</script>
but, still, it only works on first audio element on page. weird, i say.
thx for help.
answered Mar 23 at 4:24
chistabochistabo
34
34
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
add a comment |
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol
– chistabo
Mar 23 at 5:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310157%2fhtml5-audio-set-border-color-with-javascript-when-playing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown