Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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: PlayStrea$$anonymous$$gFullscreen$$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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

U3DXT Init failed, everything is setup 1 Answer

Using MediaExporter to save to MP3 1 Answer

U3DXT IAP - prevent pending transactions from starting download after Init() 1 Answer

u3dxt causing failed validation 2 Answers

Has U3DXT been abandoned? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges