Not able to play the .wav sound which i recorded through coding in blackberry - blackberry

i have tried to record the audio in wav format and i succeeded but when i try to play that file, it gives an error that 'media file is of unsupported format'.
the main portion of code is as follows:
player = Manager.createPlayer("capture://audio?encoding=pcm&rate=44100&bits=16&channels=1");
player.realize();
controller = (RecordControl) player.getControl("RecordControl");
controller.setRecordLocation("file:///SDCard/BlackBerry/voicenotes/voice.wav");
//controller.setRecordSizeLimit(396900);
controller.startRecord();
player.start();
Thread.sleep(7000);
controller.commit();
player.close();
This code works well and it gave me a voice.wav file but i am not able to play this file.Is there is something which i forget?
Thanks in advance.

Sounds like the same problem as here:
http://supportforums.blackberry.com/t5/Java-Development/Bug-in-media-Manager-Player/td-p/1009027/page/2
Essentially, you need to add the RIFF/WAVE-header for the recorded data yourself, see the last post on the thread for example.

Related

Failed to Create Sound

Very simple issue but I have no idea if anyone can help me with it. Perhaps it is a bug? I simply want to load this order but get the warning that WARNING: C:\Users\Usuario\Documents\Corona Projects\BalloonTap\game.lua:259: audio.loadSound() failed to create sound 'audio/pop.wav´.
The directory of the audio of the audio file is C:\Users\Usuario\Documents\Corona Projects\BalloonTap\audio
The code is:
balloonPop = audio.loadSound( "audio/pop.wav")
Any possible fixes? I have tried different audio files and renaming file. I have tried putting it in the main folder and just saying balloonPop = audio.loadSound( "pop.wav") but that fails as well.
When sounds are not loading in Corona, it is a good idea to check that the file can be found:
local filename = "audio/pop.wav"
if system.pathForFile( filename , system.ResourceDirectory ) == nil then
print("WARNING: cannot find audio file "..filename )
end
The fact that the sound could not be created suggests, however, that this is not the problem. From the Audio Usage/Functions Guide:
Cross-platform .wav files must be 16-bit uncompressed.
Is your sound file in the correct format?

Sound Effect Won't Play (XCode/Swift)

So I am following through an old tutorial and I think with the changes in xcode and swift this code is now no longer usable, but i am not sure. Would love some help.
Declaring constant for the audio effect
let cannonSound = SKAction.playSoundFileNamed("cannon.wav", waitForCompletion: false)
Calling the audio effect within my funtion
let hotdogSequence = SKAction.sequence([cannonSound, moveHotdog, deleteHotdog])
hotdog.run(hotdogSequence)
For more info I am using SpriteKit in Xcode and this code is contained within GameScene.swift file.
Update:
The error I receive is
2017-03-30 00:52:43.631 Ballpark Weiner[95999:1983181] SKAction: Error loading sound resource: "cannon.wav"
The game doesn't crash just no sound plays
This message usually means that the file cannot be found in your project or might be corrupt.
You should check that the file is actually copied into your project and is spelled correctly. Its case sensitive so if the actual file is called "Cannon.wav" it will not work.
Hope this helps

send audio with MFMessageComposeViewController

does anyone know i this is possible by doing something like
[compose addAttachmentData:data typeIdentifier:(NSString *)kUTTypeAudio filename:#"test"];
The resulting message isn't of any playable format so not sure if its possible at all? The data file does play in an audio player so I know thats correct.
Thanks
Jules
You need to set the filename to include a proper file extension, e.g. #"test.caf", instead of just #"test". See this answer for a similar question:
MFMessageComposeViewController iOS7 addAttachmentData:typeIdentifier:filename: not working

Blackberry java radio streaming

I'm developing a radio app for BB 5.0 in java. I don't find a way to play the radio from the url stream address that I have. I use multiple formats but nothing works (.pls, .aac, .m3u). I get a RuntimeException every time I try to play the stream. The content is ok, I've checked it.
InputStream stream = Connector.openInputStream(urlPlay);
StreamConnection streamConnection = (StreamConnection) Connector.open(urlPlay, Connector.READ);
InputStream readAhead = streamConnection.openDataInputStream();
byte[] audioData = new byte[500];
readAhead.read(audioData,0,audioData.length);
ByteArrayInputStream in2 = new ByteArrayInputStream(audioData);
player = javax.microedition.media.Manager.createPlayer(in2, "audio/aac");
System.out.println("REALIZE");
player.realize();
System.out.println("PREFETCH");
player.prefetch();
System.out.println("START");
player.start();
Edit:
When I use a URL from my .pls file I hear a little bit of my streaming but It stops immediately.
I suspect the problem is that you are trying to play playlist files instead of an actual stream. Generally, you need to parse those files yourself to get the real stream URLs.
If you open up that .m3u file, you will see that it is just a list of URLs. Take one of those URLs and then try it. Also, be sure you are setting the right content type. You can determine what that type is with cURL or VLC.

How to extract the song name from a live audio stream on the Blackberry Storm?

HI
I am new to Blackberry.
I am developing an application to get the song name from the live audio stream. I am able to get the mp3 stream bytes from the particular radioserver.To get the song name I add the flag "Icy-metadata:1".So I am getting the header from the stream.To get the mp3 block size I use "Icy-metaInt".How to recognize the metadatablocks with this mp3 block size.I am using the following code.can anyone help me to get it...Here the b[off+k] is the bytes that are from the server...I am converting whole stream in to charArray which is wrong, but how to recognize the metadataHeaders according to the mp3 block size..
b[off+k] = buffers[PlayBuf]PlayByte];
String metaSt = httpConn.getHeaderField("icy-metaint");
metaInt=Integer.parseInt(metaSt);
for (int i=0;i<b[off+k];i++)
{
metadataHeader+=(new String(b)).toCharArray();
System.out.println(metadataHeader);
metadataLength--;
Blackberry has no native regex functionality; I would recommend grabbing the regexp-me library (http://code.google.com/p/regexp-me/) and compiling it into your code. I've used it before and its regex support is pretty good. I think the regex in the code you posted would work just fine.

Resources