Android Open Source - Android-VKontakte-SDK Video






From Project

Back to project page Android-VKontakte-SDK.

License

The source code is released under:

MIT License

If you think the Android project Android-VKontakte-SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.perm.kate.api;
//  w ww. jav  a  2s .co m
import java.io.Serializable;
import org.json.JSONException;
import org.json.JSONObject;

public class Video implements Serializable{
    private static final long serialVersionUID = 1L;
    public long vid;
    public long owner_id;
    public String title;
    public String description;
    public long duration;
    public String link1;
    public String image;//130*97
    public String image_big;//320*240
    //public String photo_640;
    public long date;
    public String player;
    //files
    public String external;
    public String mp4_240;
    public String mp4_360;
    public String mp4_480;
    public String mp4_720;
    public String flv_320;
    public String access_key;//used when private video attached to message
    public int views;
    
    
    public static Video parse(JSONObject o) throws NumberFormatException, JSONException{
        Video v = new Video();
        v.vid = o.getLong("id");
        v.owner_id = o.getLong("owner_id");
        v.title = Api.unescape(o.optString("title"));
        v.duration = o.optLong("duration");
        v.description = Api.unescape(o.optString("description"));
        v.image = o.optString("photo_130");
        //notifications.get ?????????? ????? ??-???????? ? ???? like_video - ??? ? API
        if(!o.has("photo_130") && o.has("image"))
            v.image = o.optString("image");
        v.image_big = o.optString("photo_320");
        //notifications.get ?????????? ????? ??-???????? ? ???? like_video - ??? ? API
        if(!o.has("photo_320") && o.has("image_medium"))
            v.image_big = o.optString("image_medium");
        v.date = o.optLong("date");
        v.player = o.optString("player");
        if (o.has("views"))
            v.views = o.getInt("views");
        
        JSONObject files=o.optJSONObject("files");
        if(files!=null){
            v.external = files.optString("external");
            v.mp4_240 = files.optString("mp4_240");
            v.mp4_360 = files.optString("mp4_360");
            v.mp4_480 = files.optString("mp4_480");
            v.mp4_720 = files.optString("mp4_720");
            v.flv_320 = files.optString("flv_320");
        }
        return v;
    }
    
    public static Video parseForAttachments(JSONObject o) throws NumberFormatException, JSONException{
        Video v = new Video();
        v.vid = o.getLong("id");
        v.owner_id = o.getLong("owner_id");
        v.title = Api.unescape(o.getString("title"));
        v.duration = o.getLong("duration");
        v.description = Api.unescape(o.optString("description"));
        v.image = o.optString("photo_130");
        v.image_big = o.optString("photo_320");
        v.date = o.optLong("date");
        v.player = o.optString("player");
        v.access_key = o.optString("access_key");
        return v;
    }
    
    public String getVideoUrl() {
        return getVideoUrl(owner_id, vid);
    }
    
    public static String getVideoUrl(long owner_id, long video_id) {
        String res = null;
        String base_url = "http://vk.com/";
        res = base_url + "video" + owner_id + "_" + video_id;
        //sample http://vkontakte.ru/video4491835_158963813
        //http://79.gt2.vkadre.ru/assets/videos/f6b1af1e4258-24411750.vk.flv
        return res;
    }
}




Java Source Code List

com.perm.kate.api.Album.java
com.perm.kate.api.Api.java
com.perm.kate.api.Attachment.java
com.perm.kate.api.AudioAlbum.java
com.perm.kate.api.Audio.java
com.perm.kate.api.Auth.java
com.perm.kate.api.BanInfo.java
com.perm.kate.api.BannArg.java
com.perm.kate.api.City.java
com.perm.kate.api.CommentList.java
com.perm.kate.api.Comment.java
com.perm.kate.api.Constants.java
com.perm.kate.api.Contact.java
com.perm.kate.api.Counters.java
com.perm.kate.api.Country.java
com.perm.kate.api.Document.java
com.perm.kate.api.FriendsList.java
com.perm.kate.api.Geo.java
com.perm.kate.api.Gift.java
com.perm.kate.api.Graffiti.java
com.perm.kate.api.GroupBanItem.java
com.perm.kate.api.GroupTopic.java
com.perm.kate.api.Group.java
com.perm.kate.api.IdsPair.java
com.perm.kate.api.KException.java
com.perm.kate.api.LastActivity.java
com.perm.kate.api.Link.java
com.perm.kate.api.Media.java
com.perm.kate.api.Message.java
com.perm.kate.api.NameCases.java
com.perm.kate.api.NewsItem.java
com.perm.kate.api.NewsJTags.java
com.perm.kate.api.NewsTypes.java
com.perm.kate.api.Newsfeed.java
com.perm.kate.api.Note.java
com.perm.kate.api.Notification.java
com.perm.kate.api.Notifications.java
com.perm.kate.api.Page.java
com.perm.kate.api.Params.java
com.perm.kate.api.PhotoComment.java
com.perm.kate.api.PhotoTag.java
com.perm.kate.api.Photo.java
com.perm.kate.api.Place.java
com.perm.kate.api.Reply.java
com.perm.kate.api.SearchDialogItem.java
com.perm.kate.api.User.java
com.perm.kate.api.Video.java
com.perm.kate.api.VkApp.java
com.perm.kate.api.VkPollAnswer.java
com.perm.kate.api.VkPoll.java
com.perm.kate.api.VkStatus.java
com.perm.kate.api.WallMessage.java
com.perm.kate.api.sample.Account.java
com.perm.kate.api.sample.Constants.java
com.perm.kate.api.sample.LoginActivity.java
com.perm.kate.api.sample.MainActivity.java
com.perm.utils.Utils.java
com.perm.utils.WrongResponseCodeException.java