本文整理汇总了Java中org.videolan.vlc.MediaWrapper类的典型用法代码示例。如果您正苦于以下问题:Java MediaWrapper类的具体用法?Java MediaWrapper怎么用?Java MediaWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaWrapper类属于org.videolan.vlc包,在下文中一共展示了MediaWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMediaPlayerEvent
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
public void onMediaPlayerEvent(MediaPlayer.Event event) {
switch (event.type) {
case MediaPlayer.Event.Opening:
mSwitchedToVideo = false;
break;
case MediaPlayer.Event.ESAdded:
final boolean forceAudio = (mService.getCurrentMediaWrapper().getFlags() & MediaWrapper.MEDIA_FORCE_AUDIO) != 0;
if (!forceAudio && !mSwitchedToVideo && event.getEsChangedType() == Media.Track.Type.Video) {
mService.switchToVideo();
mSwitchedToVideo = true;
}
break;
case MediaPlayer.Event.Stopped:
hide();
break;
}
}
示例2: getPictureFromCache
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
public static Bitmap getPictureFromCache(MediaWrapper media) {
// mPicture is not null only if passed through
// the ctor which is deprecated by now.
Bitmap b = media.getPicture();
if(b == null) {
BitmapCache cache = BitmapCache.getInstance();
Bitmap picture = cache.getBitmapFromMemCache(media.getLocation());
if(picture == null) {
/* Not in memcache:
* serving the file from the database and
* adding it to the memcache for later use.
*/
picture = readCoverBitmap(media.getArtworkURL());
if (picture == null)
picture = MediaDatabase.getInstance().getPicture(media.getUri());
cache.addBitmapToMemCache(media.getLocation(), picture);
}
return picture;
} else {
return b;
}
}
示例3: deleteMedia
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
public void deleteMedia(int position){
final MediaWrapper media = mVideoAdapter.getItem(position);
final String path = media.getUri().getPath();
VLCApplication.runBackground(new Runnable() {
public void run() {
Util.recursiveDelete(VLCApplication.getAppContext(), new File(path));
}
});
mMediaLibrary.getMediaItems().remove(media);
mVideoAdapter.remove(media);
if (mService != null) {
final List<String> list = mService.getMediaLocations();
if (list != null && list.contains(media.getLocation())) {
mService.removeLocation(media.getLocation());
}
}
}
示例4: doInBackground
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
final ArrayList<MediaWrapper> videoList = mMediaLibrary.getVideoItems();
int size;
// Update video section
if (!videoList.isEmpty()) {
size = videoList.size();
if (NUM_ITEMS_PREVIEW < size)
size = NUM_ITEMS_PREVIEW;
final int total = size;
mRootContainer.post(new Runnable() {
@Override
public void run() {
MediaWrapper item;
for (int i = 0; i < total; ++i) {
item = videoList.get(i);
mVideoAdapter.add(item);
mVideoIndex.put(item.getLocation(), i);
}
}
});
}
return null;
}
示例5: getCoverFromMediaStore
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
private static String getCoverFromMediaStore(Context context, MediaWrapper media) {
final String album = media.getAlbum();
if (album == null)
return null;
ContentResolver contentResolver = context.getContentResolver();
Uri uri = android.provider.MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, new String[]{
MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.ALBUM_ART},
MediaStore.Audio.Albums.ALBUM + " LIKE ?",
new String[]{album}, null);
if (cursor == null) {
// do nothing
} else if (!cursor.moveToFirst()) {
// do nothing
cursor.close();
} else {
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ART);
String albumArt = cursor.getString(titleColumn);
cursor.close();
return albumArt;
}
return null;
}
示例6: update
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
public void update() {
if (mService == null)
return;
mPlayPauseButton.setImageResource(mService.isPlaying() ? R.drawable.ic_pause : R.drawable.ic_play);
if (mService.hasMedia()) {
SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(this);
if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false));
mService.switchToVideo();
finish();
return;
}
mTitleTv.setText(mService.getTitle());
mArtistTv.setText(mService.getArtist());
mProgressBar.setMax((int) mService.getLength());
MediaWrapper MediaWrapper = MediaLibrary.getInstance().getMediaItem(mService.getCurrentMediaLocation());
Bitmap cover = AudioUtil.getCover(this, MediaWrapper, mCover.getWidth());
if (cover == null)
cover = mService.getCover();
if (cover == null)
mCover.setImageResource(R.drawable.background_cone);
else
mCover.setImageBitmap(cover);
}
}
示例7: updateFavorites
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
private void updateFavorites(){
ArrayList<MediaWrapper> favs = MediaDatabase.getInstance().getAllNetworkFav();
int newSize = favs.size(), totalSize = mAdapter.getItemCount();
if (newSize == 0 && mFavorites == 0)
return;
for (int i = 1 ; i <= mFavorites ; ++i){ //remove former favorites
mAdapter.removeItem(totalSize-i, mReadyToDisplay);
}
if (newSize == 0)
mAdapter.removeItem(totalSize-mFavorites-1, mReadyToDisplay); //also remove separator if no more fav
else {
if (mFavorites == 0)
mAdapter.addItem("Network favorites", false, false); //add header if needed
for (MediaWrapper fav : favs)
mAdapter.addItem(fav, false, false); //add new favorites
}
mFavorites = newSize; //update count
}
示例8: onContextPopupMenu
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
if (!AndroidUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
}
PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
MediaWrapper media = mVideoAdapter.getItem(position);
if (media == null)
return;
setContextMenuItems(popupMenu.getMenu(), media);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return handleContextItemSelected(item, position);
}
});
popupMenu.show();
}
示例9: handleMessage
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
final AudioAlbumsSongsFragment fragment = getOwner();
switch (msg.what){
case DELETE_MEDIA:
AudioBrowserListAdapter.ListItem listItem = fragment.mSongsAdapter.getItem(msg.arg1);
MediaWrapper media = listItem.mMediaList.get(0);
final String path = media.getUri().getPath();
fragment.mMediaLibrary.getMediaItems().remove(media);
fragment.mSongsAdapter.removeMedia(media);
fragment.mAlbumsAdapter.removeMedia(media);
if (fragment.mService != null)
fragment.mService.removeLocation(media.getLocation());
fragment.mMediaLibrary.getMediaItems().remove(media);
VLCApplication.runBackground(new Runnable() {
public void run() {
Util.recursiveDelete(VLCApplication.getAppContext(), new File(path));
}
});
break;
}
}
示例10: updateList
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
private void updateList() {
int currentIndex = -1;
if (mService == null)
return;
mSongsListAdapter.clear();
final List<MediaWrapper> audioList = mService.getMedias();
final String currentItem = mService.getCurrentMediaLocation();
if (audioList != null) {
for (int i = 0; i < audioList.size(); i++) {
final MediaWrapper media = audioList.get(i);
if (currentItem != null && currentItem.equals(media.getLocation()))
currentIndex = i;
mSongsListAdapter.add(media);
}
}
mSongsListAdapter.setCurrentIndex(currentIndex);
mSongsList.setSelection(currentIndex);
mSongsListAdapter.notifyDataSetChanged();
}
示例11: getCoverFromMediaStore
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
private static String getCoverFromMediaStore(Context context, MediaWrapper media) {
final String album = media.getAlbum();
if (album == null)
return null;
ContentResolver contentResolver = context.getContentResolver();
Uri uri = android.provider.MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, new String[] {
MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.ALBUM_ART },
MediaStore.Audio.Albums.ALBUM + " LIKE ?",
new String[] { album }, null);
if (cursor == null) {
// do nothing
} else if (!cursor.moveToFirst()) {
// do nothing
cursor.close();
} else {
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ART);
String albumArt = cursor.getString(titleColumn);
cursor.close();
return albumArt;
}
return null;
}
示例12: getListWithPosition
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
/**
* Returns a single list containing all media, along with the position of
* the first media in 'position' in the _new_ single list.
*
* @param outputList The list to be written to.
* @param position Position to retrieve in to _this_ adapter.
* @return The position of 'position' in the new single list, or 0 if not found.
*/
public int getListWithPosition(List<MediaWrapper> outputList, int position) {
int outputPosition = 0;
outputList.clear();
for(int i = 0; i < mItems.size(); i++) {
if(!mItems.get(i).mIsSeparator) {
if(position == i && !mItems.get(i).mMediaList.isEmpty())
outputPosition = outputList.size();
for(MediaWrapper mediaWrapper : mItems.get(i).mMediaList) {
outputList.add(mediaWrapper);
}
}
}
return outputPosition;
}
示例13: doInBackground
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
int size;
MediaWrapper MediaWrapper;
ArrayList<MediaWrapper> mediaList = mMediaLibrary.getVideoItems();
size = mediaList == null ? 0 : mediaList.size();
mMediaIndex = new SimpleArrayMap<String, Integer>(size);
for (int i = 0 ; i < size ; ++i){
MediaWrapper = mediaList.get(i);
mMediaIndex.put(MediaWrapper.getLocation(), Integer.valueOf(i));
publishProgress(MediaWrapper);
}
return null;
}
示例14: getView
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View v = convertView;
MediaWrapper mw = mMediaList.get(position);
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
holder = new ViewHolder();
holder.binding = DataBindingUtil.inflate(inflater, R.layout.audio_browser_item, parent, false);
v = holder.binding.getRoot();
v.setTag(R.layout.audio_browser_item, holder);
} else
holder = (ViewHolder) v.getTag(R.layout.audio_browser_item);
holder.binding.setPosition(position);
holder.binding.setMedia(mw);
holder.binding.setFooter(position != mMediaList.size() - 1);
holder.binding.setClickable(mContextPopupMenuListener != null);
holder.binding.setHandler(this);
holder.binding.executePendingBindings();
return v;
}
示例15: setOverlayProgress
import org.videolan.vlc.MediaWrapper; //导入依赖的package包/类
/**
* update the overlay
*/
private int setOverlayProgress() {
if (mService == null) {
return 0;
}
int time = (int) getTime();
int length = (int) mService.getLength();
if (length == 0) {
MediaWrapper media = MediaDatabase.getInstance().getMedia(mUri);
if (media != null)
length = (int) media.getLength();
}
// Update all view elements
mSeekbar.setMax(length);
mSeekbar.setProgress(time);
if (mSysTime != null)
mSysTime.setText(DateFormat.getTimeFormat(this).format(new Date(System.currentTimeMillis())));
if (time >= 0) mTime.setText(Strings.millisToString(time));
if (length >= 0) mLength.setText(mDisplayRemainingTime && length > 0
? "-" + '\u00A0' + Strings.millisToString(length - time)
: Strings.millisToString(length));
return time;
}