當前位置: 首頁>>代碼示例>>Java>>正文


Java Util.getUserAgent方法代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.util.Util.getUserAgent方法的典型用法代碼示例。如果您正苦於以下問題:Java Util.getUserAgent方法的具體用法?Java Util.getUserAgent怎麽用?Java Util.getUserAgent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.exoplayer2.util.Util的用法示例。


在下文中一共展示了Util.getUserAgent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EncryptedFileDataSourceFactory

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
/**
 * Instantiates a new Encrypted file data source factory.
 *
 * @param context         the context
 * @param cipher          the cipher
 * @param secretKeySpec   the secret key spec
 * @param ivParameterSpec the iv parameter spec
 * @param listener        the listener
 */
public EncryptedFileDataSourceFactory(Context context, Cipher cipher, SecretKeySpec secretKeySpec, IvParameterSpec ivParameterSpec, TransferListener<? super DataSource> listener) {
    mCipher = cipher;
    mSecretKeySpec = secretKeySpec;
    mIvParameterSpec = ivParameterSpec;
    mTransferListener = listener;
    String userAgent = Util.getUserAgent(context, context.getPackageName());
    this.context = context.getApplicationContext();
    this.baseDataSourceFactory = new DefaultDataSourceFactory(context, userAgent);
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:19,代碼來源:EncryptedFileDataSourceFactory.java

示例2: startPlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public void startPlayer() {
    if(exoPlayer==null){
        exoPlayer =
                ExoPlayerFactory.newSimpleInstance(
                        context, new DefaultTrackSelector(), new DefaultLoadControl());
        exoPlayer.addListener(this);
    }
    exoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
            context, Util.getUserAgent(context, "uamp"), null);
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    MediaSource mediaSource = new ExtractorMediaSource(
            Uri.parse(currentUrl), dataSourceFactory, extractorsFactory, null, null);
    exoPlayer.prepare(mediaSource);
    configPlayer();
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:18,代碼來源:MediaPlayback21.java

示例3: initializePlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private void initializePlayer(Uri videoUri){
    if (mExoPlayer == null){
        TrackSelector trackSelector = new DefaultTrackSelector();
        LoadControl loadControl = new DefaultLoadControl();
        mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
        mExoPlayer.addListener(this);
        mExoPlayer.seekTo(currentPosition);
        mPlayerView.setPlayer(mExoPlayer);
        String userAgent = Util.getUserAgent(getContext(), "Tasty");
        MediaSource mediaSource = new ExtractorMediaSource(videoUri, new DefaultDataSourceFactory(
                getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
        mExoPlayer.prepare(mediaSource);
        if (playWhenReady) mExoPlayer.setPlayWhenReady(true);
        else mExoPlayer.setPlayWhenReady(false);
    }
}
 
開發者ID:harrynp,項目名稱:BakingApp,代碼行數:17,代碼來源:StepDetailFragment.java

示例4: doInBackground

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
protected List<SampleGroup> doInBackground(String... uris) {
  List<SampleGroup> result = new ArrayList<>();
  Context context = getApplicationContext();
  String userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
  DataSource dataSource = new DefaultDataSource(context, null, userAgent, false);
  for (String uri : uris) {
    DataSpec dataSpec = new DataSpec(Uri.parse(uri));
    InputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
    try {
      readSampleGroups(new JsonReader(new InputStreamReader(inputStream, "UTF-8")), result);
    } catch (Exception e) {
      Log.e(TAG, "Error loading sample list: " + uri, e);
      sawError = true;
    } finally {
      Util.closeQuietly(dataSource);
    }
  }
  return result;
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:21,代碼來源:SampleChooserActivity.java

示例5: onCreate

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_playback);
	ButterKnife.bind(this);
	mSurfaceView.setKeepScreenOn(true);

	mPlaybackControllFragment = (OverlayFragment) getFragmentManager().findFragmentById(R.id.playback_controls_fragment);

	mUserAgent = Util.getUserAgent(this, getResources().getString(R.string.app_name));
	synchronized (this) {
		if (player == null) {
			setupPlayer();
		}
	}
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:17,代碼來源:PlayerActivity.java

示例6: setupPlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private SimpleExoPlayer setupPlayer(){
	Log.d(TAG,"Setting up Player.");
	videoView.setKeepScreenOn(true);

	mUserAgent = Util.getUserAgent(getContext(), getResources().getString(R.string.app_name));

	AdaptiveTrackSelection.Factory trackSelectorFactory
			= new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
	DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackSelectorFactory);
	LoadControl loadControl = new DefaultLoadControl();
	DefaultRenderersFactory renderersFactory
			= new DefaultRenderersFactory(getContext(), null, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);


	exoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
	MyListener listener = new MyListener(exoPlayer, this);
	exoPlayer.addVideoListener(listener);
	exoPlayer.addListener(listener);

	exoPlayer.setPlayWhenReady(mPlaybackState);

	exoPlayer.prepare(buildMediaSource(Uri.parse(mRecording.getRecordingUrl()),""));
	return exoPlayer;
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix,代碼行數:25,代碼來源:ExoPlayerFragment.java

示例7: ExoPlayerInstance

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private ExoPlayerInstance() {
    this.context = ExpressApplication.getApplication();
    DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
    mainHandler = new Handler();
    defaultExtractorsFactory = new DefaultExtractorsFactory();
    mediaDataSourceFactory = new DefaultDataSourceFactory(context, defaultBandwidthMeter,
            new OkHttpDataSourceFactory(new OkHttpClient.Builder().build(),
                    Util.getUserAgent(context, "Tumbviewer"),
                    defaultBandwidthMeter, CacheControl.FORCE_NETWORK));
    TrackSelection.Factory factory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter);
    trackSelector = new DefaultTrackSelector(factory);
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:13,代碼來源:ExoPlayerInstance.java

示例8: initExoPlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private void initExoPlayer() {
    DefaultBandwidthMeter bwMeter = new DefaultBandwidthMeter();
    AdaptiveTrackSelection.Factory trackFactory = new AdaptiveTrackSelection.Factory(bwMeter);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackFactory);
    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    videoView.setPlayer(player);

    DataSource.Factory dsFactory = new DefaultDataSourceFactory(getBaseContext(),
            Util.getUserAgent(this, "Traxy"), bwMeter);
    ExtractorsFactory exFactory = new DefaultExtractorsFactory();
    Uri mediaUri = Uri.parse(entry.getUrl());
    MediaSource videoSource = new ExtractorMediaSource(mediaUri,
            dsFactory, exFactory, null, null);
    player.prepare(videoSource);
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:16,代碼來源:MediaViewActivity.java

示例9: PlayerController

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
public PlayerController(Context context) {
    this.bandwidthMeter = new DefaultBandwidthMeter();
    this.loadControl = new DefaultLoadControl();
    this.extractorsFactory = new DefaultExtractorsFactory();
    this.trackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    this.dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context.getApplicationContext(), TAG_NAME), (TransferListener<? super DataSource>) bandwidthMeter);
    this.trackSelector = new DefaultTrackSelector(trackSelectionFactory);
    this.player = ExoPlayerFactory.newSimpleInstance(context, this.trackSelector, this.loadControl);
    this.playerView = new PlayerView(context,this.player);
}
 
開發者ID:herudi,項目名稱:react-native-exoplayer-intent-video,代碼行數:11,代碼來源:PlayerController.java

示例10: onCreate

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (!isPlaying) {
        Handler mainHandler = new Handler();
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);

        LoadControl loadControl = new DefaultLoadControl();

        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(MainActivity.this, trackSelector, loadControl);
        SimpleExoPlayerView playerView = (SimpleExoPlayerView) findViewById(R.id.videoView);
        playerView.setPlayer(player);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this,
                Util.getUserAgent(MainActivity.this, "yourApplicationName"));
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("https://r7---sn-3c27ln7k.googlevideo.com/videoplayback?id=6fb497d0971b8cdf&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-3c27ln7k&ms=nxu&mv=m&nh=IgphcjAzLmticDAxKgkxMjcuMC4wLjE&pl=22&sc=yes&mime=video/mp4&lmt=1486083166327499&mt=1486135406&ip=134.249.158.189&ipbits=8&expire=1486164239&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,nh,pl,sc,mime,lmt&signature=3BB06D8D4294F8C49B3CE910B3D6849954302BB1.02ABE00700DFCEF715E72D0EFB73B67841E659F8&key=ck2&ratebypass=yes&title=%5BAnime365%5D%20Kuzu%20no%20Honkai%20-%2004%20(t1174045)"), dataSourceFactory,
                new DefaultExtractorsFactory(), null, null);
        player.prepare(mediaSource);
        player.setPlayWhenReady(true);

    }
}
 
開發者ID:CrazyDude1994,項目名稱:lostfilm-android-client,代碼行數:28,代碼來源:MainActivity.java

示例11: initializePlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private void initializePlayer(Uri mediaUri) {
    if (mExoPlayer == null) {
        // Create an instance of the ExoPlayer.
        TrackSelector trackSelector = new DefaultTrackSelector();
        LoadControl loadControl = new DefaultLoadControl();
        mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
        binding.exoStepFragmentPlayerView.setPlayer(mExoPlayer);
        mExoPlayer.addListener(this);
        String userAgent = Util.getUserAgent(getContext(), "RecipeStepVideo");
        MediaSource mediaSource = new ExtractorMediaSource(mediaUri, new DefaultDataSourceFactory(
                getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
        mExoPlayer.prepare(mediaSource);
        mExoPlayer.setPlayWhenReady(true);
    }
}
 
開發者ID:twisstosin,項目名稱:UdacityBakingAndroid,代碼行數:16,代碼來源:StepFragment.java

示例12: onCreate

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    // load app state
    loadAppState(getApplication());

    // set up variables
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    mStationMetadataReceived = false;
    mSession = createMediaSession(this);

    mUserAgent = Util.getUserAgent(this, APPLICATION_NAME);

    // create Wifi and wake locks
    mWifiLock = ((WifiManager) this.getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "Transistor_wifi_lock");
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor_wake_lock");

    // create media controller
    try {
        mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken());
    } catch (RemoteException e) {
        LogHelper.e(LOG_TAG, "RemoteException: " + e);
        e.printStackTrace();
    }

    // get instance of mExoPlayer
    createExoPlayer();
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:32,代碼來源:PlayerService.java

示例13: getUserAgent

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
public static String getUserAgent(Context context) {
    if (userAgent == null) {
        userAgent = Util.getUserAgent(context.getApplicationContext(), "ReactNativeVideo");
    }
    return userAgent;
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:7,代碼來源:DataSourceUtil.java

示例14: initPlayer

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private void initPlayer() {
    // Produces DataSource instances through which media data is loaded.
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, getString(R.string.app_name)), null);
    // Produces Extractor instances for parsing the media data.
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    // This is the MediaSource representing the media to be played.
    MediaSource videoSource = new ExtractorMediaSource(videoUri,
            dataSourceFactory, extractorsFactory, null, null);

    DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this);

    // Create the player
    player = ExoPlayerFactory.newSimpleInstance(renderersFactory,
            new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(null)),
            new DefaultLoadControl());

    // Bind the player to the view.
    SimpleExoPlayerView simpleExoPlayerView = findViewById(R.id.simpleExoPlayerView);
    simpleExoPlayerView.setPlayer(player);

    // Prepare the player with the source.
    player.prepare(videoSource);
    player.setRepeatMode(Player.REPEAT_MODE_ONE);
    player.setPlayWhenReady(true);

    final ImageButton playPause = findViewById(R.id.play_pause);
    player.addListener(new SimpleEventListener() {
        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            //update PlayPause-Button
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (player.getPlayWhenReady()) {
                    playPause.setImageResource(R.drawable.play_to_pause_avd);
                } else {
                    playPause.setImageResource(R.drawable.pause_to_play_avd);
                }

                Drawable d = playPause.getDrawable();
                if (d instanceof Animatable) {
                    ((Animatable) d).start();
                }
            } else {
                if (player.getPlayWhenReady()) {
                    playPause.setImageResource(R.drawable.ic_pause_white_24dp);
                } else {
                    playPause.setImageResource(R.drawable.ic_play_arrow_white_24dp);
                }
            }
        }
    });
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:53,代碼來源:VideoPlayerActivity.java

示例15: buildHttpDataSourceFactory

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
public static
@NonNull
HttpDataSource.Factory buildHttpDataSourceFactory(@NonNull Context context, @NonNull DefaultBandwidthMeter bandwidthMeter) {
    return new DefaultHttpDataSourceFactory(Util.getUserAgent(context, "TubiExoPlayer"), bandwidthMeter);
}
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:6,代碼來源:MediaHelper.java


注:本文中的com.google.android.exoplayer2.util.Util.getUserAgent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。