// // SoundViewController.swift // SearchDemo // // Created by Ralf Gronkowski on 13/10/14. // Copyright (c) 2014 Ralf Gronkowski. All rights reserved. // import AVFoundation import UIKit import MessageUI class SoundViewController: AbstractContentViewController, AVAudioPlayerDelegate{ var playerView: UIView? var avPlayer: AVAudioPlayer! var error: NSError? override func viewDidLoad() { super.viewDidLoad() playerView = UIView(frame: view.bounds) if let thePlayerView = playerView{ view.addSubview(thePlayerView) self.avPlayer = AVAudioPlayer(data: thisP4FileRev.getDataFromSwarm(), error: &error) avPlayer.delegate = self avPlayer.prepareToPlay() avPlayer.volume = 1.0 avPlayer.play() } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 10709 | gronk |
First working example of an iOS app that searches in P4Search and displys content by retrieving it from Swarm. There is a file JSON.swift in the project in which you need to paste some external code from here https://github.com/lingoer/SwiftyJSON/blob/master/SwiftyJSON/SwiftyJSON.swift to simplify JSON parsing. You will also need access to a running P4Search and Swarm instance if you want to run the app on a device or inside an emulator. Coded in Swift with XCode 6.0.1 |