[Android] [PATCH 1/3] add MediaParcelable
Thomas Guillem
thomas at gllm.fr
Mon Jan 5 15:28:16 CET 2015
Parcelable wrapper of Media class.
---
.../videolan/vlc/interfaces/MediaParcelable.aidl | 23 ++++++++
.../videolan/vlc/interfaces/MediaParcelable.java | 68 ++++++++++++++++++++++
2 files changed, 91 insertions(+)
create mode 100644 vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.aidl
create mode 100644 vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.java
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.aidl b/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.aidl
new file mode 100644
index 0000000..21ddf18
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.aidl
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * MediaParcelable.aidl
+ *****************************************************************************
+ * Copyright © 2011-2014 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+package org.videolan.vlc.interfaces;
+
+parcelable MediaParcelable;
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.java b/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.java
new file mode 100644
index 0000000..dd0f372
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/interfaces/MediaParcelable.java
@@ -0,0 +1,68 @@
+package org.videolan.vlc.interfaces;
+
+import org.videolan.libvlc.Media;
+
+import android.graphics.Bitmap;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class MediaParcelable implements Parcelable {
+ public final Media media;
+
+ public MediaParcelable(Media media) {
+ this.media = media;
+ }
+
+ public MediaParcelable(Parcel in) {
+ media = new Media(in.readString(),
+ in.readLong(),
+ in.readLong(),
+ in.readInt(),
+ (Bitmap) in.readParcelable(Bitmap.class.getClassLoader()),
+ in.readString(),
+ in.readString(),
+ in.readString(),
+ in.readString(),
+ in.readString(),
+ in.readInt(),
+ in.readInt(),
+ in.readString(),
+ in.readInt(),
+ in.readInt(),
+ in.readInt());
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeValue(media.getLocation());
+ dest.writeLong(media.getTime());
+ dest.writeLong(media.getLength());
+ dest.writeInt(media.getType());
+ dest.writeParcelable(media.getPicture(), flags);
+ dest.writeValue(media.getTitle());
+ dest.writeValue(media.getArtist());
+ dest.writeValue(media.getGenre());
+ dest.writeValue(media.getAlbum());
+ dest.writeValue(media.getAlbumArtist());
+ dest.writeInt(media.getWidth());
+ dest.writeInt(media.getHeight());
+ dest.writeValue(media.getArtworkURL());
+ dest.writeInt(media.getAudioTrack());
+ dest.writeInt(media.getSpuTrack());
+ dest.writeInt(media.getTrackNumber());
+ }
+
+ public static final Parcelable.Creator<MediaParcelable> CREATOR = new Parcelable.Creator<MediaParcelable>() {
+ public MediaParcelable createFromParcel(Parcel in) {
+ return new MediaParcelable(in);
+ }
+ public MediaParcelable[] newArray(int size) {
+ return new MediaParcelable[size];
+ }
+ };
+}
\ No newline at end of file
--
2.1.3
More information about the Android
mailing list