KTV lyrics analysis, intonation scoring components
introduce
Support XML lyrics analysis, LRC lyrics analysis, solve the problem of multi-line lyrics progress rendering, scoring according to the real-time calculation of voice scoring
Welcome to submit PR and issue any questions. I will fix them from time to time
Github
Method of use
Initialize the
private lazy var lrcScoreView: AgoraLrcScoreView = {
let lrcScoreView = AgoraLrcScoreView(delegate: self)
lrcScoreView.config.scoreConfig.scoreViewHeight = 100
lrcScoreView.config.scoreConfig.emitterColors = [.systemPink]
lrcScoreView.config.lrcConfig.lrcFontSize = .systemFont(ofSize: 15)
return lrcScoreView
}()
Copy the code
Configuration properties
Component Base Configuration
/// Configure the scoring component
public var scoreConfig: AgoraScoreItemConfigModel = .init(a)/// Lyrics component configuration
public var lrcConfig: AgoraLrcConfigModel = .init(a)/// Whether to hide the scoring component
public var isHiddenScoreView: Bool = false
/ / / background
public var backgroundImageView: UIImageView?
/// The spacing between the scoring component and the lyrics component defaults to 0
public var spacing: CGFloat = 0
Copy the code
The lyrics configuration
/// No lyrics
public var tipsString: String = "Pure music, no words."
/// prompt text color
public var tipsColor: UIColor = .black
/// prompt text size
public var tipsFont: UIFont = .systemFont(ofSize: 17)
/// The color of the dividing line
public var separatorLineColor: UIColor = .lightGray
// whether to hide the split line
public var isHiddenSeparator: Bool = false
/// Default lyrics background color
public var lrcNormalColor: UIColor = .gray
/// highlight background color of lyrics
public var lrcHighlightColor: UIColor = .white
/// Real-time rendering of lyrics color
public var lrcDrawingColor: UIColor = .orange
/// Lyrics text size default: 15
public var lrcFontSize: UIFont = .systemFont(ofSize: 15)
/// Lyrics highlight text zoom size default: 1.1
public var lrcHighlightScaleSize: Double = 1.1
/// Space the lyrics left and right
public var lrcLeftAndRightMargin: CGFloat = 15
/// Wait to start dot background color default: gray
public var waitingViewBgColor: UIColor? = .gray
/// Wait to start dot size Default: 10
public var waitingViewSize: CGFloat = 10
/// Whether you can drag lyrics default: true
public var isDrag: Bool = true
Copy the code
Grading configuration
/// The rating view height defaults to 100
public var scoreViewHeight: CGFloat = 100
/// Start position of the circle: default: 100
public var innerMargin: CGFloat = 100
/// The line height defaults to 10
public var lineHeight: CGFloat = 10
/// The line width defaults to 120
public var lineWidht: CGFloat = 120
/// Default line background color
public var normalColor: UIColor = .gray
/// Match the background color of the back line
public var highlightColor: UIColor = .orange
/// The color of the dividing line
public var separatorLineColor: UIColor = .systemPink
// whether to hide the vertical divider
public var isHiddenVerticalSeparatorLine: Bool = false
// whether to hide the upper and lower dividers
public var isHiddenSeparatorLine: Bool = false
/// cursor background color
public var cursorColor: UIColor = .systemPink
// the width of the cursor
public var cursorWidth: CGFloat = 20
/// Cursor height
public var cursorHeight: CGFloat = 20
/// whether to hide particle animation effects
public var isHiddenEmitterView: Bool = false
/// Create particle animations using images
public var emitterImages: [UIImage]?
/// emitterImages is empty by default using colors to create particle animations
public var emitterColors: [UIColor] = [.red]
/// * /
public var tailAnimateImage: UIImage?
/// The tail animation color
public var tailAnimateColor: UIColor? = .yellow
/// Score Default score: 50
public var defaultScore: Double = 50
Copy the code
Event callback
Lyrics to Delegate
weak var delegate: AgoraLrcViewDelegate?
protocol AgoraLrcViewDelegate {
/// Current player time unit: second
func getPlayerCurrentTime(a) -> TimeInterval
/// Get the total song length
func getTotalTime(a) -> TimeInterval
// Set the player time
@objc
optional func seekToTime(time: TimeInterval)
/// The current lyrics and progress
@objc
optional func currentPlayerLrc(lrc: String.progress: CGFloat)
}
Copy the code
Lyrics download Delegate
weak var downloadDelegate: AgoraLrcDownloadDelegate?
protocol AgoraLrcDownloadDelegate {
/// Start downloading
@objc
optional func beginDownloadLrc(url: String)
/// Download complete
@objc
optional func downloadLrcFinished(url: String)
/// Download progress
@objc
optional func downloadLrcProgress(url: String.progress: Double)
/// Download failed
@objc
optional func downloadLrcError(url: String.error: Error?).
/// Download cancelled
@objc
optional func downloadLrcCanceld(url: String)
/// start parsing the lyrics
@objc
optional func beginParseLrc(a)
/// End of parsing lyrics
@objc
optional func parseLrcFinished(a)
}
Copy the code
Score the Delegate
weak var scoreDelegate: AgoraKaraokeScoreDelegate?
protocol AgoraKaraokeScoreDelegate {
/// score real-time callback
/// score: the number of points added each time
// cumulativeScore: cumulativeScore
/ / / totalScore: total score
@objc optional func agoraKaraokeScore(score: Double.cumulativeScore: Double.totalScore: Double)
}
Copy the code
Integrated way
Native POD is introduced and will be used temporarily until cocoapods is released
Copy ‘AgoraLrcScoreView’ to the root directory and execute POD
pod 'AgoraLrcScore'.:path= >"AgoraLrcScoreView"
Copy the code