Music Player select some songs and play in rails

倾然丶 夕夏残阳落幕 提交于 2019-12-10 20:54:53

问题


In my rails 4 application I have jplayer to play music files , its works fine and I need to add select some songs from playlist using check-box and play option ,Its harder to customize the default jplayer playlist so that I have created a separate playlist and the code is

  <%= form_tag album_path , method: :get,  id: "sel" do  %>
     <%= submit_tag "play", name: nil, :class => "btn btn-success " %>
     <%= link_to "Play All", album_path , :class => "btn btn-success "%>
      <%  @album.audios.each do |audio| %>
        <%= check_box_tag "audio_ids[]",audio.id ,nil,class: "song"%></td>
        <%= link_to audio.name, album_path(id: @album.id, audio_ids: audio) %>
        <%= audio.artist %>
      <% end %>
 <% end %>

and its works fine too Whenever I choose some check-boxes the corresponding ids passing and I will render json according to that and I will create playlist and this is code for creating code in jplayer

$.ajax({ 
    type: 'GET',
    url:window.location ,
    dataType: "json",
    success: function(json){
       $.each(json,function(data){ 
        myPlaylist.add({title:$(this).attr("name"), artist:$(this).attr("artist"), m4a:$(this).attr("audio_url")});
         });
          }
       });

Now I need is the check-boxes to be keep their status (checked or unchecked) after refreshing the page until user change the status. How to do this one?......Whether I can use sessions? (If there is any way of having jplayer default playlist check-boxes say me that too )....

来源:https://stackoverflow.com/questions/25930992/music-player-select-some-songs-and-play-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!