/*
* Copyright (C) 2009 Teleca Poland Sp. z o.o. <android@teleca.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.teleca.jamendo.activity;
import java.util.List;
import org.json.JSONException;
import com.teleca.jamendo.JamendoApplication;
import com.teleca.jamendo.api.Album;
import com.teleca.jamendo.api.JamendoGet2Api;
import com.teleca.jamendo.api.License;
import com.teleca.jamendo.api.Playlist;
import com.teleca.jamendo.api.PlaylistEntry;
import com.teleca.jamendo.api.PlaylistRemote;
import com.teleca.jamendo.api.Track;
import com.teleca.jamendo.api.WSError;
import com.teleca.jamendo.api.impl.JamendoGet2ApiImpl;
import com.teleca.jamendo.dialog.AddToPlaylistDialog;
import com.teleca.jamendo.dialog.LoadingDialog;
import com.teleca.jamendo.dialog.LyricsDialog;
import com.teleca.jamendo.dialog.PlayerAlbumLoadingDialog;
import com.teleca.jamendo.dialog.PlaylistRemoteLoadingDialog;
import com.teleca.jamendo.media.PlayerEngine;
import com.teleca.jamendo.media.PlayerEngineListener;
import com.teleca.jamendo.util.Helper;
import com.teleca.jamendo.widget.ReflectableLayout;
import com.teleca.jamendo.widget.ReflectiveSurface;
import com.teleca.jamendo.widget.RemoteImageView;
import com.teleca.jamendo.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.SlidingDrawer;
import android.widget.TextView;
import android.widget.Toast;
/**
* Central part of the UI. Touching cover fades in 4-way media buttons.
* 4-way media buttons fade out after certain amount of time. Other parts
* of layout are progress bar, total play time, played time, song title,
* artist name and jamendo slider.<br><br>
*
* License information is implemented overlaying CreativeCommons logo over
* the album picture. Information about type of license is retrieved concurrently
* to track bufferring.
*
* @author Lukasz Wisniewski
*/
public class PlayerActivity extends Activity{
private PlayerEngine getPlayerEngine(){
return JamendoApplication.getInstance().getPlayerEngineInterface();
};
private Playlist mPlaylist;
private Album mCurrentAlbum;
// XML layout
private TextView mArtistTextView;
private TextView mSongTextView;
private TextView mCurrentTimeTextView;
private TextView mTotalTimeTextView;
private RatingBar mRatingBar;
private ProgressBar mProgressBar;
private ImageButton mPlayImageButton;
private ImageButton mNextImageButton;
private ImageButton mPrevImageButton;
private ImageButton mStopImageButton;
private RemoteImageView mCoverImageView;
private RemoteImageView mLicenseImageView;
private Animation mFadeInAnimation;
private Animation mFadeOutAnimation;
private ReflectableLayout mReflectableLayout;
private ReflectiveSurface mReflectiveSurface;
private String mBetterRes;
private SlidingDrawer mSlidingDrawer;
/**
* Launch this Activity from the outside, with defined playlist
*
* @param c context from which Activity should be started
* @param a playlist to be played
*/
public static void launch(Context c, Playlist playlist){
Intent intent = new Intent(c, PlayerActivity.class);
intent.putExtra("playlist", playlist);
/*
* For example, consider a task consisting of the activities:
* A, B, C, D. If D calls startActivity() with an Intent that
* resolves to the component of activity B, then C and D will
* be finished and B receive the given Intent, resulting in
* the stack now being: A, B.
*/
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
c.startActivity(intent);
}
/**
* Launch this Activity from the outside, with defined playlist on a remote server
*
* @param c
* @param playlistRemote
*/
public static void launch(Activity c, PlaylistRemote playlistRemote){
Intent intent = new Intent(c, PlayerActivity.class);
new PlaylistRemoteLoadingDialog(c, R.string.loading_playlist, R.string.loading_playlist_fail, intent).execute(playlistRemote);
}
/**
* Launch this Activity from the outside with the given album
*
* @param c Activity from which PlayerActivity should be started
* @param album an album to be played
*/
public static void launch(Activity c, Album album){
new PlayerAlbumLoadingDialog(c, R.string.album_loading, R.string.album_fail).execute(album);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(JamendoApplication.TAG, "PlayerActivity.onCreate");
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.player);
// XML binding
mBetterRes = getResources().getString(R.string.better_res);
mArtistTextView = (TextView)findViewById(R.id.ArtistTextView);
mSongTextView = (TextView)findViewById(R.id.SongTextView);
mCurrentTimeTextView = (TextView)findViewById(R.id.CurrentTimeTextView);
mTotalTimeTextView = (TextView)findViewById(R.id.TotalTimeTextView);
mRatingBar = (RatingBar) findViewById(R.id.TrackRowRatingBar);
mCoverImageView = (RemoteImageView)findViewById(R.id.CoverImageView);
mCoverImageView.setOnClickListener(mCoverOnClickListener);
mCoverImageView.setDefaultImage(R.drawable.no_cd_300);
mProgressBar = (ProgressBar)findViewById(R.id.ProgressBar);
mReflectableLayout = (ReflectableLayout)findViewById(R.id.ReflectableLayout);
mReflectiveSurface = (ReflectiveSurface)findViewById(R.id.ReflectiveSurface);
if(mReflectableLayout != null && mReflectiveSurface != null){
mReflectableLayout.setReflectiveSurface(mReflectiveSurface);
mReflectiveSurface.setReflectableLayout(mReflectableLayout);
}
handleIntent();
mPlayImageButton = (ImageButton)findViewById(R.id.PlayImageButton);
mPlayImageButton.setOnClickListener(mPlayOnClickListener);
mNextImageButton = (ImageButton)findViewById(R.id.NextImageButton);
mNextImageButton.setOnClickListener(mNextOnClickListener);
mPrevImageButton = (ImageButton)findViewById(R.id.PrevImageButton);
mPrevImageButton.setOnClickListener(mPrevOnClickListener);
mStopImageButton = (ImageButton)findViewById(R.id.StopImageButton);
mStopImageButton.setOnClickListener(mStopOnClickListener);
mFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
mFadeInAnimation.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
if(mFadeInAnimation.hasEnded())
mPlayImageButton.startAnimation(mFadeOutAnimation);
}
}, 7500);
}
@Override
public void onAnimationRepeat(Animation anima
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之在线播放器源码-IT计算机-毕业设计.zip (429个子文件)
resources.ap_ 218KB
jamendo.apk 297KB
PlayerActivity.class 15KB
JamendoGet2ApiImpl.class 10KB
DatabaseImpl.class 10KB
BrowsePlaylistActivity.class 9KB
AlbumActivity.class 9KB
HomeActivity.class 8KB
PlaylistActivity.class 8KB
PlayerEngineImpl.class 7KB
PlayerService.class 7KB
JamendoApplication.class 6KB
SearchActivity.class 6KB
DownloadService.class 6KB
SearchActivity$SearchingDialog.class 5KB
AddToPlaylistDialog.class 5KB
DownloadActivity.class 5KB
DownloadTask.class 5KB
RadioActivity.class 5KB
Helper.class 5KB
DownloadDatabaseImpl.class 4KB
ArtistActivity.class 4KB
HomeActivity$NewsTask.class 4KB
R$id.class 4KB
PlayerActivity$UriLoadingDialog.class 4KB
Caller.class 4KB
PlayerActivity$6.class 4KB
JamendoApplication$IntentDownloadInterface.class 4KB
BrowsePlaylistActivity$RemotePlaylistTask.class 4KB
RemoteImageView$DownloadTask.class 4KB
ReviewAdapter.class 4KB
RemoteImageView.class 4KB
R$string.class 4KB
HomeActivity$Top100Task.class 4KB
PlaylistAdapter.class 4KB
AlbumLoadingDialog.class 4KB
SeparatedListAdapter.class 4KB
JamendoApplication$IntentPlayerEngine.class 3KB
DownloadJob.class 3KB
PlayerService$1.class 3KB
DownloadJobAdapter.class 3KB
Playlist.class 3KB
RadioAdapter.class 3KB
PlayerActivity$LicenseTask.class 3KB
AboutDialog.class 3KB
TrackFunctions.class 3KB
BrowsePlaylistActivity$2.class 3KB
LoadingDialog.class 3KB
StarredAlbumsActivity.class 3KB
ArtistLoadingDialog.class 3KB
PlayerAlbumLoadingDialog.class 3KB
RadioActivity$2.class 3KB
ArtistActivity$AddToPlaylistLoadingDialog.class 3KB
AlbumAdapter.class 3KB
MediaScannerNotifier.class 3KB
R$drawable.class 3KB
AlbumActivity$1.class 3KB
StarredAlbumLoading.class 3KB
RadioActivity$1.class 3KB
LyricsDialog$LyricsTask.class 2KB
DrawableAccessor.class 2KB
TrackDatabaseBuilder.class 2KB
PlayerEngineImpl$5.class 2KB
ArrayListAdapter.class 2KB
AlbumDatabaseBuilder.class 2KB
PlaylistRemoteLoadingDialog.class 2KB
PurpleAdapter.class 2KB
RadioDatabaseBuilder.class 2KB
PlaylistActivity$1.class 2KB
AlbumBar.class 2KB
AlbumGridAdapter.class 2KB
ImageAdapter.class 2KB
AlbumActivity$3.class 2KB
LyricsDialog.class 2KB
PlaylistRemoteAdapter.class 2KB
RadioActivity$3.class 2KB
Review.class 2KB
Artist.class 2KB
BrowsePlaylistActivity$5.class 2KB
JamendoGet2Api.class 2KB
AlbumBuilder.class 2KB
ArtistActivity$2.class 2KB
PlayerActivity$CupcakeListener.class 2KB
DownloadHelper.class 2KB
PurpleEntry.class 2KB
XMLUtil.class 2KB
AlbumActivity$2.class 2KB
DownloadService$1.class 2KB
Track.class 2KB
RSSFunctions.class 2KB
BrowsePlaylistActivity$3.class 2KB
BrowsePlaylistActivity$1.class 2KB
PlayerEngineImpl$3.class 2KB
FailureBar.class 2KB
ArtistActivity$1.class 2KB
HomeActivity$1.class 2KB
ReviewBuilder.class 2KB
ReflectiveSurface.class 2KB
TrackBuilder.class 2KB
ArtistActivity$3.class 2KB
共 429 条
- 1
- 2
- 3
- 4
- 5
资源评论
芝麻粒儿
- 粉丝: 5w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功