Методы: bulkinfo | info | create | upload | update | delete
bulkinfo
Получение информации о медиафайлах по одному или нескольким кодам
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- Array code[] (Список кодов медиафайлов)
Выходные параметры
- String Code (Код медиафайла)
- String Title (Название медиафайла)
- String Type (Тип медиафайла)
- Integer Width (Ширина видео)
- Integer Height (Высота видео)
- Integer FileSize (Размер исходного файла)
- String FileName (Исходное имя файла)
- String MediaStatus (Статус обработки медиафайла)
- Integer Duration (Длительность видео в секундах)
- String Description (Описание медиафайла)
- String CreatedAt (Дата создания)
- String PlayerLink (Ссылка на плеер)
- String PlayerCode (HTML-код плеера)
- Object Poster (Информация о постере: Code, Width, Height, Url)
- Object Timeline - PreviewsVtt (VTT-файл для кадров временной шкалы)
Пример запроса:
https://boomstream.com/api/media/bulkinfo?apikey=[API_KEY]&code[]=[MEDIA_CODE_1]&code[]=[MEDIA_CODE_2]&code[]=[MEDIA_CODE_N]
Пример ответа:
<Response>
<Items>
<Item>
<Code>xxxxxxxx</Code>
<Title>test - 2024-03-13 16:45:09</Title>
<Type>video</Type>
<Width>1280</Width>
<Height>720</Height>
<FileSize>1000000</FileSize>
<FileName>test.mp4</FileName>
<MediaStatus>Done</MediaStatus>
<Duration>6</Duration>
<Description/>
<CreatedAt>2024-03-13 16:45:09</CreatedAt>
<PlayerLink>https://play.boomstream.com/xxxxxxxx</PlayerLink>
<PlayerCode><iframe width="{{width}}" height="{{height}}" src="https://play.boomstream.com/xxxxxxxx" frameborder="0" scrolling="no" allowfullscreen=""></iframe></PlayerCode>
<Poster>
<Code>h7sZjLB9-a1</Code>
<Width>1280</Width>
<Height>720</Height>
<Url>https://bs.boomstream.com/adaptive/xxxxxxxx.jpg</Url>
</Poster>
<Timeline>
<PreviewsVtt>https://bs.boomstream.com/adaptive/xxxxxxxx/playlist.vtt</PreviewsVtt>
</Timeline>
</Item>
</Items>
<Status>Success</Status>
</Response>
info
Получение дополнительной информации о медиафайле по его коду
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- String code (Код медиафайла)
Выходные параметры
- String Title (Название медиафайла)
- String Code (Код медиафайла)
- String Type (Тип медиафайла)
- Integer Width (Ширина видео)
- Integer Height (Высота видео)
- Integer FileSize (Размер исходного файла)
- String FileName (Исходное имя файла)
- String MediaStatus (Статус обработки медиафайла)
- Integer Duration (Длительность видео в секундах)
- String PlayerCode (HTML-код плеера)
- String DownloadLink (Ссылка для скачивания исходного файла)
- Object Poster (Информация о постере: Code, Width, Height, Url)
- Array Transcodes (Список транскодированных версий)
- Array Screenshots (Список скриншотов)
- Object Timeline (Информация о временной шкале: Sprites, FullSprite, Previews, PreviewsVtt)
Пример запроса:
https://boomstream.com/api/media/info?apikey=[API_KEY]&code=[MEDIA_CODE]
Пример ответа:
<Response>
<Title>demovideo.avi</Title>
<Code>xxxxxx</Code>
<Type>video</Type>
<Width>1600</Width>
<Height>900</Height>
<FileSize>1000000</FileSize>
<FileName>test.mp4</FileName>
<MediaStatus>Done</MediaStatus>
<Duration>61</Duration>
<PlayerCode>&lt;iframe width=&quot;{{width}}&quot;
height=&quot;{{height}}&quot;
src=&quot;https://play.boomstream.com/xxxxxx&quot;
frameborder=&quot;0&quot;
scrolling=&quot;no&quot;
allowfullscreen&gt;&lt;/iframe&gt;
</PlayerCode>
<DownloadLink>
https://bs.boomstream.com/balancer/hash:abd6c666f029e065e4aedb44e5c5f176/xxxxxx.orig
</DownloadLink>
<Poster>
<Code>xxxxxx-a1</Code>
<Width>1600</Width>
<Height>900</Height>
<Url>https://bs.boomstream.com/balancer/xxxxxx-a1.jpg</Url>
</Poster>
<Transcodes>
<Item>
<Code>xxxxxx-xxxxxx</Code>
<Title>1080p</Title>
<Width>1600</Width>
<Height>900</Height>
<PseudoMP4>https://bs.boomstream.com/balancer/xxxxxx-xxxxxx.mp4</PseudoMP4>
<AppleHLS>https://bs.boomstream.com/balancer/xxxxxx-xxxxxx/playlist.m3u8</AppleHLS>
</Item>
</Transcodes>
<Adaptive/>
<Screenshots>
<Item>
<Code>xxxxxx-a21</Code>
<Width>1600</Width>
<Height>900</Height>
<Url>https://bs.boomstream.com/balancer/xxxxxx-a21.jpg</Url>
</Item>
</Screenshots>
<Timeline>
<Sprites>
<Item>
<Code>xxxxxxxx-s1</Code>
<Width>800</Width>
<Height>450</Height>
<FrameCount>25</FrameCount>
<Url>https://bs.boomstream.com/balancer/xxxxxxxx-s1.webp</Url>
</Item>
</Sprites>
<FullSprite>
<Code>xxxxxxxx-f</Code>
<Width>1600</Width>
<Height>630</Height>
<FrameCount>61</FrameCount>
<Url>https://bs.boomstream.com/balancer/xxxxxxxx-f.webp</Url>
</FullSprite>
<Previews>
<Item>
<Code>xxxxxxxx-t1</Code>
<Width>160</Width>
<Height>90</Height>
<TimePosition>0.00</TimePosition>
<SpriteURL>https://bs.boomstream.com/balancer/xxxxxxxx-s1.webp</SpriteURL>
<SpriteURLxywh>https://bs.boomstream.com/balancer/xxxxxxxx-s1.webp#xywh=0,0,160,90</SpriteURLxywh>
<SpritePosition>[0, 0, 160, 90]</SpritePosition>
</Item>
</Previews>
<PreviewsVtt>https://bs.boomstream.com/adaptive/xxxxxxxx/playlist.vtt</PreviewsVtt>
</Timeline>
<Status>Success</Status>
</Response>
create
Создание нового медиафайла
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- String title (Название медиафайла)
- String link (Ссылка на источник)
Необязательные параметры:
- String folderCode (Код папки)
Выходные параметры
- String Code (Код медиафайла)
Пример запроса:
https://boomstream.com/api/media/create?apikey=[API_KEY]&link=http://example.com/video.mp4&title=temp
Пример ответа:
<Response>
<Code>dNO6bnZE</Code>
<Status>Success</Status>
</Response>
upload
Загрузка нового медиафайла через HTML-форму
Шаг 1: Получение данных для формы загрузки
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- String title (Название медиафайла)
Необязательные параметры:
- String folderCode (Код папки)
Пример запроса:
https://boomstream.com/api/media/upload?apikey=[API_KEY]&title=temp
Пример ответа:
<Response>
<UploadUrl>
https://node.org/upload/hash:8d7cd/f1a05782f77aca5cc78647178110ac8a
</UploadUrl>
<ProgressBarUrl>
https://boomstream.com/api/media/progressbar
</ProgressBarUrl>
<Status>Success</Status>
</Response>
Шаг 2: Создание страницы загрузки
Создайте страницу, например upload.php. Добавьте тег iframe в тело страницы и вставьте параметр UploadUrl.
Пример кода:
<body>
<iframe src="https://localhost/iframe.php?link=<UploadUrl>">
</body>
Шаг 3: Создание страницы для iframe
Создайте страницу для кнопки «Обзор», которая будет отображаться во фрейме — iframe.php.
Пример кода:
<script type="text/javascript">
function submitForm() {
parent.runUpload();
$('#form1').submit();
}
</script>
<form action="<UploadUrl>" method="POST" enctype="multipart/form-data" id="form1">
<input type="file" name="file" onchange="submitForm()">
</form>
Шаг 4: Создание прокси-скрипта для отслеживания прогресса
Создайте прокси-скрипт для получения статуса загрузки — progressbar.php.
Пример кода:
<?php
$progressBarUrl = (isset($_GET['progressBarUrl'])) ? $_GET['progressBarUrl'] : '';
echo @file_get_contents($progressBarUrl . '&format=json');
?>
Шаг 5: Добавление JavaScript для отслеживания прогресса
Добавьте JavaScript-код на страницу upload.php, который будет отправлять запросы к progressbar.php каждую секунду.
Пример кода:
<script type="text/javascript">
var refreshIntervalId;
var refresh = 1000;
function runUpload() {
$('#form1').submit();
refreshIntervalId = setTimeout('getPercent()', refresh);
}
function getPercent(){
$.get('https://localhost/progressbar.php', {progressBarUrl:"<progressBarUrl>"}, function(data){
if(data.Action=='done') {
console.log("DONE");
} else {
refreshIntervalId = setTimeout('getPercent()', refresh);
}
},'json');
}
</script>
Ответ в процессе загрузки:
<Response>
<Percent>10</Percent>
<Action>work</Action>
...
</Response>
Ответ при завершении загрузки:
<Response>
<Action>done</Action>
<Code>dsadas13</Code>
...
</Response>
update
Обновление параметров медиафайла или перезагрузка исходного файла
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- String code (Код медиафайла)
Необязательные параметры:
- String title (Название медиафайла)
- String link (Ссылка на источник)
Пример запроса:
https://boomstream.com/api/media/update?apikey=[API_KEY]&code=[MEDIA_CODE]&link=http://example.com/video.mp4&title=test2
Пример ответа:
<Response>
<Status>Success</Status>
</Response>
delete
Удаление медиафайла
Входные параметры
Обязательные параметры:
- String apikey (API ключ проекта)
- String code (Код медиафайла)
Пример запроса:
https://boomstream.com/api/media/delete?apikey=[API_KEY]&code=[MEDIA_CODE]
Пример ответа:
<Response>
<Status>Success</Status>
</Response>
