CS 4720
iOS Multimedia
CS 4720 – Mobile Application Development
iOS Multimedia CS 4720 Mobile Application Development CS 4720 iOS - - PowerPoint PPT Presentation
iOS Multimedia CS 4720 Mobile Application Development CS 4720 iOS Architecture CS 4720 2 Two Levels of Access Some features live at a higher level in the main media player framework - MediaCoreServices Fine-grained control is
CS 4720 – Mobile Application Development
2
3
4
5
6
7 import MobileCoreServices
controller = UIImagePickerController() if let theController = controller{ theController.sourceType = .Camera theController.mediaTypes = [kUTTypeImage as String] theController.allowsEditing = true theController.delegate = self presentViewController(theController, animated: true, completion: nil) }
8
9
10
11
12
var audioPlayer = AVAudioPlayer() let sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("tac-episode_114", ofType: "mp3")!) do{ print("Loading sound") let audioPlayer = try AVAudioPlayer(contentsOfURL:sound) print("Preparing to play") audioPlayer.delegate = self audioPlayer.prepareToPlay() print("Play") audioPlayer.play() }catch { print("Error getting the audio file") }
13 mediaPicker = MPMediaPickerController(mediaTypes: .AnyAudio) if let picker = mediaPicker{ print("Successfully instantiated a media picker") picker.delegate = self picker.allowsPickingMultipleItems = true picker.showsCloudItems = true picker.prompt = "Pick a song please..." view.addSubview(picker.view) presentViewController(picker, animated: true, completion: nil) } else { print("Could not instantiate a media picker") }
14
let audioRecordingURL = self.audioRecordingPath() do { audioRecorder = try AVAudioRecorder(URL: audioRecordingURL, settings: audioRecordingSettings()) guard let recorder = audioRecorder else{ return } recorder.delegate = self /* Prepare the recorder and then start the recording */ if recorder.prepareToRecord() && recorder.record()
15
16
17
18
{ /* Called when a touch begins */ for touch in touches { let location = touch.locationInNode(self) let sprite = SKSpriteNode(imageNamed:"Spaceship") sprite.xScale = 0.5 sprite.yScale = 0.5 sprite.position = location let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1) sprite.runAction(SKAction.repeatActionForever(action)) self.addChild(sprite) } }
19
20