2013-03-11 7 views
5

मुझे एक ही समस्या से संबंधित कई प्रश्न हैं, लेकिन this one's सुझावों के बाद, मैं कुछ समस्याओं में भाग लेता हूं।मैं AVQueuePlayer में ध्वनियों की कतार कैसे लूप करूं?

मेरे पास सबकुछ स्थापित है लेकिन जब भी मैं केएमटीटाइमेज़रो का उपयोग करता हूं तो मुझे माच त्रुटियों में मिलता है।

soundQueue = [AVQueuePlayer queuePlayerWithItems:soundEmotions]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(playerItemDidReachEnd:) 
               name:AVPlayerItemDidPlayToEndTimeNotification 
               object:[soundEmotions lastObject]]; 

यहां मैंने जो किया है।

- (void)playerItemDidReachEnd:(NSNotification *)notification { 
    // Do stuff here 
    NSLog(@"End has been reached."); 

    // Set it back to the beginning 
    [soundQueue seekToTime:kCMTimeZero]; 

    //Replay 
    [soundQueue play]; 

} 

ERROR: Undefined symbols for architecture armv7: "_kCMTimeZero", referenced from: -[ViewController playerItemDidReachEnd:] in ViewController.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

उत्तर

17

kCMTimeZeroCoreMedia.framework में एक प्रतीक है, इसलिए आप में "लिंक बाइनरी के साथ पुस्तकालय" अनुभाग पर इस ढांचे जोड़ने के लिए अपने लक्ष्य की "के चरण बनाएँ"।

+0

धन्यवाद! मैंने ढांचा जोड़ा और यह ठीक बनाता है, लेकिन किसी कारण से यह अभी भी ध्वनि को लूप नहीं करता है। क्या मैं इसे सही तरीके से नहीं कर रहा हूं? धन्यवाद! – KingPolygon

+0

मैंने इसे समझ लिया! फिर भी आपका धन्यवाद! – KingPolygon

+0

@ किंगपोलीगॉन, AVQueuePlayer लूप बनाने के लिए आपने क्या किया? – Raphael

0

मैं के लिए इस दृष्टिकोण का उपयोग कर रहा अंतिम आइटम और फिर seek to kCMTimeZero

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 

     if keyPath == "currentItem" { 

      print("Next Track...", currentTrackIndex) 

      if currentTrackIndex > 0 { 
       self.isPlaying = true 
      } 

      currentTrackIndex += 1 
      if currentTrackIndex > playerQueue.items().count { 
       currentTrackIndex = 0 
       playerQueue.seek(to: kCMTimeZero) 
      } 
     } 
    } 

और फिर निरीक्षण

private func observeTrackChanged(of player : AVQueuePlayer) { 

     player.addObserver(self, forKeyPath: "currentItem", options: .new, context: nil) 
    } 
संबंधित मुद्दे