You are here

public function JplayerPlayer::renderPlayer in jPlayer 8.2

File

src/Plugin/AudioPlayer/JplayerPlayer.php, line 30
Contains \Drupal\audiofield\Plugin\AudioPlayer\DefaultMp3Player.

Class

JplayerPlayer
@AudioPlayer ( id = "jplayer_player", title = Plugin annotation @Translation("jPlayer mp3 player"), file_types = { "mp3", }, description = "jPlayer audio player." )

Namespace

Drupal\audiofield\Plugin\AudioPlayer

Code

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),
  ];
}