Skip to content

Instantly share code, notes, and snippets.

@ayoub-9
Created December 8, 2018 14:03
Show Gist options
  • Select an option

  • Save ayoub-9/f7f7d4a1bb8f078962d256a13f3bad85 to your computer and use it in GitHub Desktop.

Select an option

Save ayoub-9/f7f7d4a1bb8f078962d256a13f3bad85 to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// NLM
//
// Created by Ayoub Alrshidi on 28/03/1440 AH.
// Copyright © 1440 Ayoub Alrshidi. All rights reserved.
//
import UIKit
import WebKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var webkit: WKWebView!
var player:AVAudioPlayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
do
{
let audioPath = Bundle.main.path(forResource: "withOut", ofType: "mp3")
try player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)
}
catch
{
//PROCESS ERROR
}
let session = AVAudioSession.sharedInstance()
do
{
try session.setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
}
catch
{
}
player.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment