Audio Player
The Audio Player component is build to play songs from files. The implementation of Audio Player is straightforward. You can implement it manually or using Cocoapod package manager.
Name | Version | Content |
---|---|---|
MGAudioPlayerKit | 0.1.3 | UINavigationBar - UISearchBar - UITableView - UIViewController - AudioPlayer |
Installation
To install this component you can use Cocoapods or drag and drop the folder of the component into your project manually.
Cocoapods
MGAudioPlayerKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MGAudioPlayerKit', :git => 'https://haraldbregu:4a4d1162147e80549f22cafb59060bdf59c4934a@github.com/HaraldBregu/MGAudioPlayerKit.git'
Customization
To customize content of AudioPlayer component you have to edit AudioPlayerComponent.swift
file. By updating and changing this file you will have different items in the list. Follow the steps below.
Items
Open the file and start edit the content. To change, add or remove items as example:
let audioItem = MGAudioPlayerItem()
audioItem.title = "NAME OF SONG" // Ex: Shoot To Trill
audioItem.author = "NAME OF AUTHOR" // Ex: AC/DC
audioItem.pubYear = "YEAR" // Ex: 2019
audioItem.thumbUrlString = "URL PREVIEW" // The url of image
audioItem.filename = "NAME OF FILE" // File name (shoottothrill)
audioItem.filetype = "EXTENSION" // File extension (mp3)
audios.append(audioItem)
Assets
To change the items of content, edit this code of lines:
return AudioPlayerAsset(
string: AudioPlayerString(
title: "Audio Player",
navigationBarTitle: "Audio Player",
searchBarPlaceholder: "Search",
navigationListPlayerPrompt: nil,
navigationAudioPlayerPrompt: nil),
font: AudioPlayerFont(
tableViewCellTitle: MGTemplate.font.title3,
tableViewCellSubtitle: MGTemplate.font.body,
playerTitle: MGTemplate.font.subhead,
playerSubtitle: MGTemplate.font.subhead,
playerYearPub: MGTemplate.font.subhead),
image: AudioPlayerImage(
likeNormal: UIImage(icon: .ionicons(.iosHeart), size: CGSize(width: 30, height: 30), textColor: .white),
likeSelected: UIImage(icon: .ionicons(.iosHeartOutline), size: CGSize(width: 30, height: 30), textColor: .white),
likeHighlighted: UIImage(icon: .ionicons(.iosHeartOutline), size: CGSize(width: 30, height: 30), textColor: .white),
tableViewCellIcon: UIImage(icon: .openIconic(.chevronRight), size: CGSize(width: 15, height: 15), textColor: .white),
play: UIImage(icon: .openIconic(.mediaPlay), size: CGSize(width: 60, height: 60), textColor: .white),
pause: UIImage(icon: .openIconic(.mediaPause), size: CGSize(width: 60, height: 60), textColor: .white),
thumbNormal: UIImage(icon: .openIconic(.mediaRecord), size: CGSize(width: 20, height: 20), textColor: .white),
thumbSelected: UIImage(icon: .openIconic(.mediaRecord), size: CGSize(width: 30, height: 30), textColor: .white),
stepForward: UIImage(icon: .openIconic(.mediaStepForward), size: CGSize(width: 30, height: 30), textColor: .white),
stepBackward: UIImage(icon: .openIconic(.mediaStepBackward), size: CGSize(width: 30, height: 30), textColor: .white),
shuffleActive: UIImage(icon: .openIconic(.random), size: CGSize(width: 30, height: 30), textColor: .white),
shuffleUnactive: UIImage(icon: .openIconic(.random), size: CGSize(width: 30, height: 30), textColor: #colorLiteral(red: 0.9529411765, green: 0.968627451, blue: 0.9725490196, alpha: 0.4026256443)),
repeatActive: UIImage(icon: .openIconic(.reload), size: CGSize(width: 30, height: 30), textColor: .white),
repeatUnactive: UIImage(icon: .openIconic(.reload), size: CGSize(width: 30, height: 30), textColor: #colorLiteral(red: 0.9529411765, green: 0.968627451, blue: 0.9725490196, alpha: 0.4026256443)),
heartActive: UIImage(icon: .openIconic(.heart), size: CGSize(width: 30, height: 30), textColor: .white),
heartUnactive: UIImage(icon: .openIconic(.heart), size: CGSize(width: 30, height: 30), textColor: #colorLiteral(red: 0.9529411765, green: 0.968627451, blue: 0.9725490196, alpha: 0.4026256443)),
option: UIImage(icon: .openIconic(.ellipses), size: CGSize(width: 30, height: 30), textColor: .white),
share: UIImage(icon: .openIconic(.share), size: CGSize(width: 30, height: 30), textColor: .white)),
color: AudioPlayerColor(
navigationBar: MGTemplate.color.navigationBar,
navigationBarContent: MGTemplate.color.text.primary,
toolBar: MGTemplate.color.toolBar,
toolBarContent: MGTemplate.color.text.primary,
view: MGTemplate.color.view,
viewContent: MGTemplate.color.text.primary,
tableView: MGTemplate.color.tableView,
tableViewSeparator: MGTemplate.color.tableViewSeparator,
refresh: MGTemplate.color.text.primary,
searchBarContent: MGTemplate.color.text.primary,
tableViewCell: MGTemplate.color.tableViewCell,
tableViewCellContent: MGTemplate.color.text.primary,
collectionView: MGTemplate.color.collectionView,
collectionViewContent: MGTemplate.color.text.primary,
sliderMinimumTrackColor: .red,
playerTitle: .red,
playerSubtitle: .red,
playerYearPub: .red,
timeProgress: .red),
data: AudioPlayerData(
items: audios,
darkKeyboard: true,
bundle: .main,
enableAds: false,
adsUnitId: "ADMOB_ID"))