Пример #1
0
func ensureSongs() {
	songsPath := path.Join(config.DataPath, "songs.txt")
	songHashesPath := path.Join(config.DataPath, "song_hashes.txt")
	if !pathExists(songsPath) && !pathExists(songHashesPath) {
		log.Printf("No song indexes detected!")
		fmt.Printf("\nPlease provide folder with mp3s: ")
		musicPath := gets()
		for !pathExists(musicPath) {
			fmt.Printf("\nInvalid path. Please try again: ")
			musicPath = gets()
		}
		library.AddPaths([]string{musicPath})
	}
}
Пример #2
0
func main() {
	command := flag.String("e", "", "command")
	configPath := flag.String("c", "", "config path")
	dataPath := flag.String("d", "", "data path")
	webPlayerOnly := flag.Bool("webplayer", false, "webplayer; no mpg123 output")
	startPaused := flag.Bool("paused", false, "start paused")
	flag.Parse()

	config.Load(*configPath, *dataPath)

	ensureBinaryExists("mpg123")
	ensureSongs()

	switch *command {
	case "add":
		library.AddPaths(flag.Args())

	default:

		library.Load()
		dj.SetSongs(library.Songs)

		if *webPlayerOnly {
			player.Silence()
		}

		if *startPaused {
			player.Pause()
		}

		go env.Updater()

		go rpc.Listener()
		go console.Listener()
		go rest.Listener()

		player.PlaySongs()

	} // switch

	doneCh := make(chan struct{})
	<-doneCh
}