class FrontController extends Controller {
+ public static $notionFileFields = [
+ 'demos' => ['notion' => 'Démos Voix', 'cat' => '🎤 Démos'],
+ 'instru' => ['notion' => 'Instru', 'cat' => '🎸 Instru'],
+ 'record' => ['notion' => 'Enregistrement', 'cat' => '💿️ Enregistrement'],
+ 'tabs' => ['notion' => 'Partition', 'cat' => '🎼 Partition'],
+ 'archives' => ['notion' => 'Archives et autres fichiers', 'cat' => '🗃️ Archives']
+ ];
+
public static function defaultCollection() {
return redirect('/' . Collection::withoutGlobalScope('ownerclause')->find(1)->slug);
}
}
+ /** @var Checkbox $hideProperty */
+ $hideProperty = $song->getProprety('Cacher dans l\'app');
+ if ($hideProperty->checked) {
+ continue;
+ }
+
$s = [];
/** @var Title $titleProperty */
$orderProperty = $song->getProprety('Ordre');
/** @var RichTextProperty $notesProperty */
$notesProperty = $song->getProprety('Notes générales');
- /** @var \Notion\Pages\Properties\Files $filesProperty */
- $filesProperty = $song->getProprety('Files & media');
- /** @var Checkbox $hideProperty */
- $hideProperty = $song->getProprety('Cacher dans l\'app');
- if ($hideProperty->checked) {
- continue;
+
+ $audioId = 0;
+ foreach (self::$notionFileFields as $key => $f) {
+ /** @var \Notion\Pages\Properties\Files $filesProperty */
+ $filesProperty = $song->getProprety($f['notion']);
+ if (!isset($s[$key])) {
+ $s[$key] = [];
+ }
+ foreach ($filesProperty->files as $file) {
+ $ext = self::parseExtensionFromAmazonURL($file->url);
+ $isAudio = in_array($ext, $audios);
+ if ($isAudio) {
+ $audioId++;
+ $aid = $audioId;
+ } else {
+ $aid = 0;
+ }
+ $e = explode('.', $file->name);
+ if (count($e) > 1) {
+ array_pop($e);
+ $name = implode('.', $e);
+ }
+ $name = $name ?: self::parseFileNameFromAmazonURL($file->url);
+ $s[$key][] = ['name' => $name, 'opturl' => $file->url, 'url' => $file->url, 'ext' => $ext, 'audio' => $aid];
+ }
}
$s['id'] = $song->id;
$s['lyrics'] = $pageContents;
$s['notes'] = self::_blockToHtml($notesProperty);
$s['notion_url'] = $song->url;
-
- $s['files'] = [];
- $s['audios'] = [];
- foreach ($filesProperty->files as $file) {
- $ext = self::parseExtensionFromAmazonURL($file->url);
- if (in_array($ext, $audios)) {
- $s['audios'][] = ['name' => self::parseFileNameFromAmazonURL($file->url), 'url' => $file->url, 'ext' => $ext];
- } else {
- $s['files'][] = ['name' => self::parseFileNameFromAmazonURL($file->url), 'url' => $file->url, 'ext' => $ext];
- }
- }
-
$res[$s['order']] = new \App\Notion\Song($s, $collection->notion_database);
}
ksort($res);
namespace App\Notion;
+use App\Http\Controllers\FrontController;
use Cubist\Util\Data;
use Cubist\Util\Str;
-class Song extends Data{
+class Song extends Data {
public function getUrl() {
return Str::slug($this->getTitle()) . '.html';
return $this->get('order');
}
- public function getNotionURL(){
+ public function getNotionURL() {
return $this->get('notion_url');
}
- public function hasSimpleChords(){
+ public function hasSimpleChords() {
return false;
}
public function getAudioTracks() {
- $res = $this->get('audios');
- foreach ($res as $k=>$v) {
- $res[$k]['i']=$k;
- $res[$k]['opturl']=$v['url'];
+ $res = [];
+ foreach (FrontController::$notionFileFields as $key => $field) {
+ foreach ($this->get($key, []) as $file) {
+ if (!$file['audio']) {
+ continue;
+ }
+ $res[] = $file;
+ }
}
return $res;
}
-
- public function getFiles(){
- return $this->get('files');
- }
-
}
$('select[data-name="audio"]').val(e[1]);
updateSelect($('select[data-name="audio"]'));
resetPlayers();
+
playAudio();
return false;
});
$('[data-action="play"]').hide();
var audio = window.getOption('audio').toString();
+
var t = window.getOption('audio_' + audio + '_tone');
if (t === undefined) {
t = 0;
<li><a href="#" class="clickselect">💿 {{__('Audio track')}} <select data-name="audio"
name="audio_{{$song->id}}">
@foreach($song->getAudioTracks() as $i=>$track)
- <option value="{{$i}}" data-url="{{$track['url']}}">{{$track['name']}}</option>
+ <option value="{{$track['audio']}}" data-url="{{$track['url']}}">{{$track['name']}}</option>
@endforeach
</select><span></span></a></li>
- @foreach($song->getAudioTracks() as $i=>$track)
- @if($collection->transpose && isset($track['tone']) && is_numeric($track['tone']))
- <li data-audio="{{$i}}"><a href="#" class="clickselect">↕️{{__('Audio key')}} <select
- class="audiotone"
- data-name="audio_{{$i}}_tone"
- name="audio_{{$i}}_tone_{{$song->id}}">
- @for($i=-5;$i<=6;$i++)
- <option value="{{($i+12)%12}}"
- @if($i===0) selected @endif>{{$tones[(12+$track['tone']+$i)%12].$song->mode}} @if($i>0)
- (+{{$i}}
- )
- @elseif($i<0)
- ({{$i}})
- @endif </option>
- @endfor
- </select><span></span></a></li>
- @endif
- @endforeach
@endif
{{-- @if($partition)--}}
{{-- <li><a target="_blank" href="{{$partition}}">🎼 {{__('Partition')}}</a></li>--}}
@php
- $audioTracks=$song->getAudioTracks();
$simple=$song->hasSimpleChords();
@endphp
<section class="fromnotion notes">{!! $song->notes !!}</section>
@endif
<div class="credits">{{$song->credits}}</div>
- @if(count($audioTracks))
- <h2>💿 {{__('Audios')}}</h2>
- <ul class="files">
- @foreach($audioTracks as $audio)
- <li><a class="select_audio" data-id="player_{{$audio['i']}}_0">{{$audio['name']}}</a></li>
- @endforeach
- </ul>
- @endif
- @if(count($song->getFiles()))
- <h2>📄 {{__('Fichiers')}}</h2>
- <ul class="files">
- @foreach($song->getFiles() as $file)
- <li><a target="_blank" href="{{$file['url']}}">{{$file['name']}}.{{$file['ext']}}</a></li>
- @endforeach
- </ul>
- @endif
- </article>
- @if(count($audioTracks))
+
+ @foreach(\App\Http\Controllers\FrontController::$notionFileFields as $key=>$field)
+ @if($song->get($key,null))
+ <h2>{{$field['cat']}}</h2>
+ <ul class="files">
+ @foreach($song->get($key) as $file)
+ <li>
+ @if($file['audio'])
+ <a class="select_audio" data-id="player_{{$file['audio']}}_0">🎵 {{$file['name']}}</a>
+ @else
+ <a target="_blank" href="{{$file['url']}}">🗒️ {{$file['name']}}</a>
+ @endif
+ </li>
+
+ @endforeach
+ </ul>
+ @endif
+ @endforeach
+
<div id="audioplayers">
- @foreach($audioTracks as $audio)
- <audio id="player_{{$audio['i']}}_0" controls loop>
- <source src="{{$audio['opturl']}}" type="audio/mp3"/>
- </audio>
+ @foreach(\App\Http\Controllers\FrontController::$notionFileFields as $key => $field)
+ @foreach($song->get($key, []) as $file)
+ @if($file['audio'])
+ @php
+ $hasAudio=true;
+ @endphp
+ <audio id="player_{{$file['audio']}}_0" controls loop>
+ <source src="{{$file['opturl']}}"/>
+ </audio>
+ @endif
+ @endforeach
@endforeach
</div>
- @endif
-@endsection
-@section('floating')
- @if(count($audioTracks))
- <a href="#" data-action="play">
- <svg x="0" y="0" width="124.512" height="124.512" aria-hidden="true">
- <use xlink:href="#play"/>
- </svg>
- </a>
- @endif
+ @endsection
+ @section('floating')
+ @if(isset($hasAudio) && $hasAudio)
+ <a href="#" data-action="play">
+ <svg x="0" y="0" width="124.512" height="124.512" aria-hidden="true">
+ <use xlink:href="#play"/>
+ </svg>
+ </a>
+ @endif
+ </article>
@endsection