Exemple #1
0
  /*
   * This method is called to initialize the AVAudioPlayer object
   */
  private void initAudioPlayer(String audioFile) {

    /*
     * A NSBundle object represents location in file system. Using pathForResource(),
     * a file with specified extension and name can be looked for in a given bundle directory.
     * Here, mainBundle() returns NSBundle object corresponding to the directory where
     * application executable is residing.
     */
    NSURL url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource(audioFile, "mp3"));
    NSErrorHolder errorHolder = new NSErrorHolder();

    /*
     * Initialize an audio player to play the audio file
     */
    audioPlayer = AVAudioPlayer.audioPlayerWithContentsOfURL(url, errorHolder);
    if (audioPlayer == null) {
      System.out.println("Error initializing player: " + errorHolder.description());
    }

    /*
     * Set indefinite number of loops
     */
    audioPlayer.setNumberOfLoops(-1);
    audioPlayer.setDelegate(this);
  }
 public AndroidManifest() {
   String filePath = NSBundle.mainBundle().pathForResource("AndroidManifest", "xml");
   NSData manifestFile = NSData.dataWithContentsOfFile(filePath);
   NSXMLParser xmlParser = new NSXMLParser(manifestFile);
   xmlParser.setShouldProcessNamespaces(true);
   xmlParser.setShouldReportNamespacePrefixes(true);
   xmlParser.setDelegate(new AndroidManifestParser(this));
   boolean success = xmlParser.parse();
   // TODO what to do if success == false?
 }