Notification With Sound

1,241 views
Skip to first unread message

Zaki Abdellah

unread,
Oct 18, 2016, 11:00:11 AM10/18/16
to Chromium-Extensions-Announce
Hi everyone
     can any person how makes a beautiful notifications with song mp3 tell me how can i do thats in my extension .
i have a web page monitoring with some jquery listner if i got a empty table i do nothing , else i must push a popup notification with a song , every 10 sec i reload this pag for loking changes.

Best regard 

Mykyta Khmel

unread,
Oct 18, 2016, 11:21:45 AM10/18/16
to Chromium-Extensions-Announce
Actually you can use html5 audio api to play sound in contentscript invoking with message from background

Zaki Abdellah

unread,
Oct 19, 2016, 4:15:40 AM10/19/16
to Chromium-Extensions-Announce
Thank you for helping us 
     ihave a problem with my script 
var audioElement;
if(!audioElement) {
  audioElement = document.createElement('audio');
  audioElement.innerHTML = '<source src="' + 'C:/Users/zakimo/Desktop/Mustapha Sahbi/static/js/Yew.mp3'+ '" type="audio/mpeg" />'
}
audioElement.play();
  }

with error 
Not allowed to load local resource: file:///C:/Users/zakimo/Desktop/Mustapha%20Sahbi/static/js/Yew.mp3

Mykyta Khmel

unread,
Oct 19, 2016, 4:44:51 AM10/19/16
to Chromium-Extensions-Announce
for this case you should add your audio to manifest as web_accessible_resources :
{
  ...
  "web_accessible_resources": [
    "static/js/Yew.mp3",
], ... }

and from contentscript make something like: 
chrome.extension.getURL('static/js/Yew.mp3');//from root of your extension

Mykyta Khmel

unread,
Oct 19, 2016, 4:49:00 AM10/19/16
to Chromium-Extensions-Announce
yous path is incorrect you are using absolute path from your system (C:/Users/...) but you should use at list 'static/js/Yew.mp3' (depends on your extension root)


On Tuesday, October 18, 2016 at 6:00:11 PM UTC+3, Zaki Abdellah wrote:

Zaki Abdellah

unread,
Oct 19, 2016, 5:27:26 AM10/19/16
to Chromium-Extensions-Announce
Ok this is myscript.js

$(window).on( 'load', function () {



if ( $(".list2_no_records").length ) {

    //alert("ha hwa khaoiiiii ")
  }else{

  alert(" P2 Assigned to Mobility Queue! Leave whatever you're working on and HANDLE IT");
  /* var audioElement;
if(!audioElement) {
  audioElement = document.createElement('audio');
  audioElement.innerHTML = '<source src="' + 'static/js/Yew.mp3'+ '" type="audio/mpeg" />'
}
audioElement.play();
  }*/
  }
  chrome.extension.getURL('static/js/Yew.mp3');//from root of your extension



} );

PhistucK

unread,
Oct 19, 2016, 6:14:38 AM10/19/16
to Zaki Abdellah, Chromium-Extensions-Announce
Instead of constructing elements, just use this -
​new Audio(chrome.runtime.getURL("static/js/src.mp3")).play()​;



PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/c4886aa1-fcc7-4485-894e-305846f51817%40chromium.org.

Zaki Abdellah

unread,
Oct 19, 2016, 6:19:47 AM10/19/16
to Chromium-Extensions-Announce, zakimoulaya...@gmail.com
Thank you PhistucK

i have this error when i use this 
new Audio(chrome.runtime.getURL("static/js/src.mp3")).play()​;



Uncaught SyntaxError: Invalid or unexpected token




PhistucK

To post to this group, send email to chromium-...@chromium.org.

PhistucK

unread,
Oct 19, 2016, 6:35:01 AM10/19/16
to Zaki Abdellah, Chromium-Extensions-Announce
​And did you try to fix it? This is basic JavaScript and this is not the place for general JavaScript support.
Try this -
(new Audio(chrome.runtime.getURL("static/js/src.mp3"))).play()​;

Please, refrain from seeking general web development support here.


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.

Zaki Abdellah

unread,
Oct 19, 2016, 6:54:30 AM10/19/16
to Chromium-Extensions-Announce, zakimoulaya...@gmail.com
plz can we help me cause i khnow this not  place for general JavaScript support.

this is my code i wanna just play a sound 


$(window).on( 'load', function () {



if ( $(".list2_no_records").length ) {

    //alert("ha hwa khaoiiiii ")
  }else{
  (new Audio(chrome.runtime.getURL("static/js/src.mp3"))).play()​;

  alert(" kindly this is not empty try ");
 



}

} );



Le mercredi 19 octobre 2016 11:35:01 UTC+1, PhistucK a écrit :
​And did you try to fix it? This is basic JavaScript and this is not the place for general JavaScript support.
Try this -
(new Audio(chrome.runtime.getURL("static/js/src.mp3"))).play()​;

Please, refrain from seeking general web development support here.


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

PhistucK

unread,
Oct 19, 2016, 6:57:02 AM10/19/16
to Zaki Abdellah, Chromium-Extensions-Announce
​Try doing it in a regular web page and if it succeeds there and not in extensions, you can ask for help. Otherwise, this is off topic for this group, sorry.​


PhistucK



PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.

PhistucK

unread,
Oct 19, 2016, 6:58:26 AM10/19/16
to Zaki Abdellah, Chromium-Extensions-Announce
And I recommend stackoverflow.com for extensions and general web development questions. This is entirely appropriate to be asked there.


PhistucK

On Wed, Oct 19, 2016 at 1:56 PM, PhistucK <phis...@gmail.com> wrote:
​Try doing it in a regular web page and if it succeeds there and not in extensions, you can ask for help. Otherwise, this is off topic for this group, sorry.​


PhistucK

Reply all
Reply to author
Forward
0 new messages