mpmediaplayercontroller

Play Song at specific index of MPMediaItemCollection in Swift

我的未来我决定 提交于 2019-12-10 15:49:11
问题 I try to make my own Musicplayer with Swift. I need to jump to a specific song/index of my MPMediaItemCollection and start to play it but i can only find methods like skipToNextItem() and skipToPreviousItem(). Is there any other way to do that than with a loop? let player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithItemCollection(mediaCollection) player.play() 回答1: According to the documentation, we use the nowPlayingItem property. To specify that playback should begin at

Simulator crashes on AQMEIOManager

喜夏-厌秋 提交于 2019-12-10 12:53:49
问题 The simulator crashes when trying to play audio. 13:22:14.211 App [2965:5603] <0xb03e7000> Error '!obj' trying to fetch default input device's sample rate 13:22:14.211 App [2965:5603] <0xb03e7000> Error getting audio input device sample rate: '!obj' 13:22:14.213 App [2965:5603] <0xb03e7000> AQMEIOManager::FindIOUnit: error '!dev' 回答1: Selecting "internal microphone" instead of "Soundbooth 3.0" in the sound system settings for input did the trick. Conclusion: The simulator does not seem to

Playing Video From UITableView

让人想犯罪 __ 提交于 2019-12-05 21:24:18
My main goal is to be able to click on a table view item and load a video. The table view is populated with the contents of the documents directory and I have been able to do this successfully and add the filename to the cell's label, I have done this with the following code: void)viewDidLoad { [super viewDidLoad]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = documentsDirectory; filePathsArray = [[NSFileManager defaultManager]

iOS: MPMusicPlayerControllerPlaybackStateDidChangeNotification called multiple times on certain devices

前提是你 提交于 2019-12-05 14:29:46
I have an application that plays back music. I'm using the following code to listen to playback state changes from the MPMusicPlayerController to update the UI. More precisely I toggle the look of the play button between play and pause. NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver: self selector: @selector (handle_NowPlayingItemChanged:) name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification object: self.musicPlayer]; [notificationCenter addObserver: self selector: @selector (handle_PlaybackStateChanged:) name:

MPMoviePlayerPlaybackDidFinishNotification being called again in iPhone 4.3 simulator when setting contentURL

丶灬走出姿态 提交于 2019-12-03 15:15:08
NOTE: See the updates at the bottom. I have an application to play videos one by one from a list. So, to test this functionality, I created a simple application with only one view controller. I referenced this blog before implementing this view controller. The view controller is named TNViewController and its implementation is as follows: #import <UIKit/UIKit.h> #import <MediaPlayer/MediaPlayer.h> @interface TNViewController : UIViewController { @private NSMutableArray *_videoArray; int _currentVideo; MPMoviePlayerController *_moviePlayer; NSURL *_movieUrl; } @end Its implementation is:

MediaPlayer change DataSource Error when MediaPlayer complets Playing First Audio

余生长醉 提交于 2019-12-02 20:04:21
问题 Any one Help for MediaPlayer Error. when aim is to Change DataSource and Play second Audio when First Audio is Compliting its Playing. My Code is below :- mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer arg0) { String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + FILENAME+arrListSize+".wav"; mMediaPlayer.release(); mMediaPlayer = null; mMediaPlayer = new MediaPlayer(); Uri uri = Uri.parse("file://"

Can't set MPMusicPlayerController queue with MPMusicPlayerMediaItemQueueDescriptor

夙愿已清 提交于 2019-12-02 16:28:16
问题 This code results in silence: let query = MPMediaQuery.songs() let result = query.items guard let items = result, items.count > 0 else {return} let song = items[0] let player = MPMusicPlayerController.applicationQueuePlayer let coll = MPMediaItemCollection(items: [song]) let q = MPMusicPlayerMediaItemQueueDescriptor(itemCollection: coll) player.setQueue(with: q) player.play() I've stepped through the code, and we reach player.play() . I have an MPMediaItem and I've correctly formed an

MediaPlayer change DataSource Error when MediaPlayer complets Playing First Audio

孤街醉人 提交于 2019-12-02 09:28:01
Any one Help for MediaPlayer Error. when aim is to Change DataSource and Play second Audio when First Audio is Compliting its Playing. My Code is below :- mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer arg0) { String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + FILENAME+arrListSize+".wav"; mMediaPlayer.release(); mMediaPlayer = null; mMediaPlayer = new MediaPlayer(); Uri uri = Uri.parse("file://"+fileName); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mMediaPlayer.setDataSource

Can't set MPMusicPlayerController queue with MPMusicPlayerMediaItemQueueDescriptor

假如想象 提交于 2019-12-02 08:14:48
This code results in silence: let query = MPMediaQuery.songs() let result = query.items guard let items = result, items.count > 0 else {return} let song = items[0] let player = MPMusicPlayerController.applicationQueuePlayer let coll = MPMediaItemCollection(items: [song]) let q = MPMusicPlayerMediaItemQueueDescriptor(itemCollection: coll) player.setQueue(with: q) player.play() I've stepped through the code, and we reach player.play() . I have an MPMediaItem and I've correctly formed an MPMediaItemCollection from that, and an MPMusicPlayerMediaItemQueueDescriptor from that . So why isn't my

How does Spotify customize the media playback controls on iOS?

拜拜、爱过 提交于 2019-11-28 16:52:40
问题 Spotify on iOS has a very interesting Control Center integration. Notice the hamburger button below. The same thing is on the lock screen! How do they do those? Is there an API in MPMediaCenter or something? 回答1: Yes, there is an API for that Looking at the instructions found in the apple docs regarding remote control events you get two classes MPRemoteCommand and MPRemoteCommandCenter highlighted. Looking up MPRemoteCommandCenter will show you there are a multitude of commands like