integration jaudio-player
[mw_sourceml] / app / out / default / views / sources / source / player.php
diff --git a/app/out/default/views/sources/source/player.php b/app/out/default/views/sources/source/player.php
new file mode 100644 (file)
index 0000000..965618a
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+  $documents = $source["reference"] ? $source["reference"]["documents"] : $source["documents"];
+  if($documents) :
+  $mw_out = $this->helper("mw_helper_out");
+  $audio_files = array();
+  foreach($documents as $id_document => $document){
+    $ext = "";
+    if(($k = strrpos($document["url"], ".")) !== false) $ext = strtolower(substr($document["url"], $k + 1));
+    switch($ext){
+      case "ogg":
+        $audio_files[] = array(
+          "type" => "audio/ogg",
+          "src" => $document["url"]
+        );
+        break;
+      case "mp3":
+        $audio_files[] = array(
+          "type" => "audio/mp3",
+          "src" => $document["url"]
+        );
+        break;
+    }
+  }
+ if($audio_files) :
+
+?>
+<audio id="audio_<?php echo $source["id"] ?>" preload="none">
+  <?php foreach($audio_files as $audio_file) : ?>
+  <source src="<?php echo $audio_file["src"] ?>" type="<?php echo $audio_file["type"] ?>" />
+  <?php endforeach; ?>
+  <?php
+
+    $waveform_file = $this->path("content")."waveforms/".$source["id"].".png";
+    if(file_exists($waveform_file)) :
+
+  ?>
+  <img class="waveform" src="<?php echo $waveform_file; ?>" alt="waveform" />
+  <?php endif; ?>
+</audio>
+<?php endif; endif; ?>