Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Saving a sound as byte array

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there everyone,

Hopefully writing this post won't be a waste of my time or your time in reading it.
I am able to play sounds from a file using...(try catch blocks omitted for clarity)


Now, I can turn the file into bytes using..

And printing out data shows it has been read into.

So what I would like to do is play a sound given a byte[]
I attempted this..., but did not work.

But this does not work, can anyone help me to fix this?

Thanks very much.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But this does not work:Are you not able to hear sound or getting an exception ?

Streams are also pipes of bytes.Though I have not worked with sound in Java.But I think that if you read the bytes from inputstream to byte array and again convert the byte array into a stream.It should be fine , nothing wrong.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, good point, I put a print out in the catch block, and so

Is throwing an error with message
"could not create audio stream from input stream"

Any idea how I can fix this?
Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic