How to handle error code -43 from NSOSStatusErrorDomain when initializing AVAudioPlayer Object? - avaudioplayer

I observed strange behavior while working with AVAudioPlayer
Following is the code:
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:[NSString stringWithFormat:#"%#",fileName]] error: &error];
In this, I downloaded the file from server and stored in application's Cache directory.
I am getting following error:
Error in playing =
Domain = NSOSStatusErrorDomain
Code = -43
Description = Error Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn’t be completed. (OSStatus error -43.)"
I also verified that file is present at that location.
Everytime I restart my application, I was getting same error for song play.
After some time, when I tried to run same code, my player just works fine without any error.
Can anyone tell me how to handle this error?
Also, Can anyone explain me what was the problem?

AVAudioPlayer does not support streaming via HTTP. Try using AVPlayer instead.

I had the same error with this code, even though I could verify that the songCacheURL was valid and that the file was available:
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:songCacheURL error:&error];
I was able to fix the issue by loading the file first into an NSData element and then using that to initialize the AVAudioPlayer instead, like so:
NSData *songFile = [[NSData alloc] initWithContentsOfURL:songCacheURL options:NSDataReadingMappedIfSafe error:&error1 ];
self.audioPlayer = [[AVAudioPlayer alloc] initWithData:songFile error:&error2];
I hope that helps someone else.
Robin

I had a similar issue. As it turns out, I was initializing the url with just the filename and omitting the bundle resources path. Your url init should look something like:
NSURL *url= [NSBundle URLForResource: #"my_sound" withExtension:#"mp3"];

I had the same error and it appeared to be that the URL was nil.
Try to check if your URL object is != nil.
Maybe your path is wrong.

I had a similar issue with AVAudioPlayer while using local-file based URL. As has been established, the trouble was with an incorrect file name, I just didn't notice a leading whitespace in its name. So first of all just check your URLs attentively.

I had a similar issue, the problem wound up being that my mp4 file target membership check box was unchecked, once I checked it, the file played perfectly.

I had a same problem and I solved it now. The problem was in name of mp3 file. In code was file name "Yes.MP3" but name of file is "Yes.mp3". When I running application in simulator everything is ok, because (I don't know why) simulator isn't case sensitive. When you are running the same code on device this error will occurred in this case.

Related

Ruby/Selenium/Watir-Webdriver: "path is not absolute" error for absolute path

document_name ='TestDoc'
document_path = ("/Users/Me/QA/Project/Documents/#{document_name}")
File.new ("/Users/Me/QA/Project/Documents/#{document_name}") # => File is created
filename_field.send_keys("#{document_path}")
filename_field.send_keys :tab # => To Trigger event but where error occurs
filename_field = browser.file_field(:name, 'file') declared in a module elsewhere.
As far as I can tell, I have provided an absolute path for the filename to upload the file but when the tab key is sent, an error occurs of:
Selenium::WebDriver::Error::UnknownError: unknown error: path is not absolute:
With an odd squiggly symbol in RubyMine that I've never seen before. Any ideas?
Update:
I added
puts filename_field.value
# => C:\fakepath\TestDoc
Spoke to one of the developers and she said "Browser does it to fake things out, so the filesystem isn't exposed". Not sure if that helps solve my issue or I'm SOL?
That error comes from Chromedriver, and comes from sending an incorrect path string to a file element. Since :tab is not a path, it is correctly raising an error.
You shouldn't need to send a tab; just sending the path of the file should accomplish what you need.
I see many small strange things in your code.
Why
document_path = ("/Users/Me/QA/Project/Documents/#{document_name}")
Not
document_path = "/Users/Me/QA/Project/Documents/#{document_name}"
Why
filename_field.send_keys("#{document_path}")
Not
filename_field.send_keys(document_path)
But the main question is why you are using send_keys instead of set?
I failed to reproduce your problem. Maybe it will be possible if you will provide your html. But i suggest you to try:
filename_field.set(document_path)
Because you can easily check it even with irb send_keys is acting differently in firefox and in chrome for example. So maybe problem with it.
Another suggestion
That is a much more weak idea. But...
Try to clear value before changing it. You can do it with javascript:
b.execute_script("arguments[0].value=''", field)
I had the same issue with Chromedriver 2.26.436421 and it was solved when I removed the code which was sending the tab key.
With previous Chromedriver sending tab key was required to trigger the change event on the file input but with latest one it seems like it is only causing issues and the change event gets triggered without it.

Playframework 2 SQLite

I am trying to get SQLite working with the playframework but so far no luck.
I have Downloaded sqlitejdbc-v056.jar and put it into the lib folder.
I then changed the application.conf:
db.driver=org.sqlite.JDBC
db.url="jdbc:sqlite:/db/geolookup.sqlite"
db.default.user=sa
db.default.password=sa
I created a folder db and drop my sqlite db into it.
Now I start play with play run
Everything seems to compile ok, but when I call the url: http://127.0.0.1:9000
I get the following error:
driver.url has type STRING rather than OBJECT
with the following line highlited:
db.driver=org.sqlite.JDBC
What am I missing?
try this:
db.default.driver="org.sqlite.JDBC"
db.default.url="jdbc:sqlite:/home/tex/dbtest"
db.default.user="sa"
db.default.password=""
Notice that the folder of the db must be an absolute path !
(BTW: with this configuration the application starts but when I try to run the evolution it throws an exception, I think this is a "dialect" problem...)
Hope this helps...
You are propably using the wrong method to get the data from the config. From your error I assume you use it like this:
configuration.getConfig("db.driver")
But this method expects an JSON object under the path "db.driver". Since under the "db.driver" path you have a string, you should read the data using this method:
configuration.getString("db.driver")
This will make the "rather than OBJECT" error go away.

SecurityError: Error #2000: No active security context

I recently had this vague error happen to me with the use of LocalConnection.
It happened every time I tried to connect and send data to another swf.
Doing an internet search came up with little results pertaining to LocalConnection and this error and the response some people had were just ridiculous.
Apparently this error pertains to image loading and fileReference also, just not in this case.
My sending code works fine, even the event.level returned as status which means the other swf got the message, however a trace in the other swf callback function did not show, telling me the callback never triggered.
Image loading error
I got nailed on this one again with loading images.
The answer has been updated to include the fix for this also.
As it turns out the fix is simple.
The connection name was too long.
I cut the name down to 30 characters and it started working immediately.
I also want to add that if there is an error in the callback function you will get this error.
IMAGE LOADING ERROR
Well this error popped up on me again, but this time when I was loading images.
// bad code
imageObj.source = partialURL1 + partialURL2 + partialURL3;
//good code
var someURL:String = partialURL1 + partialURL2 + partialURL3
imageObj.source = someURL;
It seems you can not append the URL on the same line you assign it. Looks like a debugger bug. Even with the bad code HTTPFox was showing the images where loading, but the program would crap out somewhere after the source assignment, probably on the onloaded callback. I stopped looking into the matter when I found the source assignment fixed it.
I've had this error too, and for me the errorous code was
someobject.misspelledVariable.toString();
Where someobject was sent through a earlier localConnection and misspelledVariable is of course undefined.
Changing misspelledVariable to a correct one solved my problem. Strange error though...

Add Source file link to the default ASP.NET Server Error page?

Has anyone ever thought to attempt to modify the default ASP.NET Server error page to provide a link BACK to the error source in Visual Studio?
Consider the following standard error page in ASP.NET:
Server Error in '/myproject'
Application.
Invalid object name 'usp_DoSomething'.
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.Data.SqlClient.SqlException:
Invalid object name 'usp_DoSomething'.
Source Error:
Line 4323: cmd.CommandText = "usp_DoSomething";
Line 4324:
Line 4325: using (var dr = cmd.ExecuteReader())
Line 4326: {
Line 4327: if (dr != null)
Source File:
c:\development\myproject\myproject.components\providers\sql\sqldataprovider.cs
Line: 4325
When an error like this is generated, the HTML has the source back to the file the error occurs in and the line number. Has anyone ever written or thought of writing some mechanism to turn the text into a link back to the error in Visual Studio?
I've never seen anything that does it, but it just seems like it would be a helluva nice feature and I think about it in the back of my mind every time an error occurs when I have to manually go find it in the source. It would just be nice to be able to click a link to take me straight there.
Anyone written any, or know of any solutions for this. I use Chrome or Firefox as my browsers of choice, but I'd even consider using IE again if someone found a plugin that did this.
Thanks,
Max
Well, I had been hoping for some means of hacking the error page to turn this:
c:\development\myproject\myproject.components\providers\sql\sqldataprovider.cs Line: 4325
into a link back into my source code in Visual Studio... being that the file name and line number is provided. I was thinking of a browser plugin or something, but apparently no one has built anything like that before... oh well. Was worth a shot.

Error: is not a valid virtual path

I used something like
Dim i As String
i = Server.MapPath("~/photos/") + fileName
Only once in a project that was working and online, on the offline version, when I run it on my machine, its working, no errors, I uploaded it, it gave me an error like:
'~/photos/http://www.MyURL.com/photos/4411568359267Pic003.jpg' is not a valid virtual path.
Indicating a line in my code:
var marker = new GMarker(new GLatLng(<%=coordinates%>));
This have never happened before, and I don't know where to start troubleshooting as this script -Google Maps- doesn't even need images, i tried to comment it out, it gave me the same error but on a different script this time, the one that show formatting toolbar for the text areas
Line 8: new nicEditor({buttonList : ['fontSize','fontFamily','fontFormat','bold','italic','underline','strikethrough','forecolor','bgcolor','removeformat'], iconsPath : '../nicEdit/nicEditorIcons.gif'}).panelInstance('<%= txtDescription.ClientID %>');
..please HELP :'(
can you post your fileupload aspx page and your function so we can troubleshoot it.
"'~/photos/http://www.MyURL.com/photos/4411568359267Pic003.jpg'"
look closely at the url, it is tacking the full url on to "i". what type of control or you using, a generic or a server side control
solved, turns out the error is due to old database records when i was storing the whole path in the fileName...Thanks Joshua and Keltex

Resources