Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Site Notices
Posted: 5/24/2023 1:53:10 PM EDT
Im trying this:
var beat = new Audio('file://C:/Users/me/horn.mp3');
beat.play();

does nothing...
Ive tried extra / in those 3 spots to maybe escape it, but that wasnt it either.
also tried /c/Users/me/horn.mp3 that also wasnt it.  Also C:\Users\me\horn.mp3 didnt work. also tried w/o the let keyword.
testing at https://linangdata.com/javascript-tester/ and other JS stuff works there so i just know its some mundane detail...
Link Posted: 5/24/2023 2:00:29 PM EDT
[#1]
file:///

Link Posted: 5/24/2023 2:04:21 PM EDT
[#2]
const audio = new Audio('path/to/your/audio/file.mp3');
audio.play();

Link Posted: 5/24/2023 2:32:17 PM EDT
[#3]
I'm no Web or HTML expert, but I thought Java was kinda done for?
Link Posted: 5/24/2023 2:51:58 PM EDT
[#4]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
file:///

View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
file:///


thanks but just tried that it doesnt work either.  no errors, but just doesnt do anything

Quoted:
const audio = new Audio('path/to/your/audio/file.mp3');
audio.play();


thanks but just tried that it doesnt work either.  no errors, but just doesnt do anything

Quoted:
I'm no Web or HTML expert, but I thought Java was kinda done for?

different animals - js is the most popular one in the world, based on projects on github
Link Posted: 5/24/2023 2:59:09 PM EDT
[#5]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
I'm no Web or HTML expert, but I thought Java was kinda done for?
View Quote

Java != javascript.

As to javascript, not even close.  The hipsters decided to take javascript from something that ran in your web browser and turn it into its own standalone language.  
It has a standalone interpreter, package manager than shits a billion files into your filesystem (npm), gui wrappers (reactive native), app development frameworks (phonegap, cordova), etc.  You can code anything you want in asynchronous callback spaghetti code.

After the hipsters jump to a new language, they start rewriting anything and everything.  Even if there's no need.  I present to you, the operating system written in javascript.  Guaranteed to be written by somebody drinking IPAs while wearing skinny jeans and listening to a phonograph.  https://www.toptal.com/nodejs/nodeos-the-javascript-based-operating-system

As to java, a completely different language, google is keeping that alive with android.  And there are still some enterprise guys using it.
Link Posted: 5/24/2023 3:09:51 PM EDT
[#6]
Discussion ForumsJump to Quoted PostQuote History
Quoted:

thanks but just tried that it doesnt work either.  no errors, but just doesnt do anything


thanks but just tried that it doesnt work either.  no errors, but just doesnt do anything


different animals - js is the most popular one in the world, based on projects on github
View Quote
It seemed to work for me. In the very lower left portion is the button. Try it. I am using Chrome.

https://www.discountfiling.com/GD/

The full code:

Play Audio
 
   function playAudio() {
     const audio = new Audio('/GD/DP.mp3');
     audio.play();
   }
 

Attachment Attached File


Link Posted: 5/24/2023 3:10:39 PM EDT
[#7]
After you do let me know please....that song is pretty tasteless for that back up...I did not realize it lol.
Link Posted: 5/24/2023 3:42:30 PM EDT
[#8]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
After you do let me know please....that song is pretty tasteless for that back up...I did not realize it lol.
View Quote

thanks - I got your page to work, and play your file

I was able to whip up my own local/static html page using yours as a template where instead of your website audio I used const audio = new Audio('file:///c://Users//me//horn.mp3')
then when I clicked it played my file.

BUT where its not working for me is in Selenium IDE, the "run script" command,  im just building a condition that I want a sound notification.

ETA:  OK seems selenium is busted...  I cant even get a simple run script of alert("boo!") to run in selenium
wtf
Link Posted: 5/24/2023 3:43:48 PM EDT
[#9]
Oh gotcha! I am not sure on that one.
Link Posted: 5/24/2023 4:31:20 PM EDT
[#10]
is there any way I can consolidate everything encapsulated into a composition of functions?
where instead of these 2 separate lines:
const audio = new Audio('file:///c://Users//me//horn.mp3');
audio.play();

we only have a single line such as this:
play(Audio('file:///c://Users//me//horn.mp3'));

I tried that and I get error of "play is not defined".  But I have a hunch that If I can figure out the correct JS notation for this then itll work in Selenium.

I also tried (new Audio('file:///c://Users//me//horn.mp3')).play()
which doesnt give any errors but which also doesnt play anything either in selenium or in that javascript test tool I referenced in OP
Link Posted: 5/24/2023 4:53:59 PM EDT
[#11]
Try this (From ChatGPT):

If the code provided earlier for playing a local audio file is not working in Selenium but works in a regular browser, it might be due to the way Selenium interacts with the browser environment. Selenium operates in a controlled testing environment and may have some limitations when it comes to accessing local resources like audio files.

To overcome this issue, you can try using a workaround by injecting JavaScript code into the browser context using Selenium's execute_script() method. Here's an example of how you can modify the code to make it work with Selenium:


from selenium import webdriver

driver = webdriver.Chrome()  # Or choose the appropriate browser driver

driver.get("file:///path/to/your/html/file.html")  # Load the HTML file containing the audio player

# Inject JavaScript code to play the audio
driver.execute_script("""
   const audio = new Audio('path/to/your/audio/file.mp3');
   audio.play();
""")


Make sure to replace file:///path/to/your/html/file.html with the actual path to your HTML file containing the audio player code. Additionally, replace 'path/to/your/audio/file.mp3' with the actual path to your audio file.

By using execute_script(), you can directly execute JavaScript code within the browser context controlled by Selenium, allowing you to interact with the HTML and play the audio file.
Link Posted: 5/24/2023 5:27:54 PM EDT
[#12]
Link Posted: 5/24/2023 5:40:56 PM EDT
[#13]
I did just ask chatgpt how to consolidate those 2 lines into a single one, it gave me this:
(new Audio('file:///c://Users//me//horn.mp3')).play();
which is what I figured all along - and I put that in my static webpage and pressed the button and it played.  So I know that 1 liner is good

So then I put that into selenium's "run script" it didnt do anything so I tried execute_script.  Same thing.  yeah seleniums pretty effed right now I guess.
thanks everyone oh well
Link Posted: 5/24/2023 10:09:52 PM EDT
[#14]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Java is still one of the top ranked programming language. Java, Python, javascript, C++ and SQL are pretty much the current favorites. Some analysts have javascript as #1 while others have Java at the top. Pick your poison.

And... a javascript operating system?????
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:


As to java, a completely different language, google is keeping that alive with android.  And there are still some enterprise guys using it.
Java is still one of the top ranked programming language. Java, Python, javascript, C++ and SQL are pretty much the current favorites. Some analysts have javascript as #1 while others have Java at the top. Pick your poison.

And... a javascript operating system?????


https://survey.stackoverflow.co/2022/#most-loved-dreaded-and-wanted-language-love-dread

Rust actually.
Link Posted: 5/25/2023 4:55:26 PM EDT
[#15]
Link Posted: 5/25/2023 6:34:13 PM EDT
[#16]
Discussion ForumsJump to Quoted PostQuote History
Quoted:


https://survey.stackoverflow.co/2022/#most-loved-dreaded-and-wanted-language-love-dread

Rust actually.
View Quote

That's the most loved, not the most used.

EDIT: I have no idea how that guy put that together. But Rust *does* come out #1 in most loved/desired/whatever languages.
Link Posted: 5/25/2023 6:36:13 PM EDT
[#17]
Discussion ForumsJump to Quoted PostQuote History
Quoted:

Developers might love using Rust, but I don't think it'll ever crack the top 5.
View Quote

Microsoft has already rewritten most of GDI+ in Rust. And it's headed to the Linux kernel.
Link Posted: 5/25/2023 11:42:36 PM EDT
[#18]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
This shows javascript 1st, java 5th, Rust at 9th
https://bootcamp.berkeley.edu/blog/most-in-demand-programming-languages/

java 1st, javascript 4th, rust not in top 15
https://www.hackerrank.com/blog/most-popular-languages-2023/

javascript 1st, java 6th, rust 14th
https://www.netsolutions.com/insights/most-popular-programming-languages/

Developers might love using Rust, but I don't think it'll ever crack the top 5. I think the rise of script-kiddy culture has hurt the future of high level languages like Rust, C++, java, etc. They just don't want to spend the time and effort learning more complex languages.

Personally I think Rust sounds like a language I'd enjoy using.

Edit: missing a word
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:


https://survey.stackoverflow.co/2022/#most-loved-dreaded-and-wanted-language-love-dread

Rust actually.
This shows javascript 1st, java 5th, Rust at 9th
https://bootcamp.berkeley.edu/blog/most-in-demand-programming-languages/

java 1st, javascript 4th, rust not in top 15
https://www.hackerrank.com/blog/most-popular-languages-2023/

javascript 1st, java 6th, rust 14th
https://www.netsolutions.com/insights/most-popular-programming-languages/

Developers might love using Rust, but I don't think it'll ever crack the top 5. I think the rise of script-kiddy culture has hurt the future of high level languages like Rust, C++, java, etc. They just don't want to spend the time and effort learning more complex languages.

Personally I think Rust sounds like a language I'd enjoy using.

Edit: missing a word


To be fair, you said "ranked" and "favorite". I assumed preferred languages of software engineers, and the data survey I referenced show Rust as the most ranked favorite. I suppose if you asked businesses what their ranked favorite language is, it's whatever is needed to keep the lights on with their legacy apps. Java is free/cheap software written by free/cheap software engineers and most business love free/cheap.
Link Posted: 5/26/2023 9:00:04 AM EDT
[#19]
Link Posted: 5/26/2023 12:04:04 PM EDT
[#20]
Discussion ForumsJump to Quoted PostQuote History
Quoted:

I make a fair amount of money creating software with "free/cheap" java!
View Quote

Kotlin.
Link Posted: 5/26/2023 9:27:41 PM EDT
[#21]
Discussion ForumsJump to Quoted PostQuote History
Quoted:

I make a fair amount of money creating software with "free/cheap" java!
View Quote


I make a great amount of money and I don't have to deal with Java.
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top