Playback, import fixes
This commit is contained in:
parent
a29f4433ca
commit
e8fa9e4cda
|
@ -1,6 +1,7 @@
|
|||
#= require jquery
|
||||
#= require jquery_ujs
|
||||
#= require jquery.autocomplete
|
||||
#= require jquery.neighbour
|
||||
|
||||
#= require bootstrap-dropdown
|
||||
#= require bootstrap-tooltip
|
||||
|
|
|
@ -47,18 +47,18 @@ class BeatHaven.Models.Player extends Backbone.Model
|
|||
if @playlist_on
|
||||
# not implemented
|
||||
else
|
||||
nodes = @current_track.node().next()
|
||||
return false unless nodes.length == 1
|
||||
@tracks.get(parseInt($(nodes[0]).data("id"), 10)).play()
|
||||
node = $(".tracks li.now-playing").neighbour(".tracks li", 1)
|
||||
return false unless node?
|
||||
@tracks.get(parseInt($(node).data("id"), 10)).play()
|
||||
|
||||
prev: ->
|
||||
return false unless @current_track?
|
||||
if @playlist_on
|
||||
# not implemented
|
||||
else
|
||||
nodes = @current_track.node().prev()
|
||||
return false unless nodes.length == 1
|
||||
@tracks.get(parseInt($(nodes[0]).data("id"), 10)).play()
|
||||
node = $(".tracks li.now-playing").neighbour(".tracks li", -1)
|
||||
return false unless node?
|
||||
@tracks.get(parseInt($(node).data("id"), 10)).play()
|
||||
|
||||
play_something: ->
|
||||
nodes = $(".artist-page .tracks li[data-id]")
|
||||
|
|
|
@ -28,6 +28,7 @@ class BeatHaven.Models.Track extends Backbone.Model
|
|||
self.start()
|
||||
|
||||
add_to_library: (params) ->
|
||||
self = this
|
||||
obj = soundManager.createSound
|
||||
id: @.get("id")
|
||||
url: @.get("url")
|
||||
|
@ -39,8 +40,10 @@ class BeatHaven.Models.Track extends Backbone.Model
|
|||
BH.Player.update_progress_bar(this)
|
||||
onfinish: ->
|
||||
BH.Player.next()
|
||||
self.node().removeClass("now-playing").removeClass("paused")
|
||||
ondataerror: ->
|
||||
BH.Player.next()
|
||||
self.node().removeClass("now-playing").removeClass("paused")
|
||||
@.set("sm_obj", obj)
|
||||
|
||||
node: ->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="artist-page">
|
||||
<div class="artist-page single-album">
|
||||
<h1 class="title">{{album_title}} ({{album_year}})</h1>
|
||||
<div class="album">
|
||||
<div class="pic">
|
||||
<div class="album row">
|
||||
<div class="pic span3">
|
||||
<img src="{{album_pic}}" alt="{{album_title}}"><br>
|
||||
<div class="bh-underlay-blue">
|
||||
<a href="" class="btn btn-bh-dark album-add">
|
||||
|
@ -16,6 +16,7 @@
|
|||
</a>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="span9">
|
||||
<ul class="tracks">
|
||||
{{#album_tracks}}
|
||||
<li data-id="{{track_id}}">
|
||||
|
@ -43,3 +44,4 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
class BeatHaven.Views.AlbumShow extends Backbone.View
|
||||
template: HoganTemplates["backbone/templates/album/show"]
|
||||
template: HoganTemplates["album/show"]
|
||||
|
||||
initialize: ->
|
||||
@model.on("change", @render, this)
|
||||
|
||||
render: ->
|
||||
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")
|
||||
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)
|
||||
BeatHaven.Player.tracks.push(track)
|
||||
$(@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')
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
def pic_safe
|
||||
|
@ -23,6 +23,10 @@ class Album < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def pic_thumb
|
||||
pic_safe
|
||||
end
|
||||
|
||||
def load_pic
|
||||
info = begin
|
||||
response = LastFM::Album.get_info(artist: (artist.nil? ? VA : artist.name), album: title)
|
||||
|
@ -52,7 +56,7 @@ class Album < ActiveRecord::Base
|
|||
update_attributes(
|
||||
title: robbie_album.title,
|
||||
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.update_attributes(
|
||||
disc_id: robbie_track.disc_id,
|
||||
|
|
|
@ -2,9 +2,10 @@ class Artist < ActiveRecord::Base
|
|||
has_many :albums
|
||||
has_many :performers
|
||||
has_many :tracks, through: :performers
|
||||
has_many :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 {
|
||||
includes(:albums).includes(:tracks)
|
||||
|
@ -15,7 +16,7 @@ class Artist < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def url
|
||||
"/artist/#{name.gsub(/\s/, "+")}"
|
||||
"/artist/#{name.gsub(/\s/, "+")}" rescue ""
|
||||
end
|
||||
|
||||
def import
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
class ArtistGenre < ActiveRecord::Base
|
||||
belongs_to :artist
|
||||
belongs_to :genre
|
||||
|
||||
attr_accessible :artist_id, :genre_id
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class Track < ActiveRecord::Base
|
|||
has_many :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{
|
||||
includes(:artists)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ json.album_tracks @album.tracks.to_a do |json, track|
|
|||
json.duration track.duration
|
||||
json.length track.length
|
||||
json.artists track.artists.map(&:name)
|
||||
json.album title
|
||||
json.album_pic pic_safe
|
||||
json.album @album.title
|
||||
json.album_pic @album.pic_thumb
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
BeatHaven::Application.routes.draw do
|
||||
namespace :api do
|
||||
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 }
|
||||
end
|
||||
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