Official-Kodi-Remote-iOS icon indicating copy to clipboard operation
Official-Kodi-Remote-iOS copied to clipboard

Feature Request: Play video on Phone from Kodi Library

Open kirbyzhou opened this issue 2 years ago • 17 comments

Now, Kore for Android can play video on Phone from Kodi Library. Can Official-Kodi-Remote-iOS also add this feature?

kirbyzhou avatar Aug 20 '22 02:08 kirbyzhou

There was an unfinished attempt to play file via VLC, the code got removed. Adding this feature is not on my agenda yet, but I understand this can be useful. Any help to add this is appreciated.

wutschel avatar Aug 21 '22 17:08 wutschel

Just did a quick hack, and this already plays my flac audio files, but it refuses to play the mpg and mkv files I have. I guess AVPlayer does have limited support for A/V formats.

https://github.com/wutschel/Official-Kodi-Remote-iOS/tree/local_playback

Edit: Also confirmed this works with 3pg videos.

wutschel avatar Aug 22 '22 16:08 wutschel

I guess AVPlayer does have limited support for A/V formats.

yes, you're right.

I think it'd be better to add a Share button sending video URL or so that can be transferred to an external video player app capable of handling such format.

kambala-decapitator avatar Oct 11 '22 08:10 kambala-decapitator

Why not. Added the long press action "Share" which for now only allows to copy-to-clipboard.

https://github.com/wutschel/Official-Kodi-Remote-iOS/tree/share_url

Screenshot: https://abload.de/img/bildschirmfoto2022-10olfus.png

Is it possible to let iOS select which apps are relevant for the file type the URL points to?

wutschel avatar Oct 11 '22 18:10 wutschel

Is it possible to let iOS select which apps are relevant for the file type the URL points to?

I think not, unfortunately. But please test with a few video player apps and sharing video links from other apps.

On the commit:

  • you can also show thumbnail/metadata via activityViewControllerLinkMetadata if desired, but you'll need to implement UIActivityItemProvider manually
  • not sure why you're also sharing empty string
  • I wouldn't disable mail/message/airdrop
  • sourceRect must be in sourceView's coordinate system iirc => use bounds
  • defining completionHandler for UIActivityViewController would probably be a good idea

kambala-decapitator avatar Oct 12 '22 07:10 kambala-decapitator

Thanks for your comments. I just started to play around with this a bit and will improve this further. Finally I need to test on my phone as on simulator I don't have any other apps running.

wutschel avatar Oct 12 '22 17:10 wutschel

Updated the implementation, mainly addressing the origin and not disabling mail/message/airdrop. Can you help with how to update icon? I did not find reference obj c code around activityViewControllerLinkMetadata and UIActivityItemProvider.

wutschel avatar Oct 12 '22 18:10 wutschel

here's a URL wrapper from one of my projects, hope this would be sufficient to get the idea:

// .h
@interface SharingActivityItemSource : NSObject <UIActivityItemSource>
- (instancetype)initWithUrlString:(NSString *)urlString;
@end

// .m
@import LinkPresentation;

@interface SharingActivityItemSource ()
@property (nonatomic, copy) NSURL *url;
@end

@implementation SharingActivityItemSource

- (instancetype)initWithUrlString:(NSString *)urlString {
    if (self = [super init]) {
        self.url = [NSURL URLWithString:urlString];
    }
    return self;
}

- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return self.url;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    return self.url;
}

- (LPLinkMetadata *)activityViewControllerLinkMetadata:(UIActivityViewController *)activityViewController API_AVAILABLE(ios(13.0)) {
    __auto_type meta = [LPLinkMetadata new];
    meta.originalURL = self.url;
    meta.URL = meta.originalURL;
    meta.title = @"Artikel";
    meta.imageProvider = [[NSItemProvider alloc] initWithContentsOfURL:NSBundle.mainBundle.appIconURL];
    return meta;
}

@end

and then you pass an instance of this class instead of plain URL to activityItems.

iirc there're more fields in LPLinkMetadata, please check its doc/header.

kambala-decapitator avatar Oct 12 '22 20:10 kambala-decapitator

Thanks, tried to add this to my best knowledge (see https://github.com/wutschel/Official-Kodi-Remote-iOS/tree/share_url), but this crashes with "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SharingActivityItemSource copyWithZone:]: unrecognized selector sent to instance 0x600001b00620'". If I implement it crashes with the next unrecognized selector. Did I miss something?

wutschel avatar Oct 13 '22 20:10 wutschel

you made a mistake: activityItems must be an array :)

kambala-decapitator avatar Oct 14 '22 07:10 kambala-decapitator

That was it :)

wutschel avatar Oct 14 '22 12:10 wutschel

and now with LPLinkMetadata you can control title (Down and out instead of IP), possibly display album cover image etc.

kambala-decapitator avatar Oct 14 '22 12:10 kambala-decapitator

and now with LPLinkMetadata you can control title (Down and out instead of IP), possibly display album cover image etc.

Yep, next step. But this might be a viable overall solution. Still need to test how this behaves when sharing the URL with other apps. Do you have by chance the possibility to test?

wutschel avatar Oct 14 '22 12:10 wutschel

yes, will try on iPad, have a few video players there

kambala-decapitator avatar Oct 14 '22 12:10 kambala-decapitator

Updated, but now sometimes not showing up on iPad. Will be related to the ctrl which shows the popup. Need to dig into this later.

wutschel avatar Oct 14 '22 13:10 wutschel

tested on iPad: seems to work, opening the URL in VLC works as well. Unfortunately, plain URL can't be sent to video players out of the box, probably unless they implement a share extension.

dummyView - please don't do that. Simple download can be done with NSURLSession.

But now I see that thumbnails are usually unavailable, I'd avoid delays in showing the sharing view as it's a rather bad UX (at first I thought that sharing simply doesn't work and tried it a couple of times). Can be shown only if already available in local cache (if there's such thing in the Remote).

kambala-decapitator avatar Oct 14 '22 14:10 kambala-decapitator

dummyView was just to play with this -- I still see this as kind of prototyping. Yes, there is a thumbnail cache (see updated code on the branch). If I use this, the behaviour is different of course -- if cached, the thumbnail is shown; if not, the app icon is shown.

wutschel avatar Oct 14 '22 19:10 wutschel