private static Movie elephantsDream() { MovieBuilder builder = new MovieBuilder(); builder.setId(1) .setTitle("Elephant's Dream") .setDescription( "The story of two strange characters exploring a capricious and seemingly infinite machine. The elder, Proog, acts as a tour-guide and protector, happily showing off the sights and dangers of the machine to his initially curious but increasingly skeptical protege Emo. As their journey unfolds we discover signs that the machine is not all Proog thinks it is, and his guiding takes on a more desperate aspect.") .setCardImage( "https://orange.blender.org/wp-content/themes/orange/images/common/ed_header.jpg?x53801") .setBackgroundImage( "https://orange.blender.org/wp-content/themes/orange/images/common/ed_header.jpg?x53801") .setVideoUrl("https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4") .setContentType("video/mp4") .setWidth(1280) .setHeight(720) .setAudioChannelConfig("2.0") .setPurchasePrice("$8.99") .setRentalPrice("$1.99") .setRatingStyle(Rating.RATING_5_STARS) .setRatingScore(3.5f) .setProductionYear(2006) .setDuration((int) (TimeUnit.MINUTES.toMillis(10) + TimeUnit.SECONDS.toMillis(53))); return builder.createMovie(); }
private static Movie bigBuckBunny() { MovieBuilder builder = new MovieBuilder(); builder.setId(2) .setTitle("Big Buck Bunny") .setDescription( "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.") .setCardImage( "https://peach.blender.org/wp-content/uploads/poster_bunny_big.jpg?x11217") .setBackgroundImage( "https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217") .setVideoUrl( "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4") .setContentType("video/mp4") .setWidth(1280) .setHeight(720) .setAudioChannelConfig("2.0") .setPurchasePrice("$12.99") .setRentalPrice("$1.99") .setRatingStyle(Rating.RATING_5_STARS) .setRatingScore(2.75f) .setProductionYear(2008) .setDuration((int) (TimeUnit.MINUTES.toMillis(9) + TimeUnit.SECONDS.toMillis(56))); return builder.createMovie(); }
/** * Add a movie to the database. * * @return rowId or -1 if failed */ public long addMovie(Movie movie) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_NAME, movie.getTitle()); initialValues.put(KEY_DESCRIPTION, movie.getDescription()); initialValues.put(KEY_ICON, movie.getCardImageUrl()); initialValues.put(KEY_DATA_TYPE, "video/mp4"); initialValues.put(KEY_IS_LIVE, false); initialValues.put(KEY_VIDEO_WIDTH, CARD_WIDTH); initialValues.put(KEY_VIDEO_HEIGHT, CARD_HEIGHT); initialValues.put(KEY_AUDIO_CHANNEL_CONFIG, "2.0"); initialValues.put(KEY_PURCHASE_PRICE, mHelperContext.getString(R.string.buy_2)); initialValues.put(KEY_RENTAL_PRICE, mHelperContext.getString(R.string.rent_2)); initialValues.put(KEY_RATING_STYLE, Rating.RATING_5_STARS); initialValues.put(KEY_RATING_SCORE, 3.5f); initialValues.put(KEY_PRODUCTION_YEAR, 2014); initialValues.put(KEY_COLUMN_DURATION, 0); initialValues.put(KEY_ACTION, mHelperContext.getString(R.string.global_search)); return mDatabase.insert(FTS_VIRTUAL_TABLE, null, initialValues); }
/** * Add an entry to the database for dummy deep link. * * @return rowId or -1 if failed */ public long addMovieForDeepLink(String title, String description, int icon, long duration, String production_year) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_NAME, title); initialValues.put(KEY_DESCRIPTION, description); initialValues.put(KEY_ICON, icon); initialValues.put(KEY_DATA_TYPE, "video/mp4"); initialValues.put(KEY_IS_LIVE, false); initialValues.put(KEY_VIDEO_WIDTH, 1280); initialValues.put(KEY_VIDEO_HEIGHT, 720); initialValues.put(KEY_AUDIO_CHANNEL_CONFIG, "2.0"); initialValues.put(KEY_PURCHASE_PRICE, "Free"); initialValues.put(KEY_RENTAL_PRICE, "Free"); initialValues.put(KEY_RATING_STYLE, Rating.RATING_5_STARS); initialValues.put(KEY_RATING_SCORE, 3.5f); initialValues.put(KEY_PRODUCTION_YEAR, production_year); initialValues.put(KEY_COLUMN_DURATION, duration); return mDatabase.insert(FTS_VIRTUAL_TABLE, null, initialValues); }
private static Movie jurassicPark() { MovieBuilder builder = new MovieBuilder(); builder.setId(3) .setTitle("Jurassic Park") .setDescription( "During a preview tour, a theme park suffers a major power breakdown that allows its cloned dinosaur exhibits to run amok.") .setCardImage( "https://orange.blender.org/wp-content/themes/orange/images/common/ed_header.jpg?x53801") .setBackgroundImage( "https://ackorange.blender.org/wp-content/themes/orange/images/common/ed_header.jpg?x53801") .setVideoUrl("https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4") .setContentType("video/mp4") .setWidth(1280) .setHeight(720) .setAudioChannelConfig("2.0") .setPurchasePrice("$19.99") .setRentalPrice("$9.99") .setRatingStyle(Rating.RATING_5_STARS) .setRatingScore(4.05f) .setProductionYear(1993) .setDuration( (int) (TimeUnit.HOURS.toMillis(2) + TimeUnit.MINUTES.toMillis(7) + TimeUnit.SECONDS.toMillis(15))); return builder.createMovie(); }
private static Movie theIncredibles() { MovieBuilder builder = new MovieBuilder(); builder.setId(4) .setTitle("The Incredibles") .setDescription( "In this lauded Pixar animated film, married superheroes Mr. Incredible (Craig T. Nelson) and Elastigirl (Holly Hunter) are forced to assume mundane lives as Bob and Helen Parr after all super-powered activities have been banned by the government. While Mr. Incredible loves his wife and kids, he longs to return to a life of adventure, and he gets a chance when summoned to an island to battle an out-of-control robot. Soon, Mr. Incredible is in trouble, and it's up to his family to save him.") .setCardImage( "https://peach.blender.org/wp-content/uploads/poster_bunny_big.jpg?x11217") .setBackgroundImage( "https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217") .setVideoUrl( "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4") .setContentType("video/mp4") .setWidth(1280) .setHeight(720) .setAudioChannelConfig("2.0") .setPurchasePrice("$5.99") .setRentalPrice("$4.99") .setRatingStyle(Rating.RATING_5_STARS) .setRatingScore(4f) .setProductionYear(2004) .setDuration( (int) (TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(56) + TimeUnit.SECONDS.toMillis(21))); return builder.createMovie(); }
public void onMetadataUpdate(int i, Object obj) { if (i == 0x10000001 && (obj instanceof Rating)) { mCallback.mCallback(obj); } }
public void onMetadataUpdate(int i, Object obj) { if (i == 0x10000001 && (obj instanceof Rating)) { mCallback.onSetRating(obj); } }
/** * Takes the contents of a JSON object and populates the database * @param jsonObj The JSON object of videos * @throws JSONException if the JSON object is invalid */ public List<ContentValues> buildMedia(JSONObject jsonObj) throws JSONException { JSONArray categoryArray = jsonObj.getJSONArray(TAG_GOOGLE_VIDEOS); List<ContentValues> videosToInsert = new ArrayList<>(); for (int i = 0; i < categoryArray.length(); i++) { JSONArray videoArray; JSONObject category = categoryArray.getJSONObject(i); String categoryName = category.getString(TAG_CATEGORY); videoArray = category.getJSONArray(TAG_MEDIA); for (int j = 0; j < videoArray.length(); j++) { JSONObject video = videoArray.getJSONObject(j); // If there are no URLs, skip this video entry. JSONArray urls = video.optJSONArray(TAG_SOURCES); if (urls == null || urls.length() == 0) { continue; } String title = video.optString(TAG_TITLE); String description = video.optString(TAG_DESCRIPTION); String videoUrl = (String) urls.get(0); // Get the first video only. String bgImageUrl = video.optString(TAG_BACKGROUND); String cardImageUrl = video.optString(TAG_CARD_THUMB); String studio = video.optString(TAG_STUDIO); ContentValues videoValues = new ContentValues(); videoValues.put(VideoContract.VideoEntry.COLUMN_CATEGORY, categoryName); videoValues.put(VideoContract.VideoEntry.COLUMN_NAME, title); videoValues.put(VideoContract.VideoEntry.COLUMN_DESC, description); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_URL, videoUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_CARD_IMG, cardImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_BG_IMAGE_URL, bgImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_STUDIO, studio); // Fixed defaults. videoValues.put(VideoContract.VideoEntry.COLUMN_CONTENT_TYPE, "video/mp4"); videoValues.put(VideoContract.VideoEntry.COLUMN_IS_LIVE, false); videoValues.put(VideoContract.VideoEntry.COLUMN_AUDIO_CHANNEL_CONFIG, "2.0"); videoValues.put(VideoContract.VideoEntry.COLUMN_PRODUCTION_YEAR, 2014); videoValues.put(VideoContract.VideoEntry.COLUMN_DURATION, 0); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_STYLE, Rating.RATING_5_STARS); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_SCORE, 3.5f); if (mContext != null) { videoValues.put(VideoContract.VideoEntry.COLUMN_PURCHASE_PRICE, mContext.getResources().getString(R.string.buy_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_RENTAL_PRICE, mContext.getResources().getString(R.string.rent_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_ACTION, mContext.getResources().getString(R.string.global_search)); } // TODO: Get these dimensions. videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_WIDTH, 1280); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_HEIGHT, 720); videosToInsert.add(videoValues); } } return videosToInsert; }
public static Object newUnratedRating(int ratingStyle) { return Rating.newUnratedRating(ratingStyle); }
public static Object newHeartRating(boolean hasHeart) { return Rating.newHeartRating(hasHeart); }
public static Object newThumbRating(boolean thumbIsUp) { return Rating.newThumbRating(thumbIsUp); }
public static Object newStarRating(int starRatingStyle, float starRating) { return Rating.newStarRating(starRatingStyle, starRating); }
public static Object newPercentageRating(float percent) { return Rating.newPercentageRating(percent); }
public static boolean isRated(Object ratingObj) { return ((Rating) ratingObj).isRated(); }
public static int getRatingStyle(Object ratingObj) { return ((Rating) ratingObj).getRatingStyle(); }
public static boolean hasHeart(Object ratingObj) { return ((Rating) ratingObj).hasHeart(); }
public static boolean isThumbUp(Object ratingObj) { return ((Rating) ratingObj).isThumbUp(); }
public static float getStarRating(Object ratingObj) { return ((Rating) ratingObj).getStarRating(); }
public static float getPercentRating(Object ratingObj) { return ((Rating) ratingObj).getPercentRating(); }
/** * Takes the contents of a JSON object and populates the database * @param jsonObj The JSON object of videos * @throws JSONException if the JSON object is invalid */ public List<ContentValues> buildMedia(JSONObject jsonObj) throws JSONException { JSONArray categoryArray = jsonObj.getJSONArray(TAG_CHILLY_VIDEOS); List<ContentValues> videosToInsert = new ArrayList<>(); for (int i = 0; i < categoryArray.length(); i++) { JSONArray videoArray; JSONObject category = categoryArray.getJSONObject(i); String categoryName = category.getString(TAG_CATEGORY); videoArray = category.getJSONArray(TAG_MEDIA); for (int j = 0; j < videoArray.length(); j++) { JSONObject video = videoArray.getJSONObject(j); // If there are no URLs, skip this video entry. JSONArray urls = video.optJSONArray(TAG_SOURCES); if (urls == null || urls.length() == 0) { continue; } String title = video.optString(TAG_TITLE); String description = video.optString(TAG_DESCRIPTION); String videoUrl = (String) urls.get(0); // Get the first video only. String bgImageUrl = video.optString(TAG_BACKGROUND); String cardImageUrl = video.optString(TAG_CARD_THUMB); String studio = video.optString(TAG_STUDIO); String type = video.optString(TAG_VIDEOTYPE); String year = video.optString(TAG_PRODUCTION_YEAR); ContentValues videoValues = new ContentValues(); videoValues.put(VideoContract.VideoEntry.COLUMN_CATEGORY, categoryName); videoValues.put(VideoContract.VideoEntry.COLUMN_NAME, title); videoValues.put(VideoContract.VideoEntry.COLUMN_DESC, description); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_URL, videoUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_CARD_IMG, cardImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_BG_IMAGE_URL, bgImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_STUDIO, studio); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_TYPE, type); videoValues.put(VideoContract.VideoEntry.COLUMN_PRODUCTION_YEAR, year); videoValues.put(VideoContract.VideoEntry.COLUMN_DURATION, 0); // Fixed defaults. videoValues.put(VideoContract.VideoEntry.COLUMN_CONTENT_TYPE, "video/mp4"); videoValues.put(VideoContract.VideoEntry.COLUMN_IS_LIVE, false); videoValues.put(VideoContract.VideoEntry.COLUMN_AUDIO_CHANNEL_CONFIG, "2.0"); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_STYLE, Rating.RATING_5_STARS); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_SCORE, 3.5f); if (mContext != null) { videoValues.put(VideoContract.VideoEntry.COLUMN_PURCHASE_PRICE, mContext.getResources().getString(R.string.buy_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_RENTAL_PRICE, mContext.getResources().getString(R.string.rent_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_ACTION, mContext.getResources().getString(R.string.global_search)); } // TODO: Get these dimensions. videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_WIDTH, 1280); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_HEIGHT, 720); videosToInsert.add(videoValues); } } return videosToInsert; }
public void onSetRating(Rating rating) { this.mCallback.onSetRating(rating); }
public static void setRating(Object controlsObj, Object ratingObj) { ((android.media.session.MediaController.TransportControls) controlsObj).setRating((Rating) ratingObj); }
public void onMetadataUpdate(int key, Object newValue) { if (key == 268435457 && (newValue instanceof Rating)) { this.mCallback.onSetRating(newValue); } }
public static void putRating(Object builderObj, String key, Object ratingObj) { ((android.media.MediaMetadata.Builder) builderObj).putRating(key, (Rating) ratingObj); }
@Override public void onSetRating(Rating rating) { super.onSetRating(rating); }
public static hk a(Object paramObject) { float f1 = 1.0F; if ((paramObject == null) || (Build.VERSION.SDK_INT < 21)) { return null; } int i = ((Rating)paramObject).getRatingStyle(); if (((Rating)paramObject).isRated()) { switch (i) { default: return null; case 1: if (((Rating)paramObject).hasHeart()) {} for (float f5 = f1;; f5 = 0.0F) { return new hk(1, f5); } case 2: if (((Rating)paramObject).isThumbUp()) {} for (;;) { return new hk(2, f1); f1 = 0.0F; } case 3: case 4: case 5: float f3 = ((Rating)paramObject).getStarRating(); hk localhk; switch (i) { default: Log.e("Rating", "Invalid rating style (" + i + ") for a star rating"); localhk = null; } for (;;) { return localhk; float f4 = 3.0F; for (;;) { if ((f3 >= 0.0F) && (f3 <= f4)) { break label244; } Log.e("Rating", "Trying to set out of range star-based rating"); localhk = null; break; f4 = 4.0F; continue; f4 = 5.0F; } label244: localhk = new hk(i, f3); } } float f2 = ((Rating)paramObject).getPercentRating(); if ((f2 < 0.0F) || (f2 > 100.0F)) { Log.e("Rating", "Invalid percentage-based rating value"); return null; } return new hk(6, f2); } switch (i) { default: return null; } return new hk(i, -1.0F); }
private void initMediaSessions() { mMediaPlayer = new MediaPlayer(); mSession = new MediaSession(getApplicationContext(), "simple player session"); mController =new MediaController(getApplicationContext(), mSession.getSessionToken()); mSession.setCallback(new MediaSession.Callback(){ @Override public void onPlay() { super.onPlay(); Log.e( "MediaPlayerService", "onPlay"); buildNotification( generateAction( android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE ) ); } @Override public void onPause() { super.onPause(); Log.e( "MediaPlayerService", "onPause"); buildNotification(generateAction(android.R.drawable.ic_media_play, "Play", ACTION_PLAY)); } @Override public void onSkipToNext() { super.onSkipToNext(); Log.e( "MediaPlayerService", "onSkipToNext"); //Change media here buildNotification( generateAction( android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE ) ); } @Override public void onSkipToPrevious() { super.onSkipToPrevious(); Log.e( "MediaPlayerService", "onSkipToPrevious"); //Change media here buildNotification( generateAction( android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE ) ); } @Override public void onFastForward() { super.onFastForward(); Log.e( "MediaPlayerService", "onFastForward"); //Manipulate current media here } @Override public void onRewind() { super.onRewind(); Log.e( "MediaPlayerService", "onRewind"); //Manipulate current media here } @Override public void onStop() { super.onStop(); Log.e( "MediaPlayerService", "onStop"); //Stop media player here NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel( 1 ); Intent intent = new Intent( getApplicationContext(), MediaPlayerService.class ); stopService( intent ); } @Override public void onSeekTo(long pos) { super.onSeekTo(pos); } @Override public void onSetRating(Rating rating) { super.onSetRating(rating); } } ); }
public void onSetRating(Rating rating) { mCallback.onSetRating(rating); }