• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SimpleCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onCreate

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_DEFAULT_CHANNEL_ID, getString(R.string.notification_channel_name), NotificationManagerCompat.IMPORTANCE_DEFAULT);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(notificationChannel);

        AudioAttributes audioAttributes = new AudioAttributes.Builder()
                .setUsage(AudioAttributes.USAGE_MEDIA)
                .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                .build();
        audioFocusRequest = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
                .setOnAudioFocusChangeListener(audioFocusChangeListener)
                .setAcceptsDelayedFocusGain(false)
                .setWillPauseWhenDucked(true)
                .setAudioAttributes(audioAttributes)
                .build();
    }

    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    mediaSession = new MediaSessionCompat(this, "PlayerService");
    mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
    mediaSession.setCallback(mediaSessionCallback);

    Context appContext = getApplicationContext();

    Intent activityIntent = new Intent(appContext, MainActivity.class);
    mediaSession.setSessionActivity(PendingIntent.getActivity(appContext, 0, activityIntent, 0));

    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null, appContext, MediaButtonReceiver.class);
    mediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(appContext, 0, mediaButtonIntent, 0));

    exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), new DefaultTrackSelector(), new DefaultLoadControl());
    exoPlayer.addListener(exoPlayerListener);
    DataSource.Factory httpDataSourceFactory = new OkHttpDataSourceFactory(new OkHttpClient(), Util.getUserAgent(this, getString(R.string.app_name)), null);
    Cache cache = new SimpleCache(new File(this.getCacheDir().getAbsolutePath() + "/exoplayer"), new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 100)); // 100 Mb max
    this.dataSourceFactory = new CacheDataSourceFactory(cache, httpDataSourceFactory, CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
    this.extractorsFactory = new DefaultExtractorsFactory();
}
 
开发者ID:SergeyVinyar,项目名称:AndroidAudioExample,代码行数:43,代码来源:PlayerService.java


示例2: setUp

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  tempFolder = Util.createTempDirectory(getInstrumentation().getContext(), "ExoPlayerTest");
  cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());

  fakeDataSet = new FakeDataSet()
      .setData(MASTER_PLAYLIST_URI, MASTER_PLAYLIST_DATA)
      .setData(MEDIA_PLAYLIST_1_URI, MEDIA_PLAYLIST_DATA)
      .setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence0.ts", 10)
      .setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence1.ts", 11)
      .setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence2.ts", 12)
      .setData(MEDIA_PLAYLIST_2_URI, MEDIA_PLAYLIST_DATA)
      .setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence0.ts", 13)
      .setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence1.ts", 14)
      .setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence2.ts", 15);
  hlsDownloader = getHlsDownloader(MASTER_PLAYLIST_URI);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:19,代码来源:HlsDownloaderTest.java


示例3: configureExoMedia

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
private void configureExoMedia() {
    // Registers the media sources to use the OkHttp client instead of the standard Apache one
    // Note: the OkHttpDataSourceFactory can be found in the ExoPlayer extension library `extension-okhttp`
    ExoMedia.setDataSourceFactoryProvider(new ExoMedia.DataSourceFactoryProvider() {
        @NonNull
        @Override
        public DataSource.Factory provide(@NonNull String userAgent, @Nullable TransferListener<? super DataSource> listener) {
            // Updates the network data source to use the OKHttp implementation
            DataSource.Factory upstreamFactory = new OkHttpDataSourceFactory(new OkHttpClient(), userAgent, listener);

            // Adds a cache around the upstreamFactory
            Cache cache = new SimpleCache(getCacheDir(), new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024));
            return new CacheDataSourceFactory(cache, upstreamFactory, CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
        }
    });
}
 
开发者ID:brianwernick,项目名称:ExoMedia,代码行数:17,代码来源:App.java


示例4: setUp

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation())
      .setManifestUrl(DashTestData.H264_MANIFEST)
      .setFullPlaybackNoSeeking(true)
      .setCanIncludeAdditionalVideoFormats(false)
      .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID,
          DashTestData.H264_CDD_FIXED);
  tempFolder = Util.createTempDirectory(getActivity(), "ExoPlayerTest");
  cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
}
 
开发者ID:y20k,项目名称:transistor,代码行数:13,代码来源:DashDownloadTest.java


示例5: setUp

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  MockitoUtil.setUpMockito(this);
  tempFolder = Util.createTempDirectory(getInstrumentation().getContext(), "ExoPlayerTest");
  cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
}
 
开发者ID:y20k,项目名称:transistor,代码行数:8,代码来源:DashDownloaderTest.java


示例6: createDataSource

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
@Override
public DataSource createDataSource() {
    LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
    SimpleCache simpleCache =
            new SimpleCache(new File(context.getCacheDir(), "media"), evictor);
    return new CacheDataSource(simpleCache, defaultDatasourceFactory.createDataSource(),
            new FileDataSource(), new CacheDataSink(simpleCache, maxFileSize),
            CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR,
            null);
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:11,代码来源:MediaVideoView.java


示例7: DefaultCacheDataSourceFactory

import com.google.android.exoplayer2.upstream.cache.SimpleCache; //导入依赖的package包/类
/***
 * @param context 上下文
 * @param maxCacheSize 缓存大小
 * @param secretKey If not null, cache keys will be stored encrypted on filesystem using AES/CBC.     The key must be 16 bytes long.
 * @param listener the listener
 */
public DefaultCacheDataSourceFactory(@NonNull Context context, long maxCacheSize, byte[] secretKey, @Nullable CacheDataSource.EventListener listener) {
    defaultDatasourceFactory = new JDefaultDataSourceFactory(context);
    simpleCache = new SimpleCache(new File(context.getExternalCacheDir(), "media1"), new LeastRecentlyUsedCacheEvictor(maxCacheSize), secretKey);
    this.listener = listener;
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:12,代码来源:DefaultCacheDataSourceFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TEquals类代码示例发布时间:2022-05-23
下一篇:
Java FilerImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap