ASCIInema Player integration nc16

Hi, i am starting a project for an app that is based on the pdf viewer.
the project should allow native support for “.cast” files to be viewed in nextcloud like opening pds currently. ( looks like this:

the javascript library i want to use is

it should trigger whenever you want to open a cast file via webapp or mobile app.

the usage of the player is fairly simple and looks something like this:

  <link rel="stylesheet" type="text/css" href="/asciinema-player.css" />
  <asciinema-player src="/demo.cast"></asciinema-player>
  <script src="/asciinema-player.js"></script>

i was able to generate a git repository for the project:
it is forked from the nextcloud/files_pdfviewer.

it just started but if somebody wants to join the team feel free to contribute.


what i found so far is that i have to register a mime type for .cast files like:

namespace OCA\CastViewer\Migration;

use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\ILogger;

class RegisterMimeType implements IRepairStep {
    protected $logger;
    private $customMimetypeMapping;

public function __construct(ILogger $logger) {
    $this->logger = $logger;

    // Define the custom mimetype mapping
    $this->customMimetypeMapping = array(
        "cast" => array("application/cast")

public function getName() {
    return 'Register MIME type for "application/cast"';

private function registerForExistingFiles() {
    $mimetypeMapping = $this->customMimetypeMapping;
    $mimeTypeLoader = \OC::$server->getMimeTypeLoader();

    foreach($mimetypeMapping as $mimetypeKey => $mimetypeValues) {
        foreach($mimetypeValues as $mimetypeValue) {
            $mimeId = $mimeTypeLoader->getId($mimetypeValue);
            $mimeTypeLoader->updateFilecache($mimetypeKey, $mimeId);

private function registerForNewFiles() {
    $mimetypeMapping = $this->customMimetypeMapping;
    $mimetypeMappingFile = \OC::$configDir . 'mimetypemapping.json';

    if (file_exists($mimetypeMappingFile)) {
        $existingMimetypeMapping = json_decode(file_get_contents($mimetypeMappingFile), true);
        $mimetypeMapping = array_merge($existingMimetypeMapping, $mimetypeMapping);

    file_put_contents($mimetypeMappingFile, json_encode($mimetypeMapping, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));

public function run(IOutput $output) {
    $this->logger->info('Registering the mimetype...');

    // Register the mime type for existing files

    // Register the mime type for new files

    $this->logger->info('The mimetype was successfully registered.');

and to register a default action like:

name: ‘audio’,
displayName: ‘audio’,
mime: mime,
permissions: OC.PERMISSION_READ,
icon: icon_url,
actionHandler: playFile
OCA.Files.fileActions.setDefault(mime, ‘audio’);

But how do i tell my template php which file to open?

It’s definitely a good idea for an app!

It would be nice to have the player also for the public shares.

Thank you; I am looking forward to see it ready!