Sunday 7 July 2013

iYoutube Unity iOS Plugin


IYoutube is a light plugin for you to play youtube video thru unity control. By using the light plugin, you just have to pass in the youtube url and others required parameter. This plugin will play the video on the iOS Movie Player natively if you pass in the correct parameter.

========================
======= IMPORTANT =====
========================
For some reason, youtube have update their new API and old version of iYoutube plugin does not seem to work anymore. I have update the plugin recently and publish to Unity Asset Store, you may grab the plugin from the hyperlink. Thanks :-)

PS : It is working for both iOS and Android now!!!


===================
====== Donation =====
===================
1. You can also make donation for using this plugin. Thanks you.



==================
== Support Platform ==
==================
1. iOS (Universal)
2. Android (Phone and Tablet)
3. Unity minimum version 4.1.3


Note* : Inside package will have a DemoScene,  plugins and scripts folder. You can refer on how to use this function thru DemoScene or IYoutube unity script.
Any problem you encounter of integration plugin issue, please drop me an email (licco.wee@gmail.com)


=======================
== Static Method Provided ==
=======================
/// <summary>
/// Play the youtube video.
/// </summary>
/// <returns>
/// Return true if the video play successful.
/// </returns>
/// <param name="url">youtube url, example http://www.youtube.com/watch?v=yCKSxEgz2XI </param>
/// <param name="quality">few quality available for youtube video, such as (hd720, medium, small). Pass in the correct string for quality
/// you need to play </param>
public static bool PlayVideo(string url, string quality);


/// <summary>
/// Gets the youtube thumbnail URL by youtube video url. This allow you to load the thumbnail texture by using unity WWW.
/// </summary>
/// <returns>
/// Return for the youtube thumbnial url.
/// </returns>
/// <param name='url'>youtube url, example http://www.youtube.com/watch?v=yCKSxEgz2XI
/// </param>
/// <param name='size'>
/// Size of the thumbnail > (default, medium, high and max), 4 selection for the thumbnail size.
/// </param>
public static string GetYoutubeThumbnailURLByURL(string url, string size);


/// <summary>
/// Gets the youtube thumbnail image by byte data.
/// </summary>
/// <returns>
/// Return for the thumbnail image data.
/// </returns>
/// <param name='url'>youtube url, example http://www.youtube.com/watch?v=yCKSxEgz2XI
/// </param>
/// <param name='size'>
/// Size of the thumbnail > (default, medium, high and max), 4 selection for the thumbnail size.
/// </param>
public static byte[] GetYoutubeThumbnailQuick(string url, string size);

27 comments:

  1. Works very well. Nice and simple to use. And great support from the creator.

    ReplyDelete
  2. Hi, can you make a plugin that can play live video streaming on an interface inside the game?

    ReplyDelete
  3. Seems to have trouble on iOS 5 on iPod4. Works fine on iPad3 with iOS6. Any ideas?

    ReplyDelete
    Replies
    1. I think it has to do with an API change.

      https://developers.google.com/youtube/youtube-api-list

      Hopefully the developer of this plugin is aware of the issue.

      Delete
  4. I was using this with no issues 5-7 days ago. Today I cannot seem to get a single video to play. I think Youtube has made an API change.

    ReplyDelete
    Replies
    1. Thanks to Licco for the quick reply and fix for this plugin. Everything is working perfectly.

      Delete
    2. Is this fix included in the download. If not would it be possible it could be posted up for others to use. Thanks

      Delete
  5. I'm having the same problem that Justin. Is there a fix or something?

    ReplyDelete
  6. Please, I have to publish my App this thursday so I'm in a hurry!!

    ReplyDelete
  7. This is a great solution but it stopped working for me recently. Is there a fix available somewhere? Thanks in advance!

    ReplyDelete
  8. Hi! thank you for your post, I tried to make it work, but for some reason, I doesn´t, I used another YT video, because the one referred in the demo doesn´t exist any longer, so, using another video, I can´t see any video, you can see there´s internet activity, I used my iPhone through with internet shared from my iMac, where I can monitor any activity, but in the iPhone no video is displayed, the message I got is that the video failed loading, any advice?

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. Hi mini toro,

    Is it working for Android?
    The blog post says it does but the asset store says coming soon.

    Thanks for clarifying!

    -E

    ReplyDelete
    Replies
    1. Yes, it is working for both iOS and android platform now.

      Thanks for you support :-)

      Delete
  11. Is it possible to download videos from youtube or keep it in a cache for offline viewing somehow?

    ReplyDelete
    Replies
    1. Also, I suppose it is using youtube API, but regardless, do you happen to know what kind of restrictions there might be with playing videos from one channel and thousands of clients?

      I'm going to use videos heavily and I'm trying to balance out if it's worth it going with youtube or if we should just host videos for downloading. With the second we won't have good streaming, but at least if we fall into bandwidth issues we can deal with it and not simply get blocked by APIs.

      Delete
  12. Is it possible to stream a youtube video to a texture with this plugin?

    ReplyDelete
  13. Can you please answer the above question of whether the plugin plays the video natively within the game without having to go through an external video player?

    ReplyDelete
    Replies
    1. It plays the video natively, and that's a different question. It's a player external to unity, but not external to the native video players on your mobile platform (either iOS or Android).

      Delete
  14. Any methods for retrieving title and description?

    ReplyDelete
  15. The plugin iYoutube works perfectly on Android, but on iOS we always have the following error when trying to play a video (even with the latest version of the plugin) :
    [MPViewController initWithContentURL:]: unrecognized selector sent to instance 0x18114b60 ... any idea what it could be ?
    Uncaught exception: NSInvalidArgumentException: -[MPViewController initWithContentURL:]: unrecognized selector sent to instance 0x18114b60

    ReplyDelete
    Replies
    1. We have fixed it and upload a new binary to Unity Asset Store. We will try our best fix it as soon as possible and reflect to all of our users. :)

      Delete
  16. This comment has been removed by a blog administrator.

    ReplyDelete
  17. Plz does it have the functionality of getting an event like "video ended event"
    after the video has finished playing?
    Thank you for your reply.

    ReplyDelete
  18. Plz does it have the functionality of getting an event like "video ended event"
    after the video has finished playing?
    Thank you for your reply.

    ReplyDelete
  19. Does the plugin render the video on a texture in-game or just fullscreen?

    ReplyDelete