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

Share Video feature #49

Open
westonganger opened this issue Sep 22, 2015 · 12 comments
Open

Share Video feature #49

westonganger opened this issue Sep 22, 2015 · 12 comments

Comments

@westonganger
Copy link

Is there any chance at sharing videos to instagram.

@vstirbu
Copy link
Owner

vstirbu commented Sep 28, 2015

Only on Android at this time.

@sky-code
Copy link
Contributor

ios implementation #60

@MT--
Copy link

MT-- commented Mar 4, 2016

Hoping to implement this as soon as it is merged!

@sky-code
Copy link
Contributor

sky-code commented Mar 5, 2016

As you can see this feature require additional testing and maybe some changes, could you please do it if you can

@MT--
Copy link

MT-- commented Mar 5, 2016

I can do some testing when I am ready to test my new project on iOS. I am currently just developing on Android, but I will be sure to work this out when I get to that point.

@sky-code
Copy link
Contributor

sky-code commented Jun 8, 2016

when #60 will be merged, sharing video will be posible on ios 8+ based on Photos Framework and PHAsset.
I use this feature on my project, as example:

    func saveVideoToPhotoLibrary(command: CDVInvokedUrlCommand) {
        NSLog("CDVMediaKit#saveVideoToPhotoLibrary()")
        let filePath = String(command.argumentAtIndex(0) as! NSString)
        NSLog(filePath)

        if filePath.isEmpty{
            NSLog("error filePath is empty")
        }

        var fileURL = NSURL(string: filePath)!

        if !fileURL.fileURL {
            fileURL = NSURL(fileURLWithPath: filePath)
        }

        var localIdentifier:String? = nil
        PHPhotoLibrary.sharedPhotoLibrary().performChanges({ () -> Void in

            let createAssetRequest: PHAssetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(fileURL)!
            let placeholder = createAssetRequest.placeholderForCreatedAsset
            localIdentifier = placeholder?.localIdentifier
        }, completionHandler: { (success, error) -> Void in
            if success {
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsString: localIdentifier);
                self.commandDelegate!.sendPluginResult(pluginResult, callbackId: command.callbackId);
            }
            else {
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAsString: error?.localizedDescription);
                self.commandDelegate!.sendPluginResult(pluginResult, callbackId: command.callbackId);
            }
        })

    }

This func take a path to video in my application tmp folder, save it to sharedPhotoLibrary and return local identifier string, which is similar to "24320B60-1F52-46AC-BE4C-1202F02B9D00/L0/001", when you have local identifier pass it to Instagram.shareAsset and you will see Instagram app with pre selected video.
If you pass empty string or invalid local identifier Instagram will be opened without any errors but nothing will be selected.

@westonganger
Copy link
Author

I see that iOS now has the method shareAsset which enables video upload. We should get this implemented in Android too. We have the documentation for the intent, would that be similar to what iOS does?

@vstirbu
Copy link
Owner

vstirbu commented May 16, 2017

We could add a shareVideo method for sharing the video which accepts an url to the video file. Instagram app for Android supports that feature.

@westonganger
Copy link
Author

Would love this. You are suggesting seperate methods for iOS and Android. Would it not be better to unify the JS API across both platforms with one method name or are they going to behave very differently?

@vstirbu
Copy link
Owner

vstirbu commented May 16, 2017

It might work with only one method.

In the long term the API needs to be reworked as so many things are not supported anymore by Instagram.

@albertleao
Copy link
Contributor

Sorry if I missed this, but according to the documentation video sharing is only available via iOS via the shareAsset method. Will this also work with Android as long as the video is local?

@ejlocop
Copy link

ejlocop commented Sep 3, 2018

Hi, any updates on this one?

Also, how did you guys get the local identifier string from the File ?

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

No branches or pull requests

6 participants