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

Major update #4

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2a09c66
fixed pause play issue
Jun 23, 2015
8825fb8
NEW non app store version
Jun 23, 2015
c023822
sparkle added and configured for project
Jun 23, 2015
bcdbc55
updated with fixed pause play from non App Store version
Jun 26, 2015
95b7521
added scripting bridge entitlements
Jun 27, 2015
0443f26
fixed issue where app would crash on systems where spotify is not ins…
Jun 27, 2015
e428f5d
fixed issue with pausing spotify as an optional
Jun 27, 2015
7ac38a7
Working Spotify optionals
Jun 27, 2015
b68c4b3
Added Beats 1 Support
Jul 1, 2015
1e3c889
updated build number for submission to app store
Jul 3, 2015
b7b60ec
resolved issue where app would crash when no results where returned f…
Aug 12, 2015
c686020
commuting change in info.plist
Sep 1, 2015
83aef98
updated to swift 3
joakes1990 Feb 24, 2017
b738fd5
built track recognition into media controller
joakes1990 Feb 25, 2017
2c8744f
began building custom nsmenuitem view
joakes1990 Feb 25, 2017
67fe221
added playback controls to menu item
joakes1990 Feb 26, 2017
6e31e3d
ties status bar to music controller
joakes1990 Feb 26, 2017
fbfd24d
hooked up playback controls
joakes1990 Feb 26, 2017
690835a
added store search to app
joakes1990 Feb 26, 2017
acdf787
App seams to be ready
joakes1990 Feb 26, 2017
0f5a915
Adding additional resources for contributors
joakes1990 Feb 26, 2017
e050efc
updated build number to be higher than previous version
joakes1990 Feb 27, 2017
2a53446
Merge branch 'master' of https://github.com/kevcooper/SongBar
joakes1990 Feb 27, 2017
fc59d8e
Fixed issue preventing the app from running on first launch
joakes1990 Feb 27, 2017
c6ffbfb
small fixes and updates.
joakes1990 Jun 5, 2017
929ea12
title truncates to length of menu in iTunes (no internet to test Spot…
joakes1990 Jun 10, 2017
8c0dbe2
updated to swift 4
joakes1990 Nov 1, 2017
e514ba4
updated parts of media controller
joakes1990 Nov 1, 2017
636c31d
tests for playing app
joakes1990 Nov 1, 2017
32c2ec7
Broke out notification center listener
joakes1990 Nov 2, 2017
e7d4fc9
updated media controller
joakes1990 Nov 3, 2017
370d173
fixed crasher where no apps where open
joakes1990 Nov 3, 2017
dd10c44
play pause button behaves correctly
joakes1990 Nov 7, 2017
6e12ed9
fixed back option
joakes1990 Nov 7, 2017
fea9b2c
updated settings window
joakes1990 Nov 16, 2017
a290cde
reimplemented missing listener class
joakes1990 Dec 4, 2017
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
Empty file modified .gitignore
100644 → 100755
Empty file.
Binary file added Acorn Assets/playback.acorn
Binary file not shown.
Empty file modified LICENSE
100644 → 100755
Empty file.
15 changes: 15 additions & 0 deletions Player.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Player.swift
// SongBar
//
// Created by Justin Oakes on 31/10/17.
// Copyright © 2017 corpe. All rights reserved.
//

import Foundation
import ScriptingBridge

struct Player {
let application: kServices
let bridgedApplication: SBApplication
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SongBar 2
____________________

This is the first major update to Songbar.
This version removed the Sparkle framework in favor of exclusive MAS distribution,
This should make building on your side easier as this removes the need for any 3rd party CocoaPods and allows you to build directly from the included Xcode project.
258 changes: 213 additions & 45 deletions SongBar.xcodeproj/project.pbxproj
100644 → 100755

Large diffs are not rendered by default.

Empty file modified SongBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata
100644 → 100755
Empty file.
104 changes: 11 additions & 93 deletions SongBar/AppDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,112 +8,30 @@

import Cocoa
import AppKit
import ScriptingBridge

@NSApplicationMain

class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!
@IBOutlet weak var menu: NSMenu!

var lastServiceUsed: Service?

let mediaController: MediaController = MediaController()
let listener: PlayerNotificationCenterListener = PlayerNotificationCenterListener()
var sysBar: NSStatusItem!
var iTunes: AnyObject!
var Spotify: AnyObject!
//magic number
var variableStatusItemLength: CGFloat = -1;

func applicationDidFinishLaunching(aNotification: NSNotification) {

sysBar = NSStatusBar.systemStatusBar().statusItemWithLength(variableStatusItemLength);
sysBar.menu = menu;
iTunes = SBApplication(bundleIdentifier: "com.apple.iTunes")
Spotify = SBApplication(bundleIdentifier: "com.spotify.client")

updateStatusBar();

NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateiTuensFromNotification:",
name: "com.apple.iTunes.playerInfo",
object: nil);
NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateSpotifyFromNotification:",
name: "com.spotify.client.PlaybackStateChanged",
object: nil)

}

func applicationWillTerminate(aNotification: NSNotification) {
NSDistributedNotificationCenter.defaultCenter().removeObserver(self);
}

func updateStatusBar(){

let track: iTunesTrack = iTunes.currentTrack;
let spotifyTrack: SpotifyTrack = Spotify.currentTrack

let name: String = (track.name != nil) ? track.name : "";
let artist: String = (track.artist != nil) ? track.artist : "";

let spotifyName: String = spotifyTrack.name != nil ? spotifyTrack.name : ""
let spotifyArtist: String = spotifyTrack.artist != nil ? spotifyTrack.artist : ""

if(artist != "" && name != ""){
sysBar.title! = name + " - " + artist;
}else if spotifyArtist != "" && spotifyName != ""{
sysBar.title = "\(spotifyName) - \(spotifyArtist)"
}else{
sysBar.title! = "SongBar";
}


}

func updateiTuensFromNotification(aNotification: NSNotification){
let info = aNotification.userInfo! as NSDictionary;

if(info.objectForKey("Name") != nil && info.objectForKey("Artist") != nil){
let name: String = info.valueForKey("Name") as! String;
let artist: String = info.valueForKey("Artist")as! String;

sysBar.title! = name + " - " + artist;
lastServiceUsed = Service.iTunes
}else{
sysBar.title! = "SongBar";
}
}
//magic number
let variableStatusItemLength: CGFloat = -1

func updateSpotifyFromNotification(aNotification: NSNotification){
let info = aNotification.userInfo! as NSDictionary;
if info["Name"] != nil && info["Artist"] != nil {
let name: String = info["Name"] as! String
let artist: String = info["Artist"] as! String

sysBar.title = "\(name) - \(artist)"

lastServiceUsed = Service.spotify
} else{
sysBar.title! = "SongBar";
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
sysBar = NSStatusBar.system.statusItem(withLength: variableStatusItemLength);
sysBar.updateStatusBar(itemTitle: mediaController.playingServiceTitle())
sysBar.menu = menu
}

@IBAction func playPause(sender: AnyObject) {
if lastServiceUsed == Service.iTunes{
iTunes.playpause();
} else if lastServiceUsed == Service.spotify{
Spotify.playpause()
} else {
iTunes.playpause()
}
func applicationWillTerminate(_ aNotification: Notification) {
DistributedNotificationCenter.default().removeObserver(self);
}


}

enum Service {
case iTunes

case spotify
}
89 changes: 89 additions & 0 deletions SongBar/AppDelegate.swift.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// AppDelegate.swift
// SongBar
//
// Created by Kevin Cooper on 10/21/14.
// Copyright (c) 2014 corpe. All rights reserved.
//

import Cocoa
import AppKit

@NSApplicationMain

class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var menu: NSMenu!
var mediaController: MediaController = MediaController()
var sysBar: NSStatusItem!

<<<<<<< HEAD
//magic number
let variableStatusItemLength: CGFloat = -1;

func applicationDidFinishLaunching(_ aNotification: Notification) {
if UserDefaults.standard.bool(forKey: kUserDefaults.isInitalized) == false {
UserDefaults.standard.set(true, forKey: kUserDefaults.supportiTunes)
UserDefaults.standard.set(true, forKey: kUserDefaults.supportSpotify)
// add suport for radiant here once pull request is accepted
UserDefaults.standard.set(true, forKey: kUserDefaults.isInitalized)
UserDefaults.standard.synchronize()
=======
func applicationDidFinishLaunching(aNotification: NSNotification) {

sysBar = NSStatusBar.systemStatusBar().statusItemWithLength(variableStatusItemLength);
sysBar.menu = menu;
iTunes = SBApplication(bundleIdentifier: "com.apple.iTunes")
Spotify = SBApplication(bundleIdentifier: "com.spotify.client")

updateStatusBar();

NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateiTuensFromNotification:",
name: "com.apple.iTunes.playerInfo",
object: nil);
NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateSpotifyFromNotification:",
name: "com.spotify.client.PlaybackStateChanged",
object: nil)

}

func applicationWillTerminate(aNotification: NSNotification) {
NSDistributedNotificationCenter.defaultCenter().removeObserver(self);
}

func updateStatusBar(){

let track: iTunesTrack = iTunes.currentTrack;
let spotifyTrack: SpotifyTrack = Spotify.currentTrack

let name: String = (track.name != nil) ? track.name : "";
let artist: String = (track.artist != nil) ? track.artist : "";

let spotifyName: String = spotifyTrack.name != nil ? spotifyTrack.name : ""
let spotifyArtist: String = spotifyTrack.artist != nil ? spotifyTrack.artist : ""

if(artist != "" && name != ""){
sysBar.title! = name + " - " + artist;
}else if spotifyArtist != "" && spotifyName != ""{
sysBar.title = "\(spotifyName) - \(spotifyArtist)"
}else{
sysBar.title! = "SongBar";
>>>>>>> a691bea6460ee0055c4cc9af2699d8b0a564015b
}

sysBar = NSStatusBar.system().statusItem(withLength: variableStatusItemLength);
sysBar.menu = menu
sysBar.updateStatusBar(itemTitle: kMiscStrings.songbar)

}

func applicationWillTerminate(_ aNotification: Notification) {
DistributedNotificationCenter.default().removeObserver(self);
}




}
89 changes: 89 additions & 0 deletions SongBar/AppDelegate_BACKUP_59663.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// AppDelegate.swift
// SongBar
//
// Created by Kevin Cooper on 10/21/14.
// Copyright (c) 2014 corpe. All rights reserved.
//

import Cocoa
import AppKit

@NSApplicationMain

class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var menu: NSMenu!
var mediaController: MediaController = MediaController()
var sysBar: NSStatusItem!

<<<<<<< HEAD
//magic number
let variableStatusItemLength: CGFloat = -1;

func applicationDidFinishLaunching(_ aNotification: Notification) {
if UserDefaults.standard.bool(forKey: kUserDefaults.isInitalized) == false {
UserDefaults.standard.set(true, forKey: kUserDefaults.supportiTunes)
UserDefaults.standard.set(true, forKey: kUserDefaults.supportSpotify)
// add suport for radiant here once pull request is accepted
UserDefaults.standard.set(true, forKey: kUserDefaults.isInitalized)
UserDefaults.standard.synchronize()
=======
func applicationDidFinishLaunching(aNotification: NSNotification) {

sysBar = NSStatusBar.systemStatusBar().statusItemWithLength(variableStatusItemLength);
sysBar.menu = menu;
iTunes = SBApplication(bundleIdentifier: "com.apple.iTunes")
Spotify = SBApplication(bundleIdentifier: "com.spotify.client")

updateStatusBar();

NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateiTuensFromNotification:",
name: "com.apple.iTunes.playerInfo",
object: nil);
NSDistributedNotificationCenter.defaultCenter().addObserver(self,
selector: "updateSpotifyFromNotification:",
name: "com.spotify.client.PlaybackStateChanged",
object: nil)

}

func applicationWillTerminate(aNotification: NSNotification) {
NSDistributedNotificationCenter.defaultCenter().removeObserver(self);
}

func updateStatusBar(){

let track: iTunesTrack = iTunes.currentTrack;
let spotifyTrack: SpotifyTrack = Spotify.currentTrack

let name: String = (track.name != nil) ? track.name : "";
let artist: String = (track.artist != nil) ? track.artist : "";

let spotifyName: String = spotifyTrack.name != nil ? spotifyTrack.name : ""
let spotifyArtist: String = spotifyTrack.artist != nil ? spotifyTrack.artist : ""

if(artist != "" && name != ""){
sysBar.title! = name + " - " + artist;
}else if spotifyArtist != "" && spotifyName != ""{
sysBar.title = "\(spotifyName) - \(spotifyArtist)"
}else{
sysBar.title! = "SongBar";
>>>>>>> a691bea6460ee0055c4cc9af2699d8b0a564015b
}

sysBar = NSStatusBar.system().statusItem(withLength: variableStatusItemLength);
sysBar.menu = menu
sysBar.updateStatusBar(itemTitle: kMiscStrings.songbar)

}

func applicationWillTerminate(_ aNotification: Notification) {
DistributedNotificationCenter.default().removeObserver(self);
}




}
Loading