संपादित करें: इसे समझ लिया गया है! मैं यूआरएल के पूर्ण स्ट्रिंग को सहेज रहा था, और जब मैंने ऑडियो प्लेयर को शुरू करने की कोशिश की तो मैंने [NSURL fileURLWithPath: name] का उपयोग किया; जब यह होना चाहिए [NSURL urlWithString: name]। एक और fileURLWithPath बनाकर यह पथ बदल रहा था और काम नहीं करेगा। मुझे लगता है कि मैं कुछ नमूना कोड के लिए इसे छोड़ दूंगा!कोर डेटा में रिकॉर्डिंग के यूआरएल को सहेजना, लेकिन जब मैं इसे बाद में उपयोग करने का प्रयास करता हूं तो काम नहीं करता
ठीक है, तो मेरे पास मेरे ऐप में उपयोगकर्ता से एक रिकॉर्ड किया गया ऑडियो टुकड़ा है। मैं चाहता हूं कि उपयोगकर्ता इन रिकॉर्डिंग को सहेजने में सक्षम हो, इसलिए मैंने सोचा कि मुझे रिकॉर्डिंग के यूआरएल की स्ट्रिंग को मूल डेटा में सहेजना चाहिए, यूआरएल लाएं, और उस यूआरएल के साथ एवीऑडियो प्लेयर लोड करें। लेकिन यह काम नहीं करता है।
यह मुझे देता है:
Error in audioPlayer: The operation could not be completed.
यह वह जगह है यूआरएल के NSString:
file://localhost/file:/localhost/var/mobile/Applications/E09081DE-434F-46CA-A598-
A2470973C0F1/Documents/Rang%2520De%2520sound.caf
मैं एक महसूस कर रही है यह तथ्य यह है कि यह स्थानीय होस्ट में बचाता है के साथ क्या करने के लिए कुछ है, और मैं ऑडियो प्लेयर को प्रारंभ करने का प्रयास करते समय वास्तव में उस फ़ाइल तक नहीं पहुंच सकता है। लेकिन मुझे यकीन नहीं। मुझे पता है कि यूआरएल को तुरंत एक्सेस किया जा सकता है, क्योंकि रिकॉर्ड करने के बाद मैं उस यूआरएल का उपयोग करके रिकॉर्डिंग को वापस चलाने में सक्षम हूं।
मैं रिकॉर्डिंग कैसे बचत कर रहा हूँ:
- (IBAction)saveRecording
{
rapAppDelegate *appDelegate =
[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context =
[appDelegate managedObjectContext];
NSManagedObject *newSong;
newSong = [NSEntityDescription
insertNewObjectForEntityForName:@"URLRecordings"
inManagedObjectContext:context];
NSError *error;
NSURL *urlOfRecording = audioRecorder.url;
NSString *urla = [urlOfRecording absoluteString];
NSLog(@"in saveRecording, the url is: %@",urla);
[newSong setValue:urla forKey:@"urlOfSong"];
[context save:&error];
status.text = @"Song Saved!";
}
जब मैंने इसे लाने, URL परिवर्तन! मुझे नहीं मिलता क्यों! देखो:
2012-08-03 16:31:17.434 Rap To Beats[5054:707] in saveRecording, the url is: file://localhost/var/mobile/Applications/E09081DE-434F-46CA-A598-A2470973C0F1/Documents/Le%20Gayi%20sound.caf
2012-08-03 16:31:24.381 Rap To Beats[5054:707] after fetch, the url is: file://localhost/file:/localhost/var/mobile/Applications/E09081DE-434F-46CA-A598-A2470973C0F1/Documents/Le%2520Gayi%2520sound.caf
यह ली% 20 से ली% 2520 तक चला गया! मैंने फिर से रिकॉर्ड नहीं किया था या कुछ भी मैंने कोर डेटा में एक ही स्ट्रिंग को सहेजा और इसे लाया! शुरुआत में लोकहोस्ट में कुछ बदलाव भी हैं।
फिर यह कैसे मैं इसे प्राप्त करने में कठिनाई कर रहा हूँ है:
rapAppDelegate *appDelegate =
[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context =
[appDelegate managedObjectContext];
NSEntityDescription *entityDesc =
[NSEntityDescription entityForName:@"URLRecordings"
inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"urlOfSong" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[context
executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil) {
// Handle the error.
}
[self setUrlArray:mutableFetchResults];
यह कैसे लोगों को ठीक करने के लिए पर कोई मदद? अगर इसे लोकहोस्ट के साथ करना है, तो मैं इसे कहीं और कैसे सहेजूं?
यहाँ जहां यह सहेजा जाता है पर कोड है: इस सवाल की लंबाई के लिए
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *name = self.beatName.text;
NSString *soundFilePath1 = [docsDir
stringByAppendingPathComponent:name];
NSString *soundFilePath = [soundFilePath1
stringByAppendingString:@" sound.caf"];
NSLog(@"in viewDidLoad, the url is: %@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44010.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
क्षमा करें, सिर्फ संभव के रूप में उपयोगी हो सकता है और डाल जो कुछ कोड समस्या को हल मदद कर सकता है चाहता हूँ। मुझे बताएं कि यह कुछ और है जो मैं गलत तरीके से कर रहा हूं! धन्यवाद दोस्तों!
प्रोटोकॉल के मामले में, आपको अपना उत्तर कॉपी करना चाहिए, इसे एक उत्तर के रूप में सबमिट करना चाहिए, फिर इसे स्वीकार करें (इसे चुनें) ताकि इस प्रश्न को बंद कर सकें। –
ठीक है, मैं वह करूँगा! – gg13