当前位置: 首页>>代码示例>>Java>>正文


Java RatingCompat类代码示例

本文整理汇总了Java中android.support.v4.media.RatingCompat的典型用法代码示例。如果您正苦于以下问题:Java RatingCompat类的具体用法?Java RatingCompat怎么用?Java RatingCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RatingCompat类属于android.support.v4.media包,在下文中一共展示了RatingCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rate

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void rate(RatingCompat rating) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        if (rating != null) {
            _data.writeInt(1);
            rating.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(25, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:19,代码来源:IMediaSession.java

示例2: getConstants

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
@Override
public Map<String, Object> getConstants() {
    Map<String, Object> map = new HashMap<>();
    map.put("STATE_ERROR", PlaybackStateCompat.STATE_ERROR);
    map.put("STATE_STOPPED", PlaybackStateCompat.STATE_STOPPED);
    map.put("STATE_PLAYING", PlaybackStateCompat.STATE_PLAYING);
    map.put("STATE_PAUSED", PlaybackStateCompat.STATE_PAUSED);
    map.put("STATE_BUFFERING", PlaybackStateCompat.STATE_BUFFERING);

    map.put("RATING_HEART", RatingCompat.RATING_HEART);
    map.put("RATING_THUMBS_UP_DOWN", RatingCompat.RATING_THUMB_UP_DOWN);
    map.put("RATING_3_STARS", RatingCompat.RATING_3_STARS);
    map.put("RATING_4_STARS", RatingCompat.RATING_4_STARS);
    map.put("RATING_5_STARS", RatingCompat.RATING_5_STARS);
    map.put("RATING_PERCENTAGE", RatingCompat.RATING_PERCENTAGE);
    return map;
}
 
开发者ID:tanguyantoine,项目名称:react-native-music-control,代码行数:18,代码来源:MusicControlModule.java

示例3: setRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void setRating(RatingCompat rating) {
    try {
        this.mBinder.rate(rating);
    } catch (RemoteException e) {
        Log.e(MediaControllerCompat.TAG, "Dead object in setRating. " + e);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:MediaControllerCompat.java

示例4: onSetRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
@Override
public void onSetRating(RatingCompat rating) {
    if(MusicControlModule.INSTANCE == null) return;
    int type = MusicControlModule.INSTANCE.ratingType;

    if(type == RatingCompat.RATING_PERCENTAGE) {
        sendEvent(context, "setRating", rating.getPercentRating());
    } else if(type == RatingCompat.RATING_HEART) {
        sendEvent(context, "setRating", rating.hasHeart());
    } else if(type == RatingCompat.RATING_THUMB_UP_DOWN) {
        sendEvent(context, "setRating", rating.isThumbUp());
    } else {
        sendEvent(context, "setRating", rating.getStarRating());
    }
}
 
开发者ID:tanguyantoine,项目名称:react-native-music-control,代码行数:16,代码来源:MusicControlListener.java

示例5: rate

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void rate(RatingCompat ratingcompat)
            throws RemoteException
        {
            Parcel parcel;
            Parcel parcel1;
            parcel = Parcel.obtain();
            parcel1 = Parcel.obtain();
            parcel.writeInterfaceToken("android.support.v4.media.session.IMediaSession");
            if (ratingcompat == null)
            {
                break MISSING_BLOCK_LABEL_57;
            }
            parcel.writeInt(1);
            ratingcompat.writeToParcel(parcel, 0);
_L1:
            mRemote.transact(25, parcel, parcel1, 0);
            parcel1.readException();
            parcel1.recycle();
            parcel.recycle();
            return;
            parcel.writeInt(0);
              goto _L1
            ratingcompat;
            parcel1.recycle();
            parcel.recycle();
            throw ratingcompat;
        }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:28,代码来源:IMediaSession$Stub.java

示例6: setRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void setRating(RatingCompat ratingcompat)
{
    Object obj = mControlsObj;
    if (ratingcompat != null)
    {
        ratingcompat = ((RatingCompat) (ratingcompat.getRating()));
    } else
    {
        ratingcompat = null;
    }
    setRating(obj, ratingcompat);
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:13,代码来源:MediaControllerCompat$TransportControlsApi21.java

示例7: setRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void setRating(RatingCompat ratingcompat)
{
    Object obj = mControlsObj;
    if (ratingcompat != null)
    {
        ratingcompat = ((RatingCompat) (ratingcompat.getRating()));
    } else
    {
        ratingcompat = null;
    }
    MediaControllerCompatApi21.TransportControls.setRating(obj, ratingcompat);
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:13,代码来源:MediaControllerCompat.java

示例8: rate

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void rate(RatingCompat ratingcompat)
        throws RemoteException
    {
        Parcel parcel;
        Parcel parcel1;
        parcel = Parcel.obtain();
        parcel1 = Parcel.obtain();
        parcel.writeInterfaceToken("android.support.v4.media.session.IMediaSession");
        if (ratingcompat == null)
        {
            break MISSING_BLOCK_LABEL_57;
        }
        parcel.writeInt(1);
        ratingcompat.writeToParcel(parcel, 0);
_L1:
        mRemote.transact(25, parcel, parcel1, 0);
        parcel1.readException();
        parcel1.recycle();
        parcel.recycle();
        return;
        parcel.writeInt(0);
          goto _L1
        ratingcompat;
        parcel1.recycle();
        parcel.recycle();
        throw ratingcompat;
    }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:28,代码来源:IMediaSession$Stub$Proxy.java

示例9: onSetRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void onSetRating(Object ratingObj) {
    Callback.this.onSetRating(RatingCompat.fromRating(ratingObj));
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:MediaSessionCompat.java

示例10: rate

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void rate(RatingCompat rating) throws RemoteException {
    MediaSessionImplBase.this.postToHandler(12, rating);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:MediaSessionCompat.java

示例11: handleMessage

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
public void handleMessage(Message msg) {
    Callback cb = MediaSessionImplBase.this.mCallback;
    if (cb != null) {
        switch (msg.what) {
            case 1:
                cb.onPlay();
                return;
            case 2:
                cb.onPlayFromMediaId((String) msg.obj, msg.getData());
                return;
            case 3:
                cb.onPlayFromSearch((String) msg.obj, msg.getData());
                return;
            case 4:
                cb.onSkipToQueueItem(((Long) msg.obj).longValue());
                return;
            case 5:
                cb.onPause();
                return;
            case 6:
                cb.onStop();
                return;
            case 7:
                cb.onSkipToNext();
                return;
            case 8:
                cb.onSkipToPrevious();
                return;
            case 9:
                cb.onFastForward();
                return;
            case 10:
                cb.onRewind();
                return;
            case 11:
                cb.onSeekTo(((Long) msg.obj).longValue());
                return;
            case 12:
                cb.onSetRating((RatingCompat) msg.obj);
                return;
            case 13:
                cb.onCustomAction((String) msg.obj, msg.getData());
                return;
            case 14:
                KeyEvent keyEvent = msg.obj;
                Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
                intent.putExtra("android.intent.extra.KEY_EVENT", keyEvent);
                if (!cb.onMediaButtonEvent(intent)) {
                    onMediaButtonEvent(keyEvent, cb);
                    return;
                }
                return;
            case 15:
                Command cmd = msg.obj;
                cb.onCommand(cmd.command, cmd.extras, cmd.stub);
                return;
            case 16:
                MediaSessionImplBase.this.adjustVolume(((Integer) msg.obj).intValue(), 0);
                return;
            case 17:
                MediaSessionImplBase.this.setVolumeTo(((Integer) msg.obj).intValue(), 0);
                return;
            case 18:
                cb.onPlayFromUri((Uri) msg.obj, msg.getData());
                return;
            default:
                return;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:71,代码来源:MediaSessionCompat.java

示例12: initMediaSessions

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
/**
 * Initializes media sessions and receives media events
 */
private void initMediaSessions() {
    // Make sure the media player will acquire a wake-lock while playing. If we don't do
    // that, the CPU might go to sleep while the song is playing, causing playback to stop.
    //
    // Remember that to use this, we have to declare the android.permission.WAKE_LOCK
    // permission in AndroidManifest.xml.
    mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

    PendingIntent buttonReceiverIntent = PendingIntent.getBroadcast(
            getApplicationContext(),
            0,
            new Intent(Intent.ACTION_MEDIA_BUTTON),
            PendingIntent.FLAG_UPDATE_CURRENT
    );

    mSession = new MediaSessionCompat(getApplicationContext(), "simple player session",
            null, buttonReceiverIntent);

    try {
        mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken());

        mSession.setCallback(
                new MediaSessionCompat.Callback() {
                    @Override
                    public void onPlay() {
                        super.onPlay();
                        buildNotification(generateAction(R.drawable.ic_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onPause() {

                        super.onPause();
                        pauseVideo();
                        buildNotification(generateAction(R.drawable.ic_play, "Play", ACTION_PLAY));
                    }

                    @Override
                    public void onSkipToNext() {
                        super.onSkipToNext();
                        if (!isStarting) {
                            playNext();
                        }
                        buildNotification(generateAction(R.drawable.ic_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onSkipToPrevious() {
                        super.onSkipToPrevious();
                        if (!isStarting) {
                            playPrevious();
                        }
                        buildNotification(generateAction(R.drawable.ic_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onStop() {
                        super.onStop();
                        stopPlayer();
                        NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
                        notificationManager.cancel(1);
                        Intent new_intent = new Intent();
                        new_intent.setAction(ACTION_STOP);
                        sendBroadcast(new_intent);
                        Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class);
                        stopService(intent);
                    }

                    @Override
                    public void onSetRating(RatingCompat rating) {
                        super.onSetRating(rating);
                    }
                }
        );
    } catch (RemoteException re) {
        re.printStackTrace();
    }
}
 
开发者ID:pawelpaszki,项目名称:youtube_background_android,代码行数:82,代码来源:BackgroundAudioService.java

示例13: initMediaSessions

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
/**
 * Initializes media sessions and receives media events
 */
private void initMediaSessions() {
    // Make sure the media player will acquire a wake-lock while playing. If we don't do
    // that, the CPU might go to sleep while the song is playing, causing playback to stop.
    //
    // Remember that to use this, we have to declare the android.permission.WAKE_LOCK
    // permission in AndroidManifest.xml.
    mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

    PendingIntent buttonReceiverIntent = PendingIntent.getBroadcast(
            getApplicationContext(),
            0,
            new Intent(Intent.ACTION_MEDIA_BUTTON),
            PendingIntent.FLAG_UPDATE_CURRENT
    );

    mSession = new MediaSessionCompat(getApplicationContext(), "simple player session",
            null, buttonReceiverIntent);

    try {
        mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken());

        mSession.setCallback(
                new MediaSessionCompat.Callback() {
                    @Override
                    public void onPlay() {
                        super.onPlay();
                        buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onPause() {

                        super.onPause();
                        pauseVideo();
                        buildNotification(generateAction(android.R.drawable.ic_media_play, "Play", ACTION_PLAY));
                    }

                    @Override
                    public void onSkipToNext() {
                        super.onSkipToNext();
                        if (!isStarting) {
                            playNext();
                        }
                        buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onSkipToPrevious() {
                        super.onSkipToPrevious();
                        if (!isStarting) {
                            playPrevious();
                        }
                        buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
                    }

                    @Override
                    public void onStop() {
                        super.onStop();
                        stopPlayer();
                        //remove notification and stop service
                        NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
                        notificationManager.cancel(1);
                        Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class);
                        stopService(intent);
                    }

                    @Override
                    public void onSetRating(RatingCompat rating) {
                        super.onSetRating(rating);
                    }
                }
        );
    } catch (RemoteException re) {
        re.printStackTrace();
    }
}
 
开发者ID:smedic,项目名称:Android-YouTube-Background-Player,代码行数:80,代码来源:BackgroundAudioService.java

示例14: onSetRating

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
@Override
public void onSetRating(RatingCompat rating) {
    super.onSetRating(rating);
    Log.v(TAG, "mSessionCallback onSetRating rating=" + rating.toString());
}
 
开发者ID:boybeak,项目名称:BeMusic,代码行数:6,代码来源:PlayManager.java

示例15: updateMediaSessionMetadata

import android.support.v4.media.RatingCompat; //导入依赖的package包/类
private void updateMediaSessionMetadata() {
  if (doMaintainMetadata) {
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    if (player != null && player.isPlayingAd()) {
      builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, 1);
    }
    builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, player == null ? 0
        : player.getDuration() == C.TIME_UNSET ? -1 : player.getDuration());

    if (queueNavigator != null) {
      long activeQueueItemId = queueNavigator.getActiveQueueItemId(player);
      List<MediaSessionCompat.QueueItem> queue = mediaController.getQueue();
      for (int i = 0; queue != null && i < queue.size(); i++) {
        MediaSessionCompat.QueueItem queueItem = queue.get(i);
        if (queueItem.getQueueId() == activeQueueItemId) {
          MediaDescriptionCompat description = queueItem.getDescription();
          Bundle extras = description.getExtras();
          if (extras != null) {
            for (String key : extras.keySet()) {
              Object value = extras.get(key);
              if (value instanceof String) {
                builder.putString(metadataExtrasPrefix + key, (String) value);
              } else if (value instanceof CharSequence) {
                builder.putText(metadataExtrasPrefix + key, (CharSequence) value);
              } else if (value instanceof Long) {
                builder.putLong(metadataExtrasPrefix + key, (Long) value);
              } else if (value instanceof Integer) {
                builder.putLong(metadataExtrasPrefix + key, (Integer) value);
              } else if (value instanceof Bitmap) {
                builder.putBitmap(metadataExtrasPrefix + key, (Bitmap) value);
              } else if (value instanceof RatingCompat) {
                builder.putRating(metadataExtrasPrefix + key, (RatingCompat) value);
              }
            }
          }
          if (description.getTitle() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
                String.valueOf(description.getTitle()));
          }
          if (description.getSubtitle() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,
                String.valueOf(description.getSubtitle()));
          }
          if (description.getDescription() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
                String.valueOf(description.getDescription()));
          }
          if (description.getIconBitmap() != null) {
            builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON,
                description.getIconBitmap());
          }
          if (description.getIconUri() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
                String.valueOf(description.getIconUri()));
          }
          if (description.getMediaId() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                String.valueOf(description.getMediaId()));
          }
          if (description.getMediaUri() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI,
                String.valueOf(description.getMediaUri()));
          }
          break;
        }
      }
    }
    mediaSession.setMetadata(builder.build());
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:71,代码来源:MediaSessionConnector.java


注:本文中的android.support.v4.media.RatingCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。