I am using the methods below in my code.
(void)cuePlaylistByPlaylistId:(nonnull NSString *)playlistId
index:(int)index
startSeconds:(float)startSeconds
suggestedQuality:(YTPlaybackQuality)suggestedQuality;
(void)loadPlaylistByPlaylistId:(nonnull NSString *)playlistId
index:(int)index
startSeconds:(float)startSeconds
suggestedQuality:(YTPlaybackQuality)suggestedQuality;
I need help as the above methods are not playing and not giving any callback.
Please help me out.
Related
I'm trying to establish a simple audio stream to a Chromecast device. This is just a POC for me to familiarize myself with the API. What I want to do is load up the user's library, select a song, and have it cast over. I've been following the integration guide quite closely but to no avail.
Please find the full project on Github here.
An overview of my code, AppDelegate.m:
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
GCKCastOptions *options = [GCKCastOptions.alloc initWithReceiverApplicationID:kGCKMediaDefaultReceiverApplicationID];
[GCKCastContext setSharedInstanceWithOptions:options];
[GCKCastContext.sharedInstance.sessionManager addListener:self];
}
UITableViewDelegate:
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
MPMediaItem *mediaItem = MusicManager.sharedManager[index];
NSString *path = [MPMediaLibrary.defaultMediaLibrary pathForAssetURL:mediaItem.assetURL];
GCKMediaMetadata *metadata = [GCKMediaMetadata.alloc initWithMetadataType:GCKMediaMetadataTypeMusicTrack];
[metadata setString:mediaItem.title forKey:kGCKMetadataKeyTitle];
[metadata setString:mediaItem.artist forKey:kGCKMetadataKeyArtist];
[metadata setString:mediaItem.albumTitle forKey:kGCKMetadataKeyAlbumTitle];
GCKMediaInformation *mediaInfo = [GCKMediaInformation.alloc initWithContentID:path
streamType:GCKMediaStreamTypeBuffered
contentType:[self fileMIMEType:path]
metadata:metadata
streamDuration:mediaItem.playbackDuration
customData:nil];
[GCKCastContext.sharedInstance.sessionManager.currentCastSession.remoteMediaClient loadMedia:mediaInfo autoplay:YES];
}
I initiate the casting session by tapping the GCKCastButton and Start Session, my TV shows the Cast logo, then when I tap on a specific song, my TV briefly shows the metadata (i.e. song title, artist name, etc.), and then reverts back to the Chromecast logo. On the device, if I remain on the screen presented by GCKCastButton, I can also see the details of the song that is supposed to be currently casting, but quickly changes to "No Media Selected" after a few seconds.
I've checked the file path, the MIME type, everything is correct and playable. I've even tried bundling a short MP3 and trying to cast that, but to no avail.
Can't help but feel like I'm missing something here, the integration guide doesn't really give much more info.
Any insight is appreciated. Thanks!
It seems that I was under the wrong impression that the cast library initiates a stream from the provided file itself. But instead it required an actual URL for the Chromecast device to perform a GET operation on.
I imagine this will be solved by running a server locally on the iOS device.
I am using the new Apple Music API with MPMusicPlayerController but play method doesn't work in the first time called, but after the second or third time.
My code is the following:
MPMusicPlayerController *appleMusicPlayer = /*access instantiated player*/;
[appleMusicPlayer setQueueWithStoreIDs:#[url]];
[appleMusicPlayer play];
The player is instantiated as follows:
_appleMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
_appleMusicPlayer.repeatMode = MPMusicRepeatModeNone;
_appleMusicPlayer.shuffleMode = MPMusicShuffleModeOff;
[_appleMusicPlayer beginGeneratingPlaybackNotifications];
The url passed in setQueueWithStoreIDs method is a NSString with a country-specific valid iTunesID. I provide you with a screenshot of NSLog output of url after above play method is called.
Any help would be much appreciated.
Make sure url is a string of the store ID!
You can get that here: https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/
I'd like to use an MPMediaPickerController to allow a user to select a song from his/her iPod library. From there he/she should be able to select a clip (~15s) of the song by specifying a start time and end time. Finally, the user should be able to send that clip to a friend or post it to a social network. For this, I think I'll need to create a new audio file from the raw iPod audio data.
My approach so far is to select the song, then get an AssetURL in the callback like so:
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker
didPickMediaItems: (MPMediaItemCollection *) collection {
MPMediaItem *item = [[collection items] objectAtIndex:0];
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
}
Then I can process the audio using (pseudocode):
ExtAudioFileCreateWithURL:url
The problem is that some songs have a null URL. Is this do to some sort of DRM restriction, and if so is there a workaround? Is this the best approach for the desired task?
Turned out it was a DRM restriction.
i'm trying to use VLC to playback youtube online video for IOS5.
I set a NSURL to MVLCMovieViewController, use code like this:
NSString *conntentURL = #"http://www.youtube.com/watch?v=FWKYriGgmCo";//(it's a workable link)
NSURL *url = [NSURL URLWithString:connectURL];
MVLCMovieViewController *movieViewController = [[MVLCMovieViewController alloc] init];
movieViewController.url = url;
[self presentModalViewController:movieViewController animated:YES];
[movieViewController release];
run the app, but i got a stop at http.c file with a hint "Program received signal "EXC_BAD_ACCESS"" near code:
p_sys->psz_user_agent = var_InheritString(p_access, "http-user-agent");
for(char *p = p_sys->psz_user_agent; *p, p++)
So does VLC support online playbacking? Or what should to be modified so that i can play a url directly on ios?
Thanks a lot for your help in advance!
I've done a lot of work on the VLC iOS source code, to try to get it to handle RTP and UDP streams. The short answer is that I didn't get it to work for those protocols but HTTP works, and the blocking seems to be at the OS level.
If you want the details on what I did to make VLC compile correctly and work on the latest XCode, please read the following forum thread https://forum.videolan.org/viewtopic.php?f=12&t=108691
Since YouTube seems to be HTTP, it should work but your mileage may vary.
Hope this helps.
I am currently trying out this code:
NSString *path = [[NSBundle mainBundle] pathForResource:#"dream" ofType:#"m4a"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
However, the SDK says that the ViewController does not implement the AVAudioPlayer Delegate.
Any body any ideas on how to play a WAV (or M4a) using the 2.2 SDK?
You need to add <AVAudioPlayerDelegate> to the end of your controller's class declaration, along these lines:
#interface MyViewController : UIViewController <AVAudioPlayerDelegate>
This'll probably generate some more warnings about delegate methods you need to implement - follow those and you'll be good to go.
Interesting. Try NSURL -URLWithString: - that's what I use in combination with the bundle method you're using. I don't see anything that could be causing a problem other than that. You're testing it on the device, right?
The answer I posted here should definitely help you. Just use audioservices for small wave sounds, unless you need concurrency, it's faster.
iPhoneToot.com has its own itootSound class and a VIDEO to show you how to play a wav file in 2 lines of code. Check them out at iPhoneToot.com. it will save you hours if not days of time!!