leela/video-api

从所有主要视频分享网站获取视频。支持YouTube、Dailymotion和Vimeo

0.2 2015-05-04 12:32 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:07:25 UTC


README

为YouTube、Vimeo和Dailymotion等视频网站提供的API

使用策略设计模式

首先,通过Composer安装此包。编辑您的项目composer.json文件以要求

"require": {
"leela/VideoApi": "0.1"
}

接下来,从终端更新Composer

composer update

这样就完成了!您可以开始使用了。

YouTube视频详情用法

<?php
$youtubeapi = new \Leela\VideoApi(new \Leela\Services\YouTubeService());
$youtubeapi->getVideoDetails('x2on26a');

Vimeo视频详情用法

<?php
$vimeoapi = new \Leela\VideoApi(new \Leela\Services\VimeoService());
$vimeoapi->getVideoDetails('x2on26a');

Dailymotion视频详情用法

<?php
$dailymotionapi = new \Leela\VideoApi(new \Leela\Services\DailyMotionService());
$dailymotionapi->getVideoDetails('x2on26a');

方法

1) getVideoDetails($videoId);

$videoId - Video Id of the youtube, Vimeo or the daily motion

Returns array of video details
array(
        'id' => $data->id,
        'title' => $data->title,
        'description' => $data->description,
        'thumbnail_small' => $data->thumbnail->sqDefault,
        'thumbnail_large' => $data->thumbnail->hqDefault,
        'duration' => $data->duration,
        'upload_date' => $data->uploaded,
        'like_count' => isset($data->likeCount) ? $data->likeCount : 0,
        'view_count' => isset($data->viewCount) ? $data->viewCount : 0,
        'comment_count' => isset($data->commentCount) ? $data->commentCount : 0,
        'uploader' => $data->uploader
        );

2)  getPlayer($videoId, $width, $height)
    $videoId  - Required (Video id of the youtube, Vimeo or the dailymotion)
    $width - Optional (width of the player)
    $height - Optional  (height of the player)

返回播放器的HTML数据

贡献者

Leela Narasimha Reddy - leela@leelag.com

问题和建议

请在此处报告任何错误或功能请求: https://github.com/leelanarasimha/VideoApi/issues