objective c - YouTube iframe is too slow in iOS app -
i using youtube api in ios application , problem loads slow on iphone, on ios simulator works perfectly.
i tried on different networks , on different iphones , same. on every network simulator works lot better.
i'm using ytplayerview-iframe-player.html
, ytplayerview
.
so, question can load faster or can start playing song after loads?
there no way speed network. can 2 things improve user experience: hide player until video loads, , start playing video possible (autoplay).
add autoplay key playervars dictionary:
nsdictionary *playervars = @{ @"playsinline" : @1, @"autoplay" : @1, // <- here @"showinfo" : @0, @"rel" : @0, @"modestbranding" : @1, }; [self.playerview loadwithvideoid:videoid playervars:playervars]; // hide player view until ready self.playerview.hidden = yes;
unhide player when ready:
// unhide , play - (void)playerviewdidbecomeready:(ytplayerview *)playerview { self.playerview.hidden = no; }
or
- (void)playerview:(ytplayerview *)playerview didchangetostate:(ytplayerstate)state { if (state == kytplayerstateplaying) { self.playerview.hidden = no; } }
Comments
Post a Comment