Files
Woka_Native_iOS/WOKA/Helpers/Timer/TimeStringToSeconds.swift
BilalKhanWDI 5164f2fe10 - Handled inline play play pause.
- Created a enum to handle the play pause resume functionality
- Added tap handler with animation for cells.
- Made logic if one audio is playing and then other audio plays , it ill deinit the first audio and play second.
- Added deinit to the view controller, if the view dismiss the play will stop and denitialize
2024-06-11 19:49:10 +05:30

49 lines
1.3 KiB
Swift

//
// TimeStringToSeconds.swift
// WOKA
//
// Created by MacBook Pro on 11/06/24.
//
import UIKit
extension String {
func timeStringToSeconds() -> Int? {
let components = self.split(separator: ":")
switch components.count {
case 2:
// MM:SS format
let minutes = Int(components[0]) ?? 0
let seconds = Int(components[1]) ?? 0
return (minutes * 60) + seconds
case 3:
// HH:MM:SS format
let hours = Int(components[0]) ?? 0
let minutes = Int(components[1]) ?? 0
let seconds = Int(components[2]) ?? 0
return (hours * 3600) + (minutes * 60) + seconds
default:
// Invalid format
return nil
}
}
func checkHourZero() -> String{
// Function to format the time
// Split the time string by ":"
let components = self.split(separator: ":")
// Check if the time string starts with "00"
if components.count == 3 && components[0] == "00" {
// Remove the initial "00:"
return "\(components[1]):\(components[2])"
} else {
// Return the original time string
return self
}
}
}