问题
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 TThow 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