vimeo / vimeo-unity-sdk

Easily stream your Vimeo videos into Unity or record and publish out to Vimeo.
MIT License
211 stars 49 forks source link

Support files json response in addition to play #54

Closed FirstSuns closed 5 years ago

FirstSuns commented 5 years ago

please help me as soon as possible I used your unity package fro Vimeo player(vimeo-0.9.3, 2018.10.25) But it doesn't work I used unity5.6.4p2(64bit)

I checked from debug VimeoVideo.cs/ public VimeoVideo(JSONNode video)

there is no field "play" in video parameter "if (video["play"] != null) {"

video parameter : "{\"uri\":\"\/videos\/302984985\", \"name\":\"BodyScan\", \"description\":null, \"duration\":2312, \"width\":1280, \"height\":720,

\"files\":[ {\"quality\":\"hd\", \"type\":\"video\/mp4\", \"width\":1280, \"height\":720, \"link\":\"https:\/\/player.vimeo.com\

\/external\/302984985.hd.mp4?s=80ebdc48ac5716e7761311a87c1f80eb7b524d73&profile_id=174&oauth2_token_id=1145180683\", \"created_time\":

\"2018-11-27T05:34:51+00:00\", \"fps\":29.97, \"size\":442058005, \"md5\":\"99ad44e7987d11bfdc66619328f57a73\"}, {\"quality\":\"sd\",

\"type\":\"video\/mp4\", \"width\":640, \"height\":360, \"link\":\"https:\/\/player.vimeo.com\/external\/302984985.sd.mp4?

s=3e4daba0527b1e13eec170add39a51a61cd7b0d4&profile_id=164&oauth2_token_id=1145180683\", \"created_time\":\"2018-11-27T05:34:51+00:00\",

\"fps\":29.97, \"size\":191057949, \"md5\":\"d2d1fe825bd85fb276300402d8b869cd\"}, {\"quality\":\"sd\", \"type\":\"video\/mp4\", \"width

\":960, \"height\":540, \"link\":\"https:\/\/player.vimeo.com\/external\/302984985.sd.mp4?

s=3e4daba0527b1e13eec170add39a51a61cd7b0d4&profile_id=165&oauth2_token_id=1145180683\", \"created_time\":\"2018-11-27T05:34:51+00:00\",

\"fps\":29.97, \"size\":371977428, \"md5\":\"20fe11071133fde843bc21f936fc685c\"}, {\"quality\":\"hls\", \"type\":\"video\/mp4\", \"link

\":\"https:\/\/player.vimeo.com\/external\/302984985.m3u8?s=3ee90c44741843840e83f3182c1236a793d136f4&oauth2_token_id=1145180683\",

\"created_time\":\"2018-11-27T05:34:51+00:00\", \"fps\":29.97, \"size\":442058005, \"md5\":\"99ad44e7987d11bfdc66619328f57a73\"} ]}" 2018-11-26_23-23-55

2018-11-26_23-23-55

caseypugh commented 5 years ago

Hi @FirstSuns - I dug into your Vimeo account and it looks like you are using a token from your own Vimeo developer app, which is totally fine, except I will need to enable some permissions for your account to make it work. Can you share the ID of your developer app so I can fix?

ragecryx commented 5 years ago

I was about to open a new issue for this one too. It seems that the Vimeo API returns the file entries in files key not in play. So I did some quick changes in VimeoVideo.cs:81 so it looks like:

progressiveFiles = new List<JSONNode>();
if (video["files"] != null) {
    files = video["files"];

    // Sort the progressive files quality
    if (files != null) {
        for (int i = 0; i < files.Count; i++) {
            if (files[i]["height"] != null)
            {
                progressiveFiles.Add(files[i]);
            }
        }   
        progressiveFiles.Sort(SortByQuality);
    }
}

and it works for me, at least inside the Unity Editor.

Shouldn't the SDK support both cases?

caseypugh commented 5 years ago

I think that's fair feedback. I updated this issue to reflect your comment.

We support play because it is a more modern API response from Vimeo, but requires special app priveledges. You're the first to use your own developer app, so thanks for pointing this out. We will look into making a fix.

caseypugh commented 5 years ago

And PRs are welcome :)

FirstSuns commented 5 years ago

Thanks. after fix, It works well on unity5.6.4 but after build apk for android, player doesn't work on android. I can't see any video on android device what is matter? what do I set more for android and ios?

FirstSuns commented 5 years ago

Hello I am waiting your reply what do I need to set more for android and ios version? I use unity5.6.4 now I think your plugin doesn't work on android and ios please help me

FirstSuns commented 5 years ago

Hello I am waiting your reply. I used your unity package fro Vimeo player(vimeo-0.9.3, 2018.10.25) I tested unity5.6.4 and unity2018.2.14 for android it didn't work for android please help me

ragecryx commented 5 years ago

You mean the video is not loading or it's not rendering? If it's not rendering it's probably a totally different issue. Try switching the rendering of the video between canvas and mesh/material override and see what works best for you.

caseypugh commented 5 years ago

I haven't had a chance to check out your demo - thanks for sharing. Have you turned on debug mode on your Android build to see if the Vimeo API is properly returning the video file URL?

If it is, then +1 to what @ragecryx said: this sounds like a rendering issue, which is not a problem with the Vimeo plugin, but with Unity. Unity has a lot of bugs with their native VideoPlayer. I recommend using AVPro Video which might save you a lot of trouble. AVPro also supports adaptive video (which Unity's VideoPlayer does not support), which seems like a must have if you are building a mobile application/game.

andersonaraujodl commented 5 years ago

I was about to open a new issue for this one too. It seems that the Vimeo API returns the file entries in files key not in play. So I did some quick changes in VimeoVideo.cs:81 so it looks like:

progressiveFiles = new List<JSONNode>();
if (video["files"] != null) {
    files = video["files"];

    // Sort the progressive files quality
    if (files != null) {
        for (int i = 0; i < files.Count; i++) {
            if (files[i]["height"] != null)
            {
                progressiveFiles.Add(files[i]);
            }
        }   
        progressiveFiles.Sort(SortByQuality);
    }
}

and it works for me, at least inside the Unity Editor.

Shouldn't the SDK support both cases?

This Solution worked fine for me (on Editor) but it never works if Auto play is off... Any suggestions?

caseypugh commented 5 years ago

I updated the package in the latest release which resolves this issue https://github.com/vimeo/vimeo-unity-sdk/releases/tag/0.9.4

@andersonaraujodl I also tested autoplay in this update and it worked for me.