The iOS SDK's AV Foundation framework makes it simple for developers to play and record music and video. Developers can also use the Media Player framework to play music and video files. Before running the code, you must first add the AVFoundation.framework framework framework and MediaPlayer framework frameworks to your Xcode project.
This can be accomplished by following the steps below:
Step 1: In the Xcode project, look for your target
Step 2: Right-click on the target and select Add→Existing Frameworks
Step 3: Hold down the Command key and choose AVFoundation.framework and MediaPlayer.framework from the drop-down menu
Step 4: Choose Add
Step 5: Hold down the Command key and choose AVFoundation.framework and MediaPlayer.framework from the drop-down menu
Step 6: Make the following changes to ViewController.h:
Step 7: Make the following changes to ViewController.m: