logo
down
shadow

Can't set MPMusicPlayerController queue with MPMusicPlayerMediaItemQueueDescriptor


Can't set MPMusicPlayerController queue with MPMusicPlayerMediaItemQueueDescriptor

By : user7454654
Date : November 19 2020, 03:01 PM
help you fix your problem You've found a bug. It appears that the initializer MPMusicPlayerMediaItemQueueDescriptor(itemCollection:) is completely broken: it results in an unusable queue descriptor.
The workaround, where possible, is to use the other initializer instead, namely MPMusicPlayerMediaItemQueueDescriptor(query:).
code :
let coll = MPMediaItemCollection(items: [song])
let predicate = MPMediaPropertyPredicate(
                value: song.persistentID,
                forProperty: MPMediaItemPropertyPersistentID)
let query = MPMediaQuery(filterPredicates: [predicate])
let q = MPMusicPlayerMediaItemQueueDescriptor(query: query)
player.setQueue(with: q)
player.play()


Share : facebook icon twitter icon
Why is setting queue in a MPMusicPlayerController only adding first track in collection?

Why is setting queue in a MPMusicPlayerController only adding first track in collection?


By : user1923753
Date : March 29 2020, 07:55 AM
it helps some times The MPMediaItemCollection Class Reference makes no mention of a mediaItems property. I'd guess the property you're accessing is similar to representativeItem, as that would explain why you'd only get the first track.
It looks like you answered your own question. You should use:
How do I clear the queue of a MPMusicPlayerController?

How do I clear the queue of a MPMusicPlayerController?


By : NetSolver
Date : March 29 2020, 07:55 AM
will help you I don't know if you've managed to overcome your problem, but here's a workaround that seems to be working for me.
code :
MPMediaPropertyPredicate *predicate =
    [MPMediaPropertyPredicate predicateWithValue: @"Non_Existant_Song_Name"
                                     forProperty: MPMediaItemPropertyTitle];
MPMediaQuery *q = [[MPMediaQuery alloc] init];
[q addFilterPredicate: predicate];
[self.player.controller setQueueWithQuery:q];
self.player.controller.nowPlayingItem = nil;
[self.player.controller stop];
MPMusicPlayerController queue issues

MPMusicPlayerController queue issues


By : Mochammad Ghani
Date : March 29 2020, 07:55 AM
To fix the issue you can do wow for some reason it had shuffle set to on. Thats embarassing. this fixed everything:
code :
    sharedMusicPlayer.musicPlayer.shuffleMode = MPMusicShuffleModeOff;
Current playback queue for MPMusicPlayerController?

Current playback queue for MPMusicPlayerController?


By : Andrew
Date : March 29 2020, 07:55 AM
Hope this helps This property unfortunately is not exposed on the MPMusicPlayerController class. The only alternative is to set the queue yourself.
How to clear queue of MPMusicPlayerController and add new queue when Song finished according to requirement

How to clear queue of MPMusicPlayerController and add new queue when Song finished according to requirement


By : Chetan Channe
Date : March 29 2020, 07:55 AM
I wish this helpful for you Use This Method it will help to clear queue and create or add new queue without any issue.
code :
- (void)setupMusic:(NSArray *)arrSongs forTaggedValue:(NSString *)taggedValue {

    NSMutableArray *allTheSongs = [[NSMutableArray alloc] initWithCapacity:0];
    NSLog(@"setupMusic:");
    for (SongsList *obj_songsList in arrSongs) {

        //  NSLog(@"mediaTitle: %@",obj_songsList.mediaTitle);
        MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
        [songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:obj_songsList.persistentId forProperty:MPMediaItemPropertyPersistentID]];
        NSArray *songs = [songQuery items];
        [allTheSongs addObjectsFromArray: songs];
    }

    //Modify Queue
    if ([[AppDelegate appDel].musicPlayerCtrl playbackState] == MPMusicPlaybackStatePlaying) {

        [self removeNotificationCenterForMusicPlayerController];
         MPMediaPropertyPredicate *predicate =
         [MPMediaPropertyPredicate predicateWithValue: @"Non_Existant_Song_Name"
         forProperty: MPMediaItemPropertyTitle];
         MPMediaQuery *q = [[MPMediaQuery alloc] init];
         [q addFilterPredicate: predicate];
         [[AppDelegate appDel].musicPlayerCtrl setQueueWithQuery:q];
         [AppDelegate appDel].musicPlayerCtrl.nowPlayingItem = nil;
         [[AppDelegate appDel].musicPlayerCtrl stop];

        MPMediaItemCollection *currentQueue = [[MPMediaItemCollection alloc] initWithItems:allTheSongs];
        [[AppDelegate appDel].musicPlayerCtrl setQueueWithItemCollection:currentQueue];
        [[AppDelegate appDel].musicPlayerCtrl setRepeatMode:MPMusicRepeatModeAll];
        [[AppDelegate appDel].musicPlayerCtrl play];

        [self addNotificationCenterForMusicPlayerController];
        [[AppDelegate appDel].musicPlayerCtrl beginGeneratingPlaybackNotifications];
    }
}
#pragma mark - For Hadle the Active Bugs Of MPMusicPlayerController
- (BOOL)isPlaybackStateBugActive {
    MPMusicPlaybackState playbackState = [AppDelegate appDel].musicPlayerCtrl.playbackState;
    if (playbackState == MPMusicPlaybackStatePlaying) {
        AudioSessionInitialize (NULL, NULL, NULL, NULL);
        UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
        AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory);
        AudioSessionSetActive (true);

        UInt32 audioIsPlaying;
        UInt32 size = sizeof(audioIsPlaying);
        AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &size, &audioIsPlaying);

        if (!audioIsPlaying){
            NSLog(@"PlaybackState bug is active");
            [[AppDelegate appDel].musicPlayerCtrl pause];
            [btnPlayOrPause setImage:[UIImage imageNamed:KPlayImage] forState:UIControlStateNormal];
            return YES;
        }
    }

    return NO;
}
#pragma mark - Default NotificationCenter For iPodLibrary/MusicPlayerController
- (void)addNotificationCenterForMusicPlayerController {

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

    [notificationCenter addObserver: self selector: @selector (handle_NowPlayingItemChanged:) name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];

    [notificationCenter addObserver: self selector: @selector (handle_PlaybackStateChanged:) name: MPMusicPlayerControllerPlaybackStateDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];



   // [notificationCenter addObserver: self selector: @selector (handle_VolumeChanged:) name: MPMusicPlayerControllerVolumeDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];

   // [[AppDelegate appDel].musicPlayerCtrl beginGeneratingPlaybackNotifications];
}
- (void)removeNotificationCenterForMusicPlayerController {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];

   // [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMusicPlayerControllerVolumeDidChangeNotification object: [AppDelegate appDel].musicPlayerCtrl];

    [[AppDelegate appDel].musicPlayerCtrl endGeneratingPlaybackNotifications];
}
Related Posts Related Posts :
  • Is it possible to animate a ViewCell when it appears or disappears?
  • How to install cocoa pods
  • rxjs created observable timeout always errors
  • adding lines without overwriting existing
  • How to setup Microsoft LUIS to detect composed names (dash separated)
  • In Ektron, Load Last Active Location
  • In Cypress how to count a selection of items and get the length?
  • Openlayers rotation broken when using precompose to clip a layer
  • Using SendGrid package with C# "Web" as shown in examples, is undefined
  • Service Worker: files are updated on the server but old version showing in browser
  • Ignore empty form values on update using laravl5
  • Expect: How to get the exit code from spawned process
  • Using In clause in apache Camel
  • Pass qualifier to provider method
  • Disable retained MQTT messages in Rabbit MQ
  • How to escape mask rules in kendo maskedtextbox for angular2?
  • How to delete blank rows in spss modeler
  • modify content of http response via haproxy
  • PUT multiple related records in Data API request
  • Getting data (text, ...) what user says
  • Transforming a list of structs with parent IDs into a list of trees
  • Eloquent relationship returns null, but a similar one is fine
  • how can i find the exact tick in netlogo in which agents take an action?
  • await - catch error - UnhandledPromiseRejectionWarning
  • Understanding Fabric Daily Summary Email
  • How to pass string and file as input for form parameters in a POST method using Karate
  • Windows app: fatal error C1083: Cannot open include file: 'gdiplus.h': No such file or directory
  • I have a list and I want to print a range of it's content with range and for loop
  • Integration Testing with Kitchen CI
  • Can't seem to get the from <asp:Literal </asp:Literal> property in Web forms
  • Can't access faraday params on views
  • RQM testNG integration
  • How can I enable unit templates?
  • Displaying multiple colors on a single data bar
  • Loading aggregates on reacting to domain events
  • Integrating Azure Cognitive services with Robotic Process Automation
  • Autodesk Forge Design Automation quota
  • Why can i not login to the wso2 api store using the email address of a secondary user store account
  • order not working with sortWhitelist
  • config.site for vendor libs on Fedora x86_64
  • Getting a limit response from Loopback, when no authentication is provided
  • What is the effect of FeedOptions.EnableLowPrecisionOrderBy Property
  • Recordset Null Value not being detected in null check
  • How to connect to an arbitary database using FaaS?
  • SourceTree not working after Windows 10 Fall Creators Update
  • How to get all registered user from Openfire through http
  • Error "invalid parameter" when launching a converted app
  • Using react-sortable-hoc with react-virtualized Grid
  • Xamarin.Forms: How to set values in Style only on specific platform
  • ZSH avoid adding empty commands to history?
  • Grep regular expression - Pattern issue
  • Unable to connect via Java to a DSE graph
  • Check if attachment is up to date with current document revision in couchdb
  • Can I bind an argument value ahead of time when using redux-actions?
  • How to change a member field with Kotlin reflection?
  • Replaying merged streams individually
  • DevExpress GridColumn strange proportional sizing
  • Drools Decision table error : Error while creating KieBase
  • Kafka-Flink-Stream processing: Is there a way to reload input files into the variables being used in a streaming process
  • How to export and import nifi flow from one HDP to another HDP
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org