douyun3631 2013-10-10 18:56
浏览 640

静音/取消静音按钮

I have a set of php/html pages that contain buttons that when the mouse is over it plays a sound. Now I want that when the user clicks on another button, it silence all pages of the site or put them with sound, depending if the sound was already on or not.

I already have an html code that allows me to silence the page, but it only work on the page itself, if I go to any other page or go back to that page they have sound. And I don't want that...

This is an exemple of the code in one of the pages:

<audio preload  id="sombotao">
 <source src="audio/somBotao.ogg"></source>
</audio>

<a href="exemple.php"><img src="img/exemple.png" onMouseOver="document.getElementById('sombotao').play()" /></a>

I've tried using javascript, but it didn’t work. I even tried with php using sessions, but since my experience is very limited it also didn’t work.

Can anyone help me? Where can I find a piece of code as an example?

Thanks in advance. JV

  • 写回答

1条回答 默认 最新

  • dongliechuich10319 2015-08-06 18:08
    关注

    This is completely possible. One solution will take a combination of server side and client side code. Your pages must have code that automatically checks the server every so often for updates to the volume level (This works similar to automatically updating comment feeds or stock tickers, but is so much simpler).

    Your solution will look like this:

    Step 1

    Page 1:

    • Sound is playing

    Page 2:

    • Sound is playing

    Step 2

    Page 1:

    • User clicks the mute button.
    • Page 1 "posts" via ajax to volumecontrol.php

    Step 3

    Page 1:

    • Query volumecontrol.php and find page is muted, continue muting

    Page 2:

    • Query volumecontrol.php and find page is muted, change current volume to "mute"

    A little more explanation

    Think of this like a whiteboard at a doorway. As people enter and leave the room, they leave instructions for the other members. Members do not have to be present when a message is written, they only have to see the board every so often to coordinate with the other members of the group.

    One important part of this whole process is that you will set the volume according to something unique to the user (i.e. a session variable).

    Another key is that you use Ajax to push settings to a page in PHP and use Ajax to regularly check the server for updates to that setting.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)