Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Play video on Phone from Kodi Library #702

Open
kirbyzhou opened this issue Aug 20, 2022 · 17 comments
Open

Feature Request: Play video on Phone from Kodi Library #702

kirbyzhou opened this issue Aug 20, 2022 · 17 comments
Labels

Comments

@kirbyzhou
Copy link

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

@wutschel
Copy link
Collaborator

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
Copy link
Collaborator

wutschel commented Aug 22, 2022

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.

@kambala-decapitator
Copy link
Collaborator

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.

@wutschel
Copy link
Collaborator

wutschel commented Oct 11, 2022

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?

@kambala-decapitator
Copy link
Collaborator

kambala-decapitator commented Oct 12, 2022

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

@wutschel
Copy link
Collaborator

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
Copy link
Collaborator

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.

@kambala-decapitator
Copy link
Collaborator

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.

@wutschel
Copy link
Collaborator

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?

@kambala-decapitator
Copy link
Collaborator

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

@wutschel
Copy link
Collaborator

That was it :)

@kambala-decapitator
Copy link
Collaborator

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

@wutschel
Copy link
Collaborator

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?

@kambala-decapitator
Copy link
Collaborator

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

@wutschel
Copy link
Collaborator

wutschel commented Oct 14, 2022

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.

@kambala-decapitator
Copy link
Collaborator

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).

@wutschel
Copy link
Collaborator

wutschel commented Oct 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants