android.media.Rating Java Examples
The following examples show how to use
android.media.Rating.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoDatabase.java From BuildingForAndroidTV with MIT License | 6 votes |
/** * 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); }
Example #2
Source File: VideoDatabase.java From BuildingForAndroidTV with MIT License | 6 votes |
/** * 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); }
Example #3
Source File: MockDatabase.java From leanback-assistant with Apache License 2.0 | 6 votes |
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(); }
Example #4
Source File: MockDatabase.java From leanback-assistant with Apache License 2.0 | 6 votes |
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(); }
Example #5
Source File: MockDatabase.java From leanback-assistant with Apache License 2.0 | 5 votes |
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(); }
Example #6
Source File: MockDatabase.java From leanback-assistant with Apache License 2.0 | 5 votes |
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(); }
Example #7
Source File: MediaSessionRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void rate(String packageName, int pid, int uid, ISessionControllerCallback caller, Rating rating) { try { mCb.onRate(packageName, pid, uid, caller, rating); } catch (RemoteException e) { Slog.e(TAG, "Remote failure in rate.", e); } }
Example #8
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static Object newHeartRating(boolean hasHeart) { return Rating.newHeartRating(hasHeart); }
Example #9
Source File: MediaSessionCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
@Override public void onSetRating(Rating rating) { mCallback.onSetRating(rating); }
Example #10
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static Object newThumbRating(boolean thumbIsUp) { return Rating.newThumbRating(thumbIsUp); }
Example #11
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static Object newStarRating(int starRatingStyle, float starRating) { return Rating.newStarRating(starRatingStyle, starRating); }
Example #12
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static Object newPercentageRating(float percent) { return Rating.newPercentageRating(percent); }
Example #13
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static boolean isRated(Object ratingObj) { return ((Rating)ratingObj).isRated(); }
Example #14
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static int getRatingStyle(Object ratingObj) { return ((Rating)ratingObj).getRatingStyle(); }
Example #15
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static boolean hasHeart(Object ratingObj) { return ((Rating)ratingObj).hasHeart(); }
Example #16
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static boolean isThumbUp(Object ratingObj) { return ((Rating)ratingObj).isThumbUp(); }
Example #17
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static float getStarRating(Object ratingObj) { return ((Rating)ratingObj).getStarRating(); }
Example #18
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static float getPercentRating(Object ratingObj) { return ((Rating)ratingObj).getPercentRating(); }
Example #19
Source File: MediaMetadataCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static void putRating(Object builderObj, String key, Object ratingObj) { ((MediaMetadata.Builder)builderObj).putRating(key, (Rating)ratingObj); }
Example #20
Source File: VideoDbBuilder.java From androidtv-Leanback with Apache License 2.0 | 4 votes |
/** * 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; }
Example #21
Source File: MediaPlayerService.java From AndroidDemoProjects with Apache License 2.0 | 4 votes |
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); } } ); }
Example #22
Source File: RatingCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static Object newUnratedRating(int ratingStyle) { return Rating.newUnratedRating(ratingStyle); }
Example #23
Source File: MediaControllerCompatApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static void setRating(Object controlsObj, Object ratingObj) { ((MediaController.TransportControls)controlsObj).setRating((Rating)ratingObj); }
Example #24
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static float getPercentRating(Object ratingObj) { return ((Rating) ratingObj).getPercentRating(); }
Example #25
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static float getStarRating(Object ratingObj) { return ((Rating) ratingObj).getStarRating(); }
Example #26
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static boolean isThumbUp(Object ratingObj) { return ((Rating) ratingObj).isThumbUp(); }
Example #27
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static boolean hasHeart(Object ratingObj) { return ((Rating) ratingObj).hasHeart(); }
Example #28
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static int getRatingStyle(Object ratingObj) { return ((Rating) ratingObj).getRatingStyle(); }
Example #29
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static boolean isRated(Object ratingObj) { return ((Rating) ratingObj).isRated(); }
Example #30
Source File: RatingCompatApi21.java From letv with Apache License 2.0 | 4 votes |
public static Object newPercentageRating(float percent) { return Rating.newPercentageRating(percent); }