iOS MPMediaItem: Options as set in iTunes - ios

When loading MPMediaItems via the MPMediaLibrary (MediaPlayer Framework), I'm looking for a way to access the start, stop, and volume properties as they can be set in iTunes via right click on a song => Get Info => Options.
These properties are not properties of MPMediaItem, and I'm not (yet?) able to access them via AVAsset either.
When playing the MPMediaItem using the MPMusicPlayerController applicationMusicPlayer, it does play the track from the set start point. However I need to use AVAudioPlayer and would therefore like to find a way to fetch these settings programmatically.
Any help or hints would be much appreciated!

Related

Twilio video tracks differentiation

In my application i have a user that is simultaneously using two video tracks (screen sharing and a webcam). Firs when the user connects The webcam starts and then the screen sharing track gets added.
In the muddle of this session i need an ability to enable the user camera switching. I used this guide here to implement this feature: https://www.twilio.com/blog/2018/06/switching-cameras-twilio-video-chat.html
However when i do something like this:
const tracks = Array.from(localParticipant.videoTracks.values());
localParticipant.unpublishTracks(tracks);
localParticipant.publishTrack(localVideoTrack);
I unpublish both video tracks(screen sharing and camera) and only adding a camera track. Is there a way to add a property to the track(other than "kind") that will allow me to make this distinction?
Because right now the only way i can do it is tracking if the user has screen sharing enabled and re-connect both tracks in this case.
Twilio developer evangelist here.
All Tracks within Twilio Video have a name property which is the track ID by default. However, you can set the name of the track when you create or publish it.
For example:
localParticipant.publishTrack(localVideoTrack, { name: "camera" }
You can then read the name from the LocalTrack or RemoteTrack object later.
Let me know if that helps.

Get Apple Music playlist share URL programmatically by Swift

When sharing playlist in Apple Music app via Email, you can get a URL like this
https://itunes.apple.com/jp/playlist/if-you-like...may-j./idpl.4299b4c5a42048bd850eca538e68ace2?l=en
You will also have an URL when sharing local created playlist.
I would like to know if it is possible to get the URL programmatically on iOS using Swift.
[Effort studied but failed to solve]
Related discussion using link maker does not solve the problem
Apple Music URL Scheme
Query the playlist using: MPMediaQuery.playlists() and enumerated the returned playlist but cannot find any property showing the URL
I'm pretty sure this is not possible. I believe the playlist does not have the idpl value until the user manually presses the share button in iTunes. And, there's nothing in the API to create one.
I set up a proxy and had a look at the requests iTunes makes.
I created a playlist in iTunes and added songs to the playlist. Every song I added made several requests to various endpoints under:
https://ld-6.itunes.apple.com/WebObjects/MZDaap.woa/daap/update No idpl value in any of the responses.
Then I manually hit the share button. A request is made to
https://client-api.itunes.apple.com/WebObjects/MZStorePlatform.woa/wa/lookup with the idpl in the URL.
Now when you add more songs to the playlist, the responses contain the idpl.
From that it seems that the idpl is created on the device when the user touches share.
Probably best to file a radar for Apple to add a share URL property to MPMediaPlaylist.
EDIT: I filed a radar

Record video of the screen using an App on iOS

I want to build an App that allows me to record what i am doing on my iphone.. like a mirror broadcast but without using external Apps or connect it to a mac.
is it possible ?
If u are talking about onscreen-recording then,
Check this link, u will get a valid program.
What this does is it saves the contents of a UIView to a UIImage. The author suggests you can save a video of the app in use by passing the frames through AVCaptureSession.
I believe it hasn't been tested with an OpenGL subview, but assuming that it works you might be able to modify it slightly to include audio and then you'd be set.
Refer the comments section in the link to t mix audio & video and save it as a quicktime movie.
Also,
Another useful project for this is RecordMyScreen, found here
Search in mac .. Quick Time Player..
Then Open it. and Right CLick and you will find NEw Screen Recording
Option
And You Have to follow below Step.
And Finally You have Video

How To Distinguish One Music File From The Other

I am currently building a music player app. One of the functions of my app is "My Favorites". This is nothing different from other music player apps, for it allows user to mark down their favorite songs, and when they want to play only their favorite songs, they can play them directly from the "My Favorites" list.
My problem now is that in order for me to remember and be able to play that song next time, I think I have to remember the UNIQUE ID of that song. I am not sure if there is really a UNIQUE ID for every music file stored in the phone. I just thought of that because if there is, it would be a key for me to access that music file.
The solution I tried is appending the name of the music and the artist and use it as the key. Then, I will get the music list and run a loop through it, once I find the corresponding music file by comparing it with the key I will store it in an NSMutableDictionary. Then I will be able to play it later.
The problem of my solution is that what id two music files have exactly the same artist name and same title. That I won't be able to distinguish which is which.
I hope I made my self clear. To summarize:
Problem: Is there a way to get the UNIQUE ID of a music file. If there isn't are there any other ways to determine one music file from the other?
As what #Larme suggested. I could use MPMediaItemPropertyPersistentID for the unique ID of my music files, and that is what I've applied, and it is the right answer for me.
Thank you #Larme!

Update song/track info from iPhone app

I have an app that implements the MediaPlayer framework. I can read the state, stop, play, skip, reverse, etc.
How can I update the BPM, or the comments, etc...
I have tried a direct assignment on MPMediaItemPropertyBeatsPerMinute and I get the error:
Read-only variable is not assignable
I currently have a UITextField for collecting user input, and a UIButton to save the data.
What methods can be implemented to save/push the data in the UITextField to the tracks MetaData.
Any leads would be great!
No this is not possible without jail breaking. An app cannot write to the media library.

Resources