Files
Woka_Native_iOS/WOKA/Theme/Controller/RadioVC.swift
BilalKhanWDI 4c69628a94 - Updated get user data response for avatar image
- updated cart icon in whole shop module , myoders
- Finalsied the payment gateway response
2024-07-31 19:42:51 +05:30

94 lines
2.8 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/secret-panel-10102023/hidden-admin-portal-20092023/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
// Radio Server Address (Direct)
// http://live3.rcast.net:9080 - This will not load as iOS directly rejects http
// SSL Stream Address (Proxy)
// https://stream.rcast.net/71643 - Playing in iOS and loading fine
// non-SSL Stream Address (Direct)
// http://live3.rcast.net:9080/;stream - This will not work as it is http
// Listening Page
// https://dir.rcast.net/radio/71643 - This is loading fine. but its showing unknown track
@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
}
}