Files
Woka_Native_iOS/WOKA/Theme/Controller/RadioVC.swift
BilalKhanWDI bb68fa1e3c - Completed Apply Coupon Functionality
- Made a selection for the coupon selected, also added no coupon found when coupon is not there
- Added Masila view in more section
- Added Play trailer from Manila in more section
- Gave other connectivity
2024-07-24 19:59:08 +05:30

85 lines
2.3 KiB
Swift

//
// RadioVC.swift
// WOKA
//
// Created by MacBook Pro on 13/06/24.
//
import UIKit
import WebKit
class RadioVC: UIViewController, WKNavigationDelegate {
@IBOutlet var webView: WKWebView!
var url = "https://wokaland.com/admin/api/woka_fm"
// var url = "https://s4.voscast.com:9161/stream" provide on 18th july
// var url = "https://planetcast.radiowalla.in/radio.mp3" //url from 24th july
@IBOutlet weak var backView: UIView!
deinit {
unloadWebView()
}
// WKNavigationDelegate methods
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
print("Failed to load: \(error.localizedDescription)")
}
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
print("Failed to start loading: \(error.localizedDescription)")
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
print("Finished loading")
}
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 14.0, *) {
webView.configuration.defaultWebpagePreferences.allowsContentJavaScript = true
} else {
// Fallback on earlier versions
webView.configuration.preferences.javaScriptEnabled = true
}
let radioURL = URL(string: url)!
let request = URLRequest(url: radioURL)
webView.load(request)
webView.navigationDelegate = self
backView.addTapGesture {
self.dismiss(animated: true) {
self.unloadWebView()
}
}
}
override func viewDidDisappear(_ animated: Bool) {
webView.stopLoading()
}
@IBAction func closeBtnTapped(_ sender: UIButton) {
self.dismiss(animated: true) {
self.unloadWebView()
}
}
func unloadWebView() {
// Cancel any ongoing navigation
webView.stopLoading()
// Set delegates to nil
webView.navigationDelegate = nil
webView.uiDelegate = nil
// Remove from superview
webView.removeFromSuperview()
// Release the web view
webView = nil
}
}