Reputation: 171
when i upload video to vimeo then i get the vimeo video link i can not play it on flutter video player so i tried to convert this link to mp4 using
**api.vimeo.com/{id}/config**
but it stopped to return video links this week , tried to contact vimeo but they send automatic reply so after search i used another way from api vimeo
**https://api.vimeo.com/videos/{id}**
but same problem sometimes mp4 link not returned from vimeo video links
so i need flutter video player its able to play video using vimeo video link directly or any way to get mp4 link to be able to run video on player
`
public function mp4_link($id)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.vimeo.com/videos/' . $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer 111111111111111111',
),
));
$response = curl_exec($curl);
$response = (array) json_decode($response);
curl_close($curl);
if (!isset($response['files'])) {
$response = Http::get("https://player.vimeo.com/video/$id/config");
$response = (array) json_decode($response);
}
$response = [
'pictures' => $response['pictures'] ?? $response['video']->thumbs ?? [],
'duration' => $response['duration'] ?? 0,
'files' => $response['files'] ?? $response['request']->files->progressive ?? []
];
return $response;
}
`
Upvotes: 1
Views: 1293
Reputation: 206
There are several packages that can play vimeo videos in pub.dev. You can search and take a pick. But here are some, pod_player plays both YouTube and vimeo; vimeo_player_flutter ;
Upvotes: 1