小编Col*_*ght的帖子

MPRemoteCommandCenter暂停/播放按钮没有切换?

我在MPRemoteCommandCenter中获取播放和暂停按钮切换时遇到问题.无论出于何种原因,音频和事件都将正常工作,但命令中心不会将播放按钮更改为暂停按钮.这是我的代码......

- (void)setupMPRemoteCommandCenter{
    MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];

    MPRemoteCommand *play = [commandCenter playCommand];
    [play setEnabled:YES];
    [play addTarget:self action:@selector(playAudio:)];

    MPRemoteCommand *pause = [commandCenter pauseCommand];
    [pause setEnabled:YES];
    [pause addTarget:self action:@selector(playAudio:)];


    [commandCenter.skipBackwardCommand setPreferredIntervals:@[@30.0]];
    MPRemoteCommand *skipBackwards = [commandCenter skipBackwardCommand];
    [skipBackwards setEnabled:YES];
    [skipBackwards addTarget:self action:@selector(skipBackwardEvent:)];

    [commandCenter.skipForwardCommand setPreferredIntervals:@[@30.0]];
    MPRemoteCommand *skipForwards = [commandCenter skipForwardCommand];
    [skipForwards setEnabled:YES];
    [skipForwards addTarget:self action:@selector(skipForwardEvent:)];

}
-(void)playAudio: (MPRemoteCommandHandlerStatus *)event{
    [self playAction];
    //playAction handles the audio pausing and toggling the play button on the app
}
Run Code Online (Sandbox Code Playgroud)

这是问题,媒体中心应该显示一个暂停按钮,如应用程序而不是播放按钮.

让我知道,如果你们能想到任何事情,我会很乐意帮助你.这让我疯了

objective-c media-player ios

10
推荐指数
1
解决办法
2528
查看次数

在C中释放内存的困惑?

关于我在这里做错了什么,我感到很困惑.我有一个链接的节点列表(见下面的结构),我很困惑如何在修剪列表时释放内存.我认为将它们添加到数组(eventArr)会使它们以后更容易释放,但我仍然遇到问题!谁能帮助我指出正确的方向?

static void trim_list(int room, int keep, char timestamp[]) {

        struct room_t *the_room;
        struct room_t *the_room_copy;

        struct evnode_t *eventArr[20];
        int index = 0;

        the_room_copy = malloc(sizeof(struct room_t));
        the_room = find_room(room);

        the_room_copy->room = the_room->room;
        the_room_copy->ecount = the_room->ecount;
        the_room_copy->evl_head = the_room->evl_head;

        struct evnode_t *node;

        int counter;
        int removed = 0;

        for(counter = 0; counter != keep; counter++){
          the_room_copy->evl_head = the_room_copy->evl_head->next;                 
        }

        while(the_room_copy->evl_head){
          eventArr[index] = the_room_copy->evl_head;
          the_room_copy->evl_head = the_room_copy->evl_head->next;
          index++;
          removed++;
        }

        for(index = 0; index < removed; index++){
          free(eventArr[index]);
        } …
Run Code Online (Sandbox Code Playgroud)

c malloc free gdb linked-list

1
推荐指数
1
解决办法
85
查看次数

标签 统计

c ×1

free ×1

gdb ×1

ios ×1

linked-list ×1

malloc ×1

media-player ×1

objective-c ×1