Commit 59b5684c authored by Felix Paul Kühne's avatar Felix Paul Kühne

web socket: add received URLs to ubiquitous key store

parent 244ac26b
......@@ -324,7 +324,7 @@
"url": "https://vimeo.com/74370512"
}
*/
BOOL needsMediaList;
BOOL needsMediaList = NO;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMediaList *mediaList = vpc.mediaList;
......@@ -333,7 +333,29 @@
mediaList = [[VLCMediaList alloc] init];
}
[mediaList addMedia:[VLCMedia mediaWithURL:[NSURL URLWithString:dictionary[@"url"]]]];
NSString *urlString = dictionary[@"url"];
if (urlString == nil || urlString.length == 0)
return;
/* force store update */
NSUbiquitousKeyValueStore *ubiquitousKeyValueStore = [NSUbiquitousKeyValueStore defaultStore];
[ubiquitousKeyValueStore synchronize];
/* fetch data from cloud */
NSMutableArray *recentURLs = [NSMutableArray arrayWithArray:[ubiquitousKeyValueStore arrayForKey:kVLCRecentURLs]];
/* re-order array and add item */
if ([recentURLs indexOfObject:urlString] != NSNotFound)
[recentURLs removeObject:urlString];
if (recentURLs.count >= 100)
[recentURLs removeLastObject];
[recentURLs addObject:urlString];
/* sync back */
[ubiquitousKeyValueStore setArray:recentURLs forKey:kVLCRecentURLs];
[mediaList addMedia:[VLCMedia mediaWithURL:[NSURL URLWithString:urlString]]];
if (needsMediaList) {
[vpc playMediaList:mediaList firstIndex:0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment