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 blueteak · Jan 16, 2014 at 02:35 AM · iosu3dxt

MPMediaPickerController Usage

I have been unable to correctly get the Music Selection to show up. What I ultimately want to do, is to be able to pick a number of songs, and then return the selected song data to use like a playlist.

I was unable to get the following code to work:

 public MPMediaPickerController Picker
 
 void OnClick()
 {
 Picker = new MPMediaPickerController();
 Picker.allowsPickingMultipleItems = true;
 Picker.PresentViewController(Picker,true,null)
 }

The problem comes from the PresentViewController, and Objective-C examples show a difference when using "self" to present the view controller. I tried using "this.Picker" but was unnable to get it to work. The crash when OnClick() is fired is something along the lines of "Tried to present modal view on itself".

I also read that another problem is calling the picker over unity, and it simply not showing up; this might have also been the case as I tried Picker.PresentViewController(Picker.presentedViewController,true,null) and Xcode had some log text show up, but nothing happened on the phone.

If anyone knows how to fix it (and also how to use the MPMediaPickerControllerDelegate class to return the picked songs) that would be amazing.

Thanks,

Blueteak

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

2 Replies

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

Answer by u3dxt · Jan 16, 2014 at 07:21 PM

Tell the rootViewController to present the MPMediaPickerController. A few minor releases ago, we auto wrapped event handling so you don't need to create Delegate classes anymore. Check out this code block for an example:

 using UnityEngine;
 using System.Collections;
 using U3DXT.iOS.Native.MediaPlayer;
 using U3DXT.iOS.Native.UIKit;
 
 public class MediaPicker : MonoBehaviour {
 
     void OnGUI()
     {
         if ( GUI.Button(new Rect(100,100,300,400), "Pick Songs") ){
             PickSongs();
         }
     }
 
     void PickSongs()
     {
         MPMediaPickerController mediaPicker = new MPMediaPickerController();
         mediaPicker.allowsPickingMultipleItems = true;
         mediaPicker.DidPickMediaItems += HandleDidPickMediaItems;
         // add it to the root view controller
         UIApplication.deviceRootViewController.PresentViewController(mediaPicker, true, null);
     }
 
     void HandleDidPickMediaItems (object sender, MPMediaPickerController.DidPickMediaItemsEventArgs e)
     {
         (sender as MPMediaPickerController).DismissViewController(true, null);
 
         Debug.Log (e.mediaItemCollection.count);
     }
 }
Comment
Add comment · Show 2 · 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 blueteak · Jan 16, 2014 at 10:19 PM 0
Share

Thanks; Worked perfectly!

avatar image u3dxt · Feb 14, 2014 at 06:26 PM 0
Share

BTW, if you are only interested in specific types, video, music video, songs, etc. You can specify the $$anonymous$$P$$anonymous$$ediaTypes when creating the $$anonymous$$P$$anonymous$$ediaPickerController.

http://u3dxt.com/api/?topic=html/T_U3DXT_iOS_Native_$$anonymous$$ediaPlayer_$$anonymous$$P$$anonymous$$ediaType.htm

avatar image
0

Answer by eclyptik · Jun 09, 2014 at 11:01 PM

Hi can we continue this post please... How retrieve an array with e.mediaItemCollection. for have an Audioclip array and can Play the files in Unity ?

thanks ,

Eclyptik

Comment
Add comment · 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

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

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I use Unity network system with Multipeer connectivity ? 0 Answers

Application crashes 2 Answers

Launching the appstore via u3dxt 1 Answer

How to get local currency u3dxt 1 Answer

How Do I Get Support for U3DXT's iOS SDK Plugin? 6 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