Finding video content in iPhone playlist - objective-c

Running iOS 4.2.1 I'm able to create a mixed playlist containing both audio and video. 3 items, first a video then 2 audio tracks. I know I'm working with the correct playlist.
However, cycling through the items like this...
for (MPMediaItem *mediaItem in [playlist items]) {
NSLog(#"%#",mediaItem);
NSLog(#"path %#",[mediaItem valueForProperty:MPMediaItemPropertyAssetURL]);
}
...returns me output of...
<MPConcreteMediaItem: 0x1303d0> 9016712715169871401
path ipod-library://item/item.mp3?id=9016712715169871401
<MPConcreteMediaItem: 0x12e9e0> 9016712715169871401
path ipod-library://item/item.mp3?id=9016712715169871401
...so my video asset is being excluded from the playlist. The iPhone plays the playlist correctly when I'm using it as an iPod.
I've gotten as far as I have using Ole Begemann's sample code from here. Does anyone know if video assets are supposed to be excluded? Is there another approach which would combine audio and video assets, assuming they're mixed in a playlist which I know the name of?

Related

How to pass the MediaLibrary to the AudioService and start playing from specific song in flutter

I have all the UI and logic to read songs from the device and I made my own loagic for playlists because android 10 has a bug. Anyways, so I'm looking on the audio_service package. The example has it all, but the Media library is hardcoded. Despite the name I can imagine this as Playlist with a list of songs.
How can I pass the playlist chosen to play. Maybe Shared preferences?
And another question: Is there a way from which song to start playing the playlist?

HLS live streaming subtitle?

I am using rtmp to broadcast streams to the server and using HLS to stream the video to my device.
Is there a subtitle protocol that I can update the subtitle on real time,
for example, there is a subtitle file in server, I can keep write into that file and my player also can keep read from that file.
I know WebVTT works for recorded streaming video, but will it work for live streaming video? Can I link my player to the webVTT file and I can just update the subtitle by keeping writing to it?
You can use WebVTT to add subtitles to a live HLS stream. You do this by using a live subtitle playlist. It works just like a live playlist - you add and remove entries from it as time progresses.
First create a master playlist and add a reference to your subtitle playlist (subtitles.m3u8) to it. Here’s a (simplified) example:
#EXTM3U
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",URI="subtitles.m3u8",LANGUAGE="en"
#EXT-X-STREAM-INF:BANDWIDTH=500000,RESOLUTION=1920x1080,SUBTITLES="subs"
prog_index.m3u8
The next step is updating the subtitle playlist during the live broadcast. Let’s say your subtitle playlist looks like this initially:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10,
1.webvtt
#EXTINF:10,
2.webvtt
#EXTINF:10,
3.webvtt
Notice that the #EXT-X-ENDLIST tag is missing from the playlist. This will cause the player to keep retrieving the playlist.
Then some time later (segment duration) it will look like this:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:2
#EXTINF:10,
2.webvtt
#EXTINF:10,
3.webvtt
#EXTINF:10,
4.webvtt
And so on. You’ll probably have to write some custom code to update the subtitle playlist.

Playing DRM songs

I have an audio tag like this:
<audio id="myAudio" msaudiocategory="BackgroundCapableMedia"></audio>
to which I set the src property to
URL.createObjectURL(file, { oneTimeOnly: true });
and then call
myAudio.play();
This works well for my personal mp3's, but songs downloaded through the Xbox Music Pass, which I assume are under DRM, simply do not play. There's no audio and the 'timeupdate' event never fires. I don't see any exception or message in the Output window.
I tried playing those same songs with VLC, and I get no audio while the progress bar advances normally.
Is it possible to play those songs outside of the official apps?
Edit: and if it isn't, can we detect if a music file is DRM'ed so as to prevent its usage in our apps?
These are DRM'd files, so they need the DRM keys, etc etc.
Since those are private to the application, it's not possible to play that DRM'd content outside of those applications.

iTunes Match + AVplayer + MPMediaQuery not working

I'm developing an app which makes usage of AVPlayer, MPMediaItem and MPMediaQuery. It works as long as Itunes match. We start with a MPMediaQuery, then we perform some filtering leaving some MPMediaItems, then we have been using AVPlayer because:
1.- we also play noises during the song play
2.- we need to suscribe to play/stops events from ipod.
All this features are currently working, except if the ipod library has itunes match enabled. Even when AVPlayer status is playing, no sound comes. Is obvious that it is not triggering the song download from iCloud.
All the information I have about itunes match by the moment is this post:
MPMediaItem and iTunes Match
which states you can trigger the download by using a MPMusicPlayerController play call. For the reasons given above, we cannot make use of this class to control our own player.
I have two ideas on how to solve this problem:
A. Find a way to check if a song is already downloaded and available in the library to play using AVPlayer. If the song is not available let the user know that we don't support songs not available.
B. Find a way to trigger the download of the song just before it becomes the next item to play.
I still cannot find how to implement any of these solutions and I haven't found any related documentation, so I submitted my app with a warning message to prevent users to use this app if they are using itunes match.
On iOS 6 and up you can use [[item valueForProperty:MPMediaItemPropertyIsCloudItem] boolValue] to check if an item is already downloaded.
A. Find a way to check if a song is already downloaded and available
in the library to play using AVPlayer. If the song is not available
let the user know that we don't support songs not available.
This isn't perfect but it works in most cases. Songs downloaded from iTunes Match will be DRM free. So you can check the assets DRM flags, if it is not exportable then it needs to be downloaded. It is possible to get a false positive with audio books/pod casts but you are mostly safe.
MPMediaItem* item
NSURL* url = [item valueForProperty:MPMediaItemPropertyAssetURL];
AVURLAsset* assetToLoad = [[AVURLAsset alloc] initWithURL:url options:nil];
bool protectedCon = assetToLoad.hasProtectedContent;
bool exportable = true;
if (gApp.mSysVersionInt >= 5) {
exportable = assetToLoad.exportable; //4.3+
}
B. Find a way to trigger the download of the song just before it
becomes the next item to play.
You can try doing this will a muted MPMusicPlayerController, but there is no way to track when the song is downloaded and sometimes it takes a very long time.

Getting list/path of songs from iphone's library

Want to create an alarm application, that will play a music file at a specific time. How can i get list of songs from iphone's library. I want to show this list in tableview, user can then select a single file that will be played at sepecified time.
Any code sample?
Just use the MPMediaPickerController.
The sample code AddMusic shows how to choose (and add) music in the iPod library.