• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Gamrek · Jun 30, 2014 at 11:16 AM · u3dxt

U3DXT - Choose Video from Photos App

Hi,

I am new to use this plugin, may I ask if it is possible to:

Choose a existing video from Photos App using its native UI?

If so, is it OK to give me some sample code for me to follow? Or where can I start?

In additional to this, is it possible to be able to play the chosen video on a plane or on a cube?

Thank you. Derek

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by u3dxt · Jul 01, 2014 at 05:54 PM

Hi, to get videos from the native UI, you can use the following. BTW, this is copied from our high-level API: https://github.com/vitapoly/u3dxt/blob/master/src/highlevel/core/GUI/GUIXT.cs, except added one line to specify "public.movie" as the media type. There is a TODO in _OnPickedMedia() for you to do something with the URL of the movie file. However, our plugin does not allow you to import that into a texture.

 private static UIImagePickerController _picker;
 private static UIPopoverController _popover;
 
 public static void ShowImagePicker(UIImagePickerControllerSourceType source = UIImagePickerControllerSourceType.PhotoLibrary,
                                    UIImagePickerControllerCameraDevice cameraDevice = UIImagePickerControllerCameraDevice.Rear) {
     _picker = new UIImagePickerController();
     _picker.mediaTypes = new Object[] { "public.movie" }; // pick only movies
     _picker.sourceType = source;
     _picker.DidFinishPickingMediaWithInfo += _OnPickedMedia;
     _picker.DidCancel += _OnCancelledPick;
     if (source == UIImagePickerControllerSourceType.Camera)
         _picker.cameraDevice = cameraDevice;
 
     var rootVc = UIApplication.deviceRootViewController;
     if (CoreXT.IsiPad && (source != UIImagePickerControllerSourceType.Camera)) {
         if (_popover == null) {
             _popover = new UIPopoverController(_picker);
             _popover.DidDismiss += _OnCancelledPick;
             _popover.shouldDismissHandler = _ShouldDismissPopover;
         } else {
             _popover.contentViewController = _picker;
         }
 
         var rect = rootVc.view.bounds;
         rect.x = rect.width / 2;
         rect.y = rect.height;
         rect.width = 1;
         rect.height = 1;
         _popover.PresentPopover(
             rect,
             rootVc.view,
             UIPopoverArrowDirection.Down,
             true);
     } else {
         rootVc.PresentViewController(_picker, true, null);
     }
 }
 
 private static void _OnPickedMedia(object sender, UIImagePickerController.DidFinishPickingMediaWithInfoEventArgs e) {
     if (_popover != null)
         _popover.DismissPopover(true);
     else if (_picker.parentViewController != null)
         _picker.parentViewController.DismissViewController(true, null);
     else
         UIApplication.deviceRootViewController.DismissViewController(true, null);
 
     _picker = null;
     _popover = null;
 
     NSURL url = null;
     if (e.info.ContainsKey(UIImagePickerController.ReferenceURL))
         url = e.info[UIImagePickerController.ReferenceURL] as NSURL;
     //TODO: do something with the URL    
 }
 
 private static void _OnCancelledPick(object sender, EventArgs e) {
     if (_popover != null) {
 //                _popover.DismissPopover(true);
     } else if (_picker.parentViewController != null) {
         _picker.parentViewController.DismissViewController(true, null);
     } else {
         UIApplication.deviceRootViewController.DismissViewController(true, null);
     }
 
     _picker = null;
     _popover = null;
 }
 
 private static bool _ShouldDismissPopover(UIPopoverController popover) {
     return true;
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gamrek · Jul 02, 2014 at 10:00 AM 0
Share

Hello,

Thank you for your answer. I have tried your code and it works. But I have more question regarding this.

  1. The url is a reference url of the video, is it possible to know its actual location, its path?

  2. I tried to use the url directly by putting: PlayStreamingFullscreen$$anonymous$$ovie(url.tostring(), true, U3DXT.iOS.Native.$$anonymous$$ediaPlayer.$$anonymous$$P$$anonymous$$ovieControlStyle.Default) But it doesn't play the video. What have I done wrong in here?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How Do I Get Support for U3DXT's iOS SDK Plugin? 6 Answers

How do I get ReportAchievement to notify the user? 1 Answer

Launching the appstore via u3dxt 1 Answer

U3DXT Webview GUILayout.Button Problem 0 Answers

iOS 8 location services not working 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges