I'm developing a iOS media Player using the iPodMusicPlayer. I have a UITableView with the MPMediaPickerController selector.
After buying a song from the iTunes store, the picked track has no artwork in the iPodMusicPlayer:
MPMediaPlayer* player = [MPMediaPlayer iPodMusicPlayer];
MPMediaItem*item = [player nowPlayingItem];
MPMediaItemArtwork *artwork = [item valueForProperty:MPMediaItemPropertyArtwork];
UIImage *albumCoverArt = [artwork imageWithSize:CGSizeMake(100.0f, 100.0f)];
if(albumCoverArt!=nil) {
// do something
}
else {
// nil before sync
}
After syncing with iTunes the song reveals the artwork.
Since before syncing, the iPod player shows the artwork, I think I'm missing something in the code when requesting the item to the MPMediaLibrary.
Any idea?
I am having the same issue.
Seems like when you buy a song from the iTunes store directly on your iPhone, retrieving the artwork will give you a blank image.
After syncing your phone with iTunes, solves it and then you will get the right image from MPMediaItemArtwork.
Offcourse I would suspect the right image immediately after buying from iTunes.
Related
i want to play live streaming video in uiwebview it is playing by believe code
UIWebView *web=[[UIWebView alloc]initWithFrame:self.view.bounds];
[web loadHTMLString:htmlString baseURL:nil];
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
web.scalesPageToFit=YES;
web.mediaPlaybackRequiresUserAction=NO;
[self.view addSubview: web];
but the problem is that audio is not playing in simulator or not in any device with that live video what i am doing wrong or what i have missed here
go to Info.plist property list - add a new row - select required background modes, there should be a subrow called Item 0, select app plays audio or streams audio/video using AirPlay. Also check Audio air play in background modes in compatibility.
I am testing my app with Apple Music, my app grabs the current playing song and displays relevant information on it.
One of the steps is to get the album artwork, however I find that when the song is playing from Apple Music it does not contain any artwork.
Here is my code, the first if condition is ran, which suggests that the artwork is initialized, however I get no image.
Does anyone know how I can get the artwork when the song is being played though Apple Music?
song is of type MPMediaItem
CGSize artworkImageViewSize = cell.albumImage.bounds.size;
MPMediaItemArtwork *artwork = [song valueForProperty:MPMediaItemPropertyArtwork];
if (artwork)
{
cell.albumImage.image = [artwork imageWithSize:artworkImageViewSize];
}
else
{
cell.albumImage.image = [UIImage imageNamed:#"noArtwork"];
}
Whenever I try to print artwork.bounds I get back null.
This question already has answers here:
How to enable iPod controls in the background to control non-iPod music in iOS 4?
(3 answers)
Closed 9 years ago.
I have an online audio player app. I want the user to have controls of the app's play and pause even from the locked screen. The buttons are already shown by default. The code for my app is here.
Now how to enable the buttons to control my player. And how to show the image of my App when the screen of the App is locked. This is the example image
Please help if this is possible.
Thanx in Advance.
iOS 5 onwards, MPNowPlayingInfoCenter supports the setting of the track title as well as album art image in both the lock screen and the remote playback controls.To check whether MPNowPlayingInfoCenter is available, try this:-
if ([MPNowPlayingInfoCenter class]) {
UIImage *albumArtImg = [UIImage imageNamed:#"abc.png"];
albumArt = [[MPMediaItemArtwork alloc] initWithImage:albumArtImg];
NSDictionary *dictCurrentlyPlaying = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:#"Temporary", [NSNumber numberWithInt:22], albumArt, nil] forKeys:[NSArray arrayWithObjects:MPMediaItemPropertyTitle, MPMediaItemPropertyPlaybackDuration, MPMediaItemPropertyArtwork, nil]];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = dictCurrentlyPlaying;
}
Updated:- Please have a look at these:-1. http://jaysonlane.net/tech-blog/2012/04/lock-screen-now-playing-with-mpnowplayinginfocenter/2. How to set the title when playing music in background on iPhone?
Here's one I haven't been able to find an answer to. I am creating an iPhone (iOS 5.0) app and have used MPMoviePlayerController to get a thumbnail frame for video clips which I display in a gallery that contains thumbnails for both images & videos (just like the Photos app).
In the Photos app, for video thumbnails, it shows a little toolbar with a movie camera icon and the length of the clip, to indicate the thumbnail is a video. I can't figure out how to add this to my video frame thumbnails. Do I have to create something like that toolbar and add it to the UIImage of the frame thumbnail myself, or is there something here that I've just missed?
Thanks in advance.
I get the solution for your question...
So , you can use this: `
[yourButton setBackgroundImage:[self getVideoThumbnail:urlFromVideo]
forState:UIControlStateNormal];
[yourButton setImage:[UIImage imageNamed:yourImageName] forState:UIControlStateNormal];`
Function to getThumbnail is here:
- (UIImage *)getVideoThumbnail:(NSURL *)videoURL
{
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
//Player autoplays audio on init
[player stop];
return thumbnail;
}
I think this is the option for you...
I have an iOS app that streams background audio using AVAudioSession. It is working correctly, but I am curious, is there any way to change the text on the lock screen audio controls? Right now it simply displays the name of my app, but I would like to change it to the name of the track.
Additionally, the multi-tasking bar has no text under the controls- is there a way to add the track name there, as the iPod app does?
iOS 5 now supports setting the track title as well as an album art image in both the lock screen and the remote playback controls (the controls you get when you double-click the home button and swipe right). Take a look at the
MPNowPlayingInfoCenter class. Of course, to maximize compatibility, you'd want to test whether MPNowPlayingInfoCenter is available, by doing something like:
if ([MPNowPlayingInfoCenter class]) {
/* we're on iOS 5, so set up the now playing center */
UIImage *albumArtImage = [UIImage imageNamed:#"HitchHikersGuide"];
albumArt = [[MPMediaItemArtwork alloc] initWithImage:albumArtImage];
NSDictionary *currentlyPlayingTrackInfo = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:#"Life, the Universe and Everything", [NSNumber numberWithInt:42], albumArt, nil] forKeys:[NSArray arrayWithObjects:MPMediaItemPropertyTitle, MPMediaItemPropertyPlaybackDuration, MPMediaItemPropertyArtwork, nil]];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = currentlyPlayingTrackInfo;
}
here it is in swift! (no need to check for iOS 5 and up anymore)
let albumArt = MPMediaItemArtwork(image: UIImage(named:"HitchHikersGuide"))
let albumDict = [MPMediaItemPropertyTitle: "Life, the Universe and Everything", MPMediaItemPropertyPlaybackDuration: 42, MPMediaItemPropertyArtwork: albumArt]
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = albumDict