So in the project ive been working on i use the youtube API to add a video to a chromeless player (got custom buttons, everything works no problems).
It loads the youtube id which it gets from the database (Codeigniter, PHP).
But what i would like to see is: instead of loading 1 video, id like to add all the videos i get from the database in the cue of that one player.
So only one screen, first video retrieved from dbase gets played first, when its done second get loaded preferably also looped. Is there any way i can achieve this?
My first guess would be to save the array with youtube id's somewhere and on state change (when the 'video stop'-event gets fired) load the next id from the array. Havent tried this yet because id prefer if the cue gets just gets filled on the init, so it doesnt have to load after a video has been ended. Is This possible?
First, you must use Youtube API version 2 to activate newly statechange function.
This is the code for you:
var video_list = [
'21OH0wlkfbc',
'InZNBcJTmWs',
'iIzqYiRo01E',
'ZYmADPVEqU4'
];
var video_current = 0;
function onYouTubePlayerReady( ) {
var o = document.getElementById( 'ytplayer2_object' );
if( o ) {
o.addEventListener( "onStateChange", "ytplayer_statechange" );
}
}
function ytplayer_statechange( state ) {
// 0 => video ended
if ( state == 0 ) {
video_current++;
video_current %= video_list.length;
ytplayer_loadvideo(video_list[ video_current ]);
}
}
Related
I would like to include a video into a website. I need no help with that. But for improving the loading time, I would like to check the internet speed of the user with pure php and then decided to load the video immediately if the internet speed is fast enough and it takes maximum 2 seconds to download that video. else I would like to show an image and give the user to load the video after the rest of the page is already shown.
For giving you an idea what it should look like hava look at this page: https://rocketlabusa.com/
I do already have some code and need just some help with getting the internet speed. I'm able to develop the rest on my own.
Thanks!
That's my code:
<?php
define ( "urlToVideo", "someVideo.mp4" );
define ( "sizeOfMovieInBytes", filesize ( urlToVideo ) );
define ( "speedOfInternetConnectionInBytesPerSecond", 1 ); /* this is what I need */
if (sizeOfMovieInBytes / speedOfInternetConnectionInBytesPerSecond > 2) { // if it takes more than 2 Seconds to load the movie
/*
* a image should be shown and a play button for enabling the user to load the video after the rest of the website has loaded
*/
} else { // if it takes 2 seconds or less
/*
* the video should be loaded immediately and the image and played immediately
*/
}
?>
I can't import data table from the site which contain stock data. I did in MS Excel 2007; Data > Get External Data > From Web > Import as usual but there have no return from sites. When I tried to grab data table from the site its shown a small window massage (screenshot), I think the process redirecting to another link; but ultimate result is zero. I think the page is script protected.
Redirecting massage: "Opening: 'http://www.dsebd.org/latest_share_price_all.php"
Please advice me how could I download ( import) data from such site in my Excel Workbook.
The site original link: http://www.dsebd.org/latest_share_price_scroll_l.php [I want to download data from here]
Thanks in Advance for any support.
It's not problem with Excel.
Website is using iframe-->and denying access to request...
Look for site code by pressing F12. Did it ever worked for you before
The following code will place each trading code, LTP, change and % change on a separate line in the active worksheet.
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://www.dsebd.org/latest_share_price_scroll_l.php"
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
If you use F12 to look at the source code, you'll notice that each stock and it's associated data is bracketed by a tagname (in this case "a"). Use this to collect the data for each stock and place the data for all stocks in "Results". Step through "Results" and place each stock on a separate line. Use the replace function to remove a line break so the data appears on 1 line.
Set Results = IE.document.getElementsByTagname("table")(0).getElementsByTagname("a")
x = Results.Length
For y = 0 To x - 1
gg = Results(y).innertext
gg = Replace(gg, Chr(10), "", 1, -1, vbTextCompare)
ActiveCell = gg
ActiveCell.Offset(1,0).Select
Next
Press A1 cell, then data-> http://www.dsebd.org/latest_share_price_scroll_l.php-> click first arrow-> import->ok .....eureka
on cell E1 you will see ur desired thing
I'm confident about posting multiple photos to a fan page album through a common batch request with PHP, and I also know how to use che "no_story" command to hide the wall posts showing each image just uploaded. What I need to know is if it's possible to show an unique wall post on the fan page showing the whole upload, like the standard Facebook behavior when you upload more pictures using the web interface, and not one post for each photos.
This is the closest I have got:
$attachment = array
(
'access_token'=>$fanPageAccessToken,
'object_id' => $AlbumId,
'message' => $AlbumDesc,
'link' =>$AlbumLink
);
$result = $facebook->api($fanPageId.'/links/','post',$attachment);
}
I get the variables by querying the albums associated with the fanpage:
$fanPageAlbums = $facebook->api($fanPageId . '/albums/');
foreach ($this->fanPageAlbums['data'] as $fanPageAlbum) {
if ($albumId == $fanPageAlbum['id']) {
$albumLink = $fanPageAlbum['link'];
$albumDesc = $fanPageAlbum['description'];
break;
}
}
The key thing is your are posting to the links part of the graph, not the feed.
This works in that it will produce one big picture and three thumbs below it, as you would expect. However, it doesn't appear on the feeds of friends properly.
I've been struggling with this for ages, and the above is the closest I have got to mimicing exactly the facebook behavior. If you get any further please let me know!
I've recently started developing a portfolio website which I would like to link to my wordpress blog using simplepie. It's been quite a smooth process so far - loading names and descriptions of posts, and linking them to the full post was quite easy. However, I would like the option to render the posts in my own website as well. Getting the full content of a given post is simple, but what I would like to do is provide a list of recent posts which link to a php page on my portfolio website that takes a GET variable of some sort to identify the post, so that I can render the full content there.
That's where I've run into problems - there doesn't seem to be any way to look up a post according to a specific id or name or similar. Is there any way I can pull some unique identifier from a post object on one page, then pass the identifier to another page and look up the specific post there? If that's impossible, is there any way for me to simply pass the entire post object, or temporarily store it somewhere so it can be used by the other page?
Thank you for your time.
I stumbled across your question looking for something else about simplepie. But I do work with an identifier while using simplepie. So this seems to be the answer to your question:
My getFeedPosts-function in PHP looks like this:
public function getFeedPosts($numberPosts = null) {
$feed = new SimplePie(); // default options
$feed->set_feed_url('http://yourname.blogspot.com'); // Set the feed
$feed->enable_cache(true); /* Enable caching */
$feed->set_cache_duration(1800); /* seconds to cache the feed */
$feed->init(); // Run SimplePie.
$feed->handle_content_type();
$allFeeds = array();
$number = $numberPosts>0 ? $numberPosts : 0;
foreach ($feed->get_items(0, $number) as $item) {
$singleFeed = array(
'author'=>$item->get_author(),
'categories'=>$item->get_categories(),
'copyright'=>$item->get_copyright(),
'content'=>$item->get_content(),
'date'=>$item->get_date("d.m.Y H:i"),
'description'=>$item->get_description(),
'id'=>$item->get_id(),
'latitude'=>$item->get_latitude(),
'longitude'=>$item->get_longitude(),
'permalink'=>$item->get_permalink(),
'title'=>$item->get_title()
);
array_push($allFeeds, $singleFeed);
}
$feed = null;
return json_encode($allFeeds);
}
As you can see, I build a associative array and return it as JSON what makes it really easy using jQuery and ajax (in my case) on the client side.
The 'id' is a unique identifier of every post in my blog. So this is the key to identify the same post also in another function/on another page. You just have to iterate the posts and compare this id. As far as I can see, there is no get_item($ID)-function. There is an get_item($key)-function but it is also just taking out a specific post from the list of all posts by the array-position (which is nearly the same way I suggest).
i'm trying to get all the images from a facebook group using facebook API
i have a problem i can't get all the photos using
$facebook->api_client->call_method('Photos.get', array('subj_id' => $uid));
http://wiki.developers.facebook.com/index.php/Photos.get
what i'm using now is the method
$albums = $facebook->api_client->photos_getAlbums($uid, NULL);
http://wiki.developers.facebook.com/index.php/Photos.getAlbums
and then loop for ever album on
$facebook->api_client->call_method('Photos.get', array('subj_id' => $uid));
then i add every new array results to my big array
$big_array = array_merge($big_array,$result_array_from_that_call);
2 problems occurs here :
1- sometimes this calls fails - i think because of too many calls per second -
2- the request takes a v.long time to process
is there a better way to do that?
Thanks guys
Cheers
EDIT :: i tried to get all the images using
$facebook->api_client->call_method('Photos.get', array('subj_id' => $uid));
and using $uid as the group ID but that's doesn't work " don't know why maybe because all the images is listed in groups "
the best solution was to output the album and then the user clicks on an album and check the images inside it