javascript - Click to turn off volume -
i want able turn on volume clicking image have worked out want turn off volume when image clicked off.
i have 2 images toggle between speaker on , speaker off
speaker_on when clicked changes image speaker off , audio plays speaker_off when clicked changes image speaker on audio not turn off
i'm using setvolume control audio setttings
here jquery code
$(document).ready(function(){ //use event delegation $(document).on('click','#imageid',function(){ var $this= $(this); $('#toggle').toggle('slide',function(){ //swap src of image on toggle completed var imgsrc = $this.attr('src'); $this.attr('src',$this.data('othersource')); $this.data('othersource',imgsrc); }); }); });
and html
<div id="toggle"><strong>click speaker volume</strong> </div> <img src="images/speaker_on.jpg" onclick='jwplayer(smallvid).setvolume(80);'id="imageid" data-othersource="/images/speaker_off.jpg" />
this code need call when speaker off image selected off image
jwplayer(smallvid).setvolume(0);
i've tried couple of approaches can't seem volume turn off when toggle speaker off image.
thanks
try jsfiddle here
jwplayer('playerveglz8hc').setup({ playlist: 'http://jwpsrv.com/feed/veglz8hc.rss', width: '100%', aspectratio: '16:9' }); $("#infotoggler").click(function() { var onvol = 100, offvol = 0 ; var vol = jwplayer().getvolume(); if(vol == 0 ) { jwplayer().setvolume(onvol); $(this).find('img').toggle(); } else{ jwplayer().setvolume(offvol); $(this).find('img').toggle(); } });
i toggling between image asked , setting volume on , off based on that, please check , let me know if works
happy
Comments
Post a Comment