Here I come with the second and last article of viddler series. If you are not aware about the previous article,you can take a look at that article and come back here after completing that article.
Let’s see flashback of the previous article first.
Flashback
Yesterday in previous article, we have seen the basic idea about Viddler and Viddler API.Also, We have covered how to record videos using viddler api.
In this article:
In this article, we will take step forward to viddler API.Here step by step,I will show how to play the recorded video using Viddler API.
Let’s look into the example to play Viddler API in PHP.
When I have recorded video and save that video,fetch the video_id
. You can get that code into previous article. So, Here using that video_id, we will get and play that video in our site.
Step 1:
First of all, create one file into that demo folder.For example. I am creating get_specific_video.php
file here.
Step 2:
Include phpviddler.php file, create viddler object using API key and authenticate user same as we had done in previous article:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | include '../phpviddler.php'; //Example to auth as you and get your videos include '../phpviddler.php'; //Create viddler object $v = new Viddler_V2('<API KEY>', TRUE); //key $auth = $v->viddler_users_auth(array( 'user' => '<username>', 'password' => '<password>' ) ); |
Step 3:
Next, get the your session id and validate session. Then call viddler_videos_getDetails
function with the video id returned when you save the video.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //Get your session id $session_id = (isset($auth['auth']['sessionid'])) ? $auth['auth']['sessionid'] : ''; //If no session id, print errors if (! empty($session_id)) { $videos = $v->viddler_videos_getDetails( array( 'video_id' => '<video_id>', // Returned Video_ID 'add_embed_code'=> 1, 'sessionid' => $auth['auth']['sessionid'] ) ); } echo $videos['video']['embed_code']; |
Here, You will ge the embed_code in response of viddler_videos_getDetails function. if video not found, you will get error code.
Conclusion
So now we have covered both how to record and how to play recorded video using viddler API. I hope you have enjoyed series articles about viddler API. It would be great if you share your thoughts below in comment.
If you have any query or question,tell us in the comment section :). Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.