joinbox/mux 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joinbox/mux

最新稳定版本:v0.1

Composer 安装命令:

composer require joinbox/mux

包简介

README 文档

README

This module provides a service for generating Mux Assets API clients in a Drupal project. It provides custom functions for uploading videos to Mux and retrieving playback ids, as well as polling the Mux API for an assets status.

Installation

Usage

To use this module, simply call the mux.assets_api service:

$assetsApi = \Drupal::service('mux.assets_api');

This will return an instance of MuxPhp\Api\AssetsApi, authenticated with the Mux API username and password from the site's configuration.

You can then use this client to interact with the Mux Assets API, for example:

$asset = $assetsApi->getAsset($assetId);

Please refer to the Mux Assets API documentation for more information on the available methods and their usage.

Custom Functions

  • uploadAndRetrieveAsset($videoUrl): ?Asset: This function takes a video URL as an argument and uploads the video to Mux as a new asset. If the upload is successful, it returns the asset.

  • getPlaybackIdFromAsset(?Asset $asset): This function takes an asset as an argument and retrieves the playback id from it.

  • pollAssetStatus(string $assetId): This function takes an asset id as an argument and polls the Mux API for the asset's status every second until the status is 'ready'. It cancels the polling if the status is 'errored'.

These functions provide a simple and effective way to interact with the Mux Assets API, allowing for video upload and retrieval of playback ids. They also handle error scenarios, ensuring that the application can gracefully handle any issues that may occur during the interaction with the Mux API.

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-03-28