<% provide(:title, "#{@music_session.description}") %>
<% provide(:description, description_for_music_session(@music_session)) %>
<% provide(:page_name, 'music-sessions entity-landing') %>

<% content_for :social_meta do %>
    <meta property="fb:app_id"          content="<%= Rails.application.config.facebook_app_id %>" />
    <meta property="og:title"           content="<%= title_for_music_session(@music_session) %>" />
    <meta property="og:url"             content="<%= request.original_url %>" />
    <meta property="og:description"     content="<%= description_for_music_session(@music_session)  %>" />
    <meta property="og:image"           content="<%= facebook_image_for_music_session(@music_session) %>" />
    <meta property="og:image:width"     content="<%= facebook_image_size_for_music_session(@music_session) %>" />
    <meta property="og:image:height"    content="<%= facebook_image_size_for_music_session(@music_session) %>" />
    <meta property="og:type"            content="website" />

    <meta name="twitter:card"           content="summary">
    <meta name="twitter:site"           content="@jamkazam">
    <meta name="twitter:title"          content="<%= title_for_music_session(@music_session) %>" />
    <meta name="twitter:description"    content="<%= description_for_music_session(@music_session) %>" />
<% end %>

<div class="sessions-page">
  <% if @music_session.fan_access %>
    <div class="landing-band">
      <% unless @music_session.band.nil? %>
        <div class="landing-avatar">
          <% unless @music_session.band.photo_url.blank? %>
            <%= image_tag "#{@music_session.band.photo_url}", {:alt => ""} %>
          <% else %>
            <%= image_tag "shared/avatar_generic_band.png", {:alt => ""} %>
          <% end %>
        </div>
        <%= @music_session.band.name %>
      <% else %>
        <div class="landing-avatar">
          <% unless @music_session.creator.photo_url.blank? %>
            <%= image_tag "#{@music_session.creator.photo_url}", {:alt => ""} %>
          <% else %>
            <%= image_tag "shared/avatar_generic.png", {:alt => ""} %>
          <% end %>
        </div>
        <%= @music_session.creator.name %>
      <% end %>
    </div>

    <div class="landing-details">
      <div class="left f20 teal"><strong>SESSION</strong></div>
      <div class="right f14 grey"><%= timeago(@music_session.created_at) %></div>
      <br clear="all" /><br />
      <div class="left w70"><%= @music_session.description %><br /><br /></div>
      <% if @music_session.session_removed_at.blank? %>
        <div class="right">
          <a id="btnLike"><%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :alt => ""} %>&nbsp;LIKE</a>&nbsp;&nbsp;&nbsp;
          <a id="btnShare"><%= image_tag "content/icon_share.png", {:width => 13, :height => 15, :alt => ""} %>&nbsp;SHARE</a>
        </div>
      <% end %>
      <br clear="all" />
      <div class="w100">
        <div class="session-controls <%= @music_session.is_over? ? 'ended' : 'inprogress' %>" data-music-session="<%=@music_session.id %>">
          <a class="left play-button" href="#">
            <%= image_tag 'content/icon_pausebutton.png', width:20, height:20, class:'play-icon' %>
            <% if @music_session.active_music_session && @music_session.active_music_session.mount %>
              <audio preload="none">
                <source src="<%= @music_session.active_music_session.mount.url %>" type="<%= @music_session.active_music_session.mount.resolve_string(:mime_type) %>">
              </audio>
            <% end %>
          </a>
          <div class="session-status"><%= @music_session.is_over? ? 'SESSION ENDED' : 'LIVE SESSION IN PROGRESS' %></div>
          <%= session_duration(@music_session, class: 'session-duration tick-duration recording-current', 'data-created-at' => @music_session.created_at.to_i) %>
        </div>

        <div class="left white"><%= @music_session.genre.description %></div>
        <div class="right white">

          <span id="spnCommentCount"><%= @music_session.comment_count %></span>
          <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %>&nbsp;&nbsp;&nbsp;&nbsp;

          <span id="spnLikeCount"><%= @music_session.like_count %></span>
          <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %>

        </div>
      </div>
      <br clear="all" /><br />
      <%= render :partial => "shared/track_details", :locals => {:tracks => @music_session.grouped_tracks} %>
    </div>

  <% else %>
    <div class="left f20 teal"><strong>SESSION NOT FOUND</strong></div>
  <% end %>

</div>

  <% if false %>
    <div class="landing-sidebar" style="z-index:900;"><br />
      <br>
      <br>
      <div align="center">
        <div class="sponsor">
          <span>SPONSORED BY:</span>
          <a href="http://www.centurylinktechnology.com/">
            <%= image_tag 'content/logo_centurylink.png', width:320, height:80, alt:'CenturyLink logo'%>
          </a>
        </div>
        <div align="center">LEARN ABOUT JAMKAZAM</div>
        <br>
        <%= image_tag('web/carousel_musicians.jpg', width:350,  alt:'JamKazam Overview',
                      class: 'video-slide', :'data-video-header' => 'JamKazam Overview',
                      :'data-video-url' => 'https://www.youtube.com/embed/ylYcvTY9CVo?autoplay=1') %>
      </div>
    </div>
  <% else %>
    <% if signed_in? && @music_session.fan_access %>
      <% unless @music_session.band.nil? %>
        <%= render :partial => "shared/landing_sidebar", :locals => {:user => @music_session.band, :recent_history => @music_session.band.recent_history(@music_session.id, nil)} %>
      <% else %>
        <%= render :partial => "shared/landing_sidebar", :locals => {:user => @music_session.creator, :recent_history => @music_session.creator.recent_history(@music_session.id, nil)} %>
      <% end %>
    <% else %>
      <%= render :partial => "shared/cta_sidebar" %>
    <% end %>
  <% end %>

  <% if @music_session.fan_access %>
    <% content_for :after_black_bar do %>
      <br />
      <%= render :partial => "shared/comments", :locals => {:comments => @music_session.comments, :id => "txtSessionComment", :info_page => false} %>
    <% end %>


    <% content_for :extra_js do %>
        <script type="text/javascript">
            $(function () {
              var showMusicSession = new JK.ShowMusicSession(JK.app);
              showMusicSession.initialize("<%= @music_session.id %>");
            });
        </script>
    <% end %>
  <% end %>