Let's get the ID information required to play with video links from popular video sites (Youtube, Google Drive, Facebook, Vimeo, Dailymotion, Ok.ru, Twitch) and create an embed code so that you can use videos wherever you want.
Let's take a look at our getVideoID function, which I prepared directly, without further ado.
The function is very simple to use, we send the video link that we have assigned to our $link variable into the getVideoID function, and it gives us the necessary ID information and which site it belongs to as array output.
You can use the videoID given by the function in your own player or embed code or save it for later use.
Now let's prepare a playerVideo function suitable for the output of our getVideoID function.
function playVideo($params=[]){
$data=[];
$videoID = $params["videoID"];
$videoType = $params["videoType"];
$isVideo = $params["isVideo"];
if(!$isVideo){
$data["error"]= "Not found video";
}
if(empty($videoID)){
$data["error"]= "Not found video id";
}
if(!isset($data["error"])){
switch($videoType){
case "youtube":
$data["ok"]='';
break;
case "google":
$data["ok"]='';
break;
case "vimeo":
$data["ok"]='';
break;
case "mp4":
$data["ok"]='';
break;
case "daily":
$data["ok"]='';
break;
case "ok":
$data["ok"]='';
break;
case "twitch_videos":
$link = 'https://player.twitch.tv/?video='.$videoID;
$data["ok"]='
Let's look at its use together again.
$link="https://www.youtube.com/watch?v=O8CCJKzj4BM";
$video=getVideoID($link);
$player=playVideo($video);
print_r($player);
/*
Ekran çıktısı aşağıdaki gibidir
Örnek başarılı çıktısı:
Array
(
[ok] =>
)
Örnek hata çıktısı:
Array
(
[error] => Not found video id
)
*/
If you get stuck, do not hesitate to ask. The sites that come to my mind are this for now, you can specify in the comments if you say anything on this site.
Vermiş olduğum sitede arama yaptığımda bulduğum video linklerinin başına otomatik http://cros9.yayin.com.tr/ ekleyecek şekilde nasıl bir kod kullanabilirim