Playback, import fixes
This commit is contained in:
parent
a29f4433ca
commit
e8fa9e4cda
|
@ -1,6 +1,7 @@
|
||||||
#= require jquery
|
#= require jquery
|
||||||
#= require jquery_ujs
|
#= require jquery_ujs
|
||||||
#= require jquery.autocomplete
|
#= require jquery.autocomplete
|
||||||
|
#= require jquery.neighbour
|
||||||
|
|
||||||
#= require bootstrap-dropdown
|
#= require bootstrap-dropdown
|
||||||
#= require bootstrap-tooltip
|
#= require bootstrap-tooltip
|
||||||
|
|
|
@ -47,18 +47,18 @@ class BeatHaven.Models.Player extends Backbone.Model
|
||||||
if @playlist_on
|
if @playlist_on
|
||||||
# not implemented
|
# not implemented
|
||||||
else
|
else
|
||||||
nodes = @current_track.node().next()
|
node = $(".tracks li.now-playing").neighbour(".tracks li", 1)
|
||||||
return false unless nodes.length == 1
|
return false unless node?
|
||||||
@tracks.get(parseInt($(nodes[0]).data("id"), 10)).play()
|
@tracks.get(parseInt($(node).data("id"), 10)).play()
|
||||||
|
|
||||||
prev: ->
|
prev: ->
|
||||||
return false unless @current_track?
|
return false unless @current_track?
|
||||||
if @playlist_on
|
if @playlist_on
|
||||||
# not implemented
|
# not implemented
|
||||||
else
|
else
|
||||||
nodes = @current_track.node().prev()
|
node = $(".tracks li.now-playing").neighbour(".tracks li", -1)
|
||||||
return false unless nodes.length == 1
|
return false unless node?
|
||||||
@tracks.get(parseInt($(nodes[0]).data("id"), 10)).play()
|
@tracks.get(parseInt($(node).data("id"), 10)).play()
|
||||||
|
|
||||||
play_something: ->
|
play_something: ->
|
||||||
nodes = $(".artist-page .tracks li[data-id]")
|
nodes = $(".artist-page .tracks li[data-id]")
|
||||||
|
|
|
@ -28,6 +28,7 @@ class BeatHaven.Models.Track extends Backbone.Model
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
add_to_library: (params) ->
|
add_to_library: (params) ->
|
||||||
|
self = this
|
||||||
obj = soundManager.createSound
|
obj = soundManager.createSound
|
||||||
id: @.get("id")
|
id: @.get("id")
|
||||||
url: @.get("url")
|
url: @.get("url")
|
||||||
|
@ -39,8 +40,10 @@ class BeatHaven.Models.Track extends Backbone.Model
|
||||||
BH.Player.update_progress_bar(this)
|
BH.Player.update_progress_bar(this)
|
||||||
onfinish: ->
|
onfinish: ->
|
||||||
BH.Player.next()
|
BH.Player.next()
|
||||||
|
self.node().removeClass("now-playing").removeClass("paused")
|
||||||
ondataerror: ->
|
ondataerror: ->
|
||||||
BH.Player.next()
|
BH.Player.next()
|
||||||
|
self.node().removeClass("now-playing").removeClass("paused")
|
||||||
@.set("sm_obj", obj)
|
@.set("sm_obj", obj)
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="artist-page">
|
<div class="artist-page single-album">
|
||||||
<h1 class="title">{{album_title}} ({{album_year}})</h1>
|
<h1 class="title">{{album_title}} ({{album_year}})</h1>
|
||||||
<div class="album">
|
<div class="album row">
|
||||||
<div class="pic">
|
<div class="pic span3">
|
||||||
<img src="{{album_pic}}" alt="{{album_title}}"><br>
|
<img src="{{album_pic}}" alt="{{album_title}}"><br>
|
||||||
<div class="bh-underlay-blue">
|
<div class="bh-underlay-blue">
|
||||||
<a href="" class="btn btn-bh-dark album-add">
|
<a href="" class="btn btn-bh-dark album-add">
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
<div class="span9">
|
||||||
<ul class="tracks">
|
<ul class="tracks">
|
||||||
{{#album_tracks}}
|
{{#album_tracks}}
|
||||||
<li data-id="{{track_id}}">
|
<li data-id="{{track_id}}">
|
||||||
|
@ -42,4 +43,5 @@
|
||||||
{{/album_tracks}}
|
{{/album_tracks}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
class BeatHaven.Views.AlbumShow extends Backbone.View
|
class BeatHaven.Views.AlbumShow extends Backbone.View
|
||||||
template: HoganTemplates["backbone/templates/album/show"]
|
template: HoganTemplates["album/show"]
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
@model.on("change", @render, this)
|
@model.on("change", @render, this)
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
if typeof @model.get("album_tracks") != "undefined"
|
if typeof @model.get("album_tracks") != "undefined"
|
||||||
|
@model.set "i18n_add", BH.I18n.t("artist.album.add")
|
||||||
|
@model.set "i18n_play", BH.I18n.t("artist.album.play")
|
||||||
for track_info in @model.get("album_tracks")
|
for track_info in @model.get("album_tracks")
|
||||||
|
track_info["i18n_add"] = BH.I18n.t("artist.album.track.add")
|
||||||
|
track_info["i18n_play"] = BH.I18n.t("artist.album.track.play")
|
||||||
|
track_info["i18n_pause"] = BH.I18n.t("artist.album.track.pause")
|
||||||
track = new BeatHaven.Models.Track(track_info.meta)
|
track = new BeatHaven.Models.Track(track_info.meta)
|
||||||
BeatHaven.Player.tracks.push(track)
|
BeatHaven.Player.tracks.push(track)
|
||||||
$(@el).html(@template.render(@model.toJSON()))
|
$(@el).html(@template.render(@model.toJSON()))
|
||||||
|
|
|
@ -162,3 +162,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.artist-page.single-album {
|
||||||
|
.tracks > li {
|
||||||
|
width: 705px;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
max-width: 615px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Album < ActiveRecord::Base
|
||||||
# .order('"albums"."year" ASC')
|
# .order('"albums"."year" ASC')
|
||||||
}
|
}
|
||||||
|
|
||||||
attr_accessible :artist_id, :pic, :rovi_id, :title, :year, :is_hidden
|
attr_accessible :artist_id, :pic, :rovi_id, :title, :year, :is_hidden, :tracks
|
||||||
VA = "Various Artists"
|
VA = "Various Artists"
|
||||||
|
|
||||||
def pic_safe
|
def pic_safe
|
||||||
|
@ -23,6 +23,10 @@ class Album < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pic_thumb
|
||||||
|
pic_safe
|
||||||
|
end
|
||||||
|
|
||||||
def load_pic
|
def load_pic
|
||||||
info = begin
|
info = begin
|
||||||
response = LastFM::Album.get_info(artist: (artist.nil? ? VA : artist.name), album: title)
|
response = LastFM::Album.get_info(artist: (artist.nil? ? VA : artist.name), album: title)
|
||||||
|
@ -52,14 +56,14 @@ class Album < ActiveRecord::Base
|
||||||
update_attributes(
|
update_attributes(
|
||||||
title: robbie_album.title,
|
title: robbie_album.title,
|
||||||
year: robbie_album.year,
|
year: robbie_album.year,
|
||||||
tracks: robbie_album.tracks.each { |robbie_track|
|
tracks: robbie_album.tracks.map{ |robbie_track|
|
||||||
track = Track.find_or_create_by_rovi_id(robbie_track.id)
|
track = Track.find_or_create_by_rovi_id(robbie_track.id)
|
||||||
track.update_attributes(
|
track.update_attributes(
|
||||||
disc_id: robbie_track.disc_id,
|
disc_id: robbie_track.disc_id,
|
||||||
position: robbie_track.position,
|
position: robbie_track.position,
|
||||||
title: robbie_track.title,
|
title: robbie_track.title,
|
||||||
duration: robbie_track.duration,
|
duration: robbie_track.duration,
|
||||||
artists: robbie_track.artists.map { |robbie_artist|
|
artists: robbie_track.artists.map{ |robbie_artist|
|
||||||
track_artist = Artist.find_or_create_by_rovi_id(robbie_artist.id)
|
track_artist = Artist.find_or_create_by_rovi_id(robbie_artist.id)
|
||||||
track_artist.update_attributes(
|
track_artist.update_attributes(
|
||||||
name: robbie_artist.name
|
name: robbie_artist.name
|
||||||
|
|
|
@ -2,9 +2,10 @@ class Artist < ActiveRecord::Base
|
||||||
has_many :albums
|
has_many :albums
|
||||||
has_many :performers
|
has_many :performers
|
||||||
has_many :tracks, through: :performers
|
has_many :tracks, through: :performers
|
||||||
|
has_many :artist_genres
|
||||||
has_many :genres, through: :artist_genres
|
has_many :genres, through: :artist_genres
|
||||||
|
|
||||||
attr_accessible :bio, :is_group, :name, :pic, :rovi_id
|
attr_accessible :bio, :is_group, :name, :pic, :rovi_id, :albums, :genres
|
||||||
|
|
||||||
scope :discography, lambda {
|
scope :discography, lambda {
|
||||||
includes(:albums).includes(:tracks)
|
includes(:albums).includes(:tracks)
|
||||||
|
@ -15,7 +16,7 @@ class Artist < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/artist/#{name.gsub(/\s/, "+")}"
|
"/artist/#{name.gsub(/\s/, "+")}" rescue ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
class ArtistGenre < ActiveRecord::Base
|
class ArtistGenre < ActiveRecord::Base
|
||||||
|
belongs_to :artist
|
||||||
|
belongs_to :genre
|
||||||
|
|
||||||
attr_accessible :artist_id, :genre_id
|
attr_accessible :artist_id, :genre_id
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Track < ActiveRecord::Base
|
||||||
has_many :performers
|
has_many :performers
|
||||||
has_many :artists, through: :performers
|
has_many :artists, through: :performers
|
||||||
|
|
||||||
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title
|
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title, :artists
|
||||||
scope :with_artists, lambda{
|
scope :with_artists, lambda{
|
||||||
includes(:artists)
|
includes(:artists)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ json.album_tracks @album.tracks.to_a do |json, track|
|
||||||
json.duration track.duration
|
json.duration track.duration
|
||||||
json.length track.length
|
json.length track.length
|
||||||
json.artists track.artists.map(&:name)
|
json.artists track.artists.map(&:name)
|
||||||
json.album title
|
json.album @album.title
|
||||||
json.album_pic pic_safe
|
json.album_pic @album.pic_thumb
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
BeatHaven::Application.routes.draw do
|
BeatHaven::Application.routes.draw do
|
||||||
namespace :api do
|
namespace :api do
|
||||||
resources :artists, only: [:show], constraints: { id: /.+/ }, format: :json
|
resources :artists, only: [:show], constraints: { id: /.+/ }, format: :json
|
||||||
resources :albums, only: [:show, :picture] do
|
resources :albums, only: [:show, :picture], format: :json do
|
||||||
member { get :picture }
|
member { get :picture }
|
||||||
end
|
end
|
||||||
resources :search, only: [] do
|
resources :search, only: [] do
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
$.fn.neighbour = (context, offset) ->
|
||||||
|
self = this[0]
|
||||||
|
result = null
|
||||||
|
nodes = $(context)
|
||||||
|
nodes.each (i, node) ->
|
||||||
|
result = nodes[i+offset] if node is self
|
||||||
|
result = null if typeof result is "undefined"
|
||||||
|
result
|
Loading…
Reference in New Issue