How to play streaming video using Dropbox API?

家住魔仙堡 提交于 2020-01-13 06:38:40

问题


Now I develope application that play video streaming.

My video fild uploaded at dropbox and using Dropbox Core API and media method.

Media method , Core API

What I made code is this.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    AndroidAuthSession session = buildSession();

    mDBApi = new DropboxAPI<AndroidAuthSession>(session);

    checkAppKeySetup();



    btn_con=(Button)findViewById(R.id.con_btn);
    btn_con.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mLoggedIn) {
                logOut();
            } else {
                if (USE_OAUTH1) {
                mDBApi.getSession().startAuthentication(MainActivity.this);
            } else {
                mDBApi.getSession().startOAuth2Authentication(MainActivity.this);
            }
        }
    }
    });



    btn_play = (Button)findViewById(R.id.movie_btn);
    btn_play.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            try {
                URLpath =  mDBApi.media("https://dl.dropboxusercontent.com/u/xxxxxxxxx/uprightrow.mp4",false);

            } catch (DropboxException e) {
                Log.d("sibal",e.toString());
                e.printStackTrace();
            }

        }
    });

}

I want to make, When I click btn_con, connect with my dropbox (actually, my final purpose will don't make this button. Automatically link) When I click btn_play, using media method to URL, streaming video.

But when I run my application, After click btn_con bring this screen,

and after click btn_play, nothing happended. URL path can't recieve anything TT

how can I solve this problem?


回答1:


this way can solve your problem for auth finish.
In your onResume()

AndroidAuthSession session = mApi.getSession();
if (session.authenticationSuccessful()) {
    try {
        session.finishAuthentication();
        TokenPair tokens = session.getAccessTokenPair();
        Log.i("henry","tokens.key = "+ tokens.key);
        Log.i("henry","tokens.secret = "+ tokens.secret);
        // do something with dropbox api
    }
}

Dropbox don't provide online url for each file so that you can't play streaming video from dropbox



来源:https://stackoverflow.com/questions/21620604/how-to-play-streaming-video-using-dropbox-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!