JplayerPlayer.php in jPlayer 8.2
File
src/Plugin/AudioPlayer/JplayerPlayer.php
View source
<?php
namespace Drupal\audiofield\Plugin\AudioPlayer;
use Drupal\audiofield\AudioFieldPluginInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Url;
use Drupal\file\FileInterface;
class JplayerPlayer implements AudioFieldPluginInterface {
public function renderPlayer(FileInterface $file) {
$file_uri = $file
->getFileUri();
$url = Url::fromUri(file_create_url($file_uri));
$markup = "<p>I am a jplayer audio player!</p><audio controls>\n <source src='" . $url
->toString() . "' type='audio/mpeg'>\n Your browser does not support the audio element.\n </audio>";
return [
'#markup' => Markup::create($markup),
];
}
}
Classes
Name |
Description |
JplayerPlayer |
@AudioPlayer (
id = "jplayer_player",
title =
Plugin annotation
@Translation("jPlayer mp3 player"),
file_types = {
"mp3",
},
description = "jPlayer audio player."
) |