LOCAL mp3 ファイルのパスを JavaScript に送信し、そこからソースが入力されたオーディオ タグを作成しようとしています。しかし、これを試してみると、「オーディオ ファイルを再生できません」というメッセージが表示されます。ファイル自体はアプリ固有のサンドボックスから来ているため、パスは次のようになります
/Users/username/Library/Application Support/iPhone Simulator/6.0/Applications/818263D7-4246-4DEC-9186-6AC14F0175A3/Documents/audiofile.mp3
問題は、アプリケーション自体のサンドボックスまたはローカル ファイル システムに保存されているものではなく、同じ方法を使用してデスクトップから mp3 を再生できることです。これは、パスを取得し、webview を介して javascript に送信するために使用しているコードです。どんな助けでも大歓迎です。
UIWebView *webContainer = [[UIWebView alloc] initWithFrame: self.view.bounds];
webContainer.backgroundColor = [UIColor grayColor];
webContainer.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight );
[webContainer setBackgroundColor:[UIColor clearColor]];
webContainer.delegate = self;
[self.view addSubview:webContainer];
NSString *imagePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *imPath = [NSString stringWithFormat:@"%@/angels.mp3",imagePath];
imPath = [imPath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
[webContainer stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setupAudio('%@');", imPath]];