Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for macOS #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Examples/MacOS/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Artsy/Specs.git'

platform :osx, '10.14'
inhibit_all_warnings!
use_frameworks!

project 'SpotlightLyricsMacExample'

target 'SpotlightLyricsMacExample' do
pod 'SpotlightLyrics', :path => '../../SpotlightLyrics.podspec'
pod 'SpotlightLyrics/Mac', :path => '../../SpotlightLyrics.podspec'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
409 changes: 409 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
26 changes: 26 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// AppDelegate.swift
// SpotlightLyricsMacExample
//
// Created by Lyt on 9/28/20.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {




func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
717 changes: 717 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
69 changes: 69 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// ViewController.swift
// SpotlightLyricsMacExample
//
// Created by Lyt on 9/28/20.
//

import Cocoa
import SpotlightLyrics

/// An example for usage of LyricsView
final class ViewController: NSViewController {

private lazy var playButton = NSButton(title: "Play from beginning", target: self, action: #selector(playFromBeginning))

private lazy var lyricsView: LyricsView = {
let lyricsView = LyricsView()
if let filepath = Bundle.main.path(forResource: "imagine.lrc", ofType: "txt") {
do {
let contents = try String(contentsOfFile: filepath)
lyricsView.lyrics = contents
} catch {
assertionFailure("contents could not be loaded")
}
} else {
assertionFailure("txt file not found")
}
return lyricsView
}()

override func viewDidLoad() {
super.viewDidLoad()
setupLayout()
}

override func viewDidAppear() {
super.viewDidAppear()
lyricsView.timer.play()
}

private func setupLayout() {
NSLayoutConstraint.activate([
view.heightAnchor.constraint(equalToConstant: 500)
])

view.addSubview(lyricsView)
lyricsView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
lyricsView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
lyricsView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
lyricsView.topAnchor.constraint(equalTo: view.topAnchor)
])

view.addSubview(playButton)
playButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playButton.topAnchor.constraint(equalTo: lyricsView.bottomAnchor),
playButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
playButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -8)
])
}

@objc private func playFromBeginning() {
lyricsView.timer.reset()
lyricsView.timer.play()
}

}

43 changes: 43 additions & 0 deletions Examples/MacOS/SpotlightLyricsMacExample/imagine.lrc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[artist:Etta James]
[title:Imagine]
[album:All the Way]

[00:00]Etta James - Imagine
[00:07](All the Way)
[00:13]
[00:15.48]Imagine there's no heaven
[00:22.67]It's easy if you try
[00:29.45]No hell below us
[00:36.42]Above us is only sky
[00:40.93]
[00:43.30]Imagine all the people
[00:48.80]Living for today
[00:55.36]
[00:57.18]Imagine there's no countries
[01:04.02]It isn't hard to do
[01:10.67]Nothing to kill or die for
[01:16.95]No religion too
[01:21.30]
[01:24.26]Imagine all the people
[01:29.92]Living life in peace, oh, yes
[01:37.63]
[01:37.64]You may say that I'm a dreamer
[01:44.05]But I'm not the only one
[01:50.76]I hope someday you'll join us
[01:56.88]And the world will live as one
[02:03.36]
[02:05.74]Imagine no possessions
[02:11.93]I wonder if you can
[02:18.67]No need for greed or hunger
[02:25.99]A brotherhood of man
[02:31.43]
[02:32.24]Imagine all the people
[02:38.43]Sharing all the world, oh oh oh
[02:46.03]
[02:46.26]You may say that I'm a dreamer
[02:52.51]But I'm not the only one
[02:59.26]I hope someday you'll join us
[03:05.49]And the world will live as one
[03:12.21]I hope someday you'll join us
[03:19.03]And the world will live as one
[03:31.02]
19 changes: 19 additions & 0 deletions Examples/iOS/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Artsy/Specs.git'

platform :ios, '9.0'
inhibit_all_warnings!
use_frameworks!

project 'SpotlightLyricsIOSExample'

target 'SpotlightLyricsIOSExample' do
pod 'SpotlightLyrics', :path => '../../SpotlightLyrics.podspec'
pod 'SpotlightLyrics/iOS', :path => '../../SpotlightLyrics.podspec'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
Loading