Java Code Examples for com.google.android.media.tv.companionlibrary.model.Program#getStartTimeUtcMillis()
The following examples show how to use
com.google.android.media.tv.companionlibrary.model.Program#getStartTimeUtcMillis() .
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: EpgSyncJobService.java From xipl with Apache License 2.0 | 5 votes |
/** * Returns {@code true} if the {@code oldProgram} program is the same as the {@code newProgram} * program but should update metadata. This updates the database instead of deleting and * inserting a new program to keep the user's intent, eg. recording this program. */ public boolean shouldUpdateProgramMetadata(Program oldProgram, Program newProgram) { // NOTE: Here, we update the old program if it has the same title and overlaps with the // new program. The test logic is just an example and you can modify this. E.g. check // whether the both programs have the same program ID if your EPG supports any ID for // the programs. return oldProgram.getTitle().equals(newProgram.getTitle()) && oldProgram.getStartTimeUtcMillis() <= newProgram.getEndTimeUtcMillis() && newProgram.getStartTimeUtcMillis() <= oldProgram.getEndTimeUtcMillis(); }
Example 2
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 5 votes |
@Test public void testRepeatProgramDuration() { // If repeat-programs is on, schedule the programs sequentially in a loop. To make every // device play the same program in a given channel and time, we assumes the loop started // from the epoch time. long totalDurationMs = 0; for (Program program : mProgramList) { totalDurationMs += (program.getEndTimeUtcMillis() - program.getStartTimeUtcMillis()); assertTrue(program.getEndTimeUtcMillis() >= program.getStartTimeUtcMillis()); } long programStartTimeMs = mStartMs - mStartMs % totalDurationMs; assertNotSame(0, totalDurationMs); assertTrue(programStartTimeMs > 0); assertTrue(programStartTimeMs <= mStartMs); }
Example 3
Source File: EpgSyncJobService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
/** * Returns {@code true} if the {@code oldProgram} program is the same as the {@code newProgram} * program but should update metadata. This updates the database instead of deleting and * inserting a new program to keep the user's intent, eg. recording this program. */ public boolean shouldUpdateProgramMetadata(Program oldProgram, Program newProgram) { // NOTE: Here, we update the old program if it has the same title and overlaps with the // new program. The test logic is just an example and you can modify this. E.g. check // whether the both programs have the same program ID if your EPG supports any ID for // the programs. return oldProgram.getTitle().equals(newProgram.getTitle()) && oldProgram.getStartTimeUtcMillis() <= newProgram.getEndTimeUtcMillis() && newProgram.getStartTimeUtcMillis() <= oldProgram.getEndTimeUtcMillis(); }
Example 4
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testRepeatProgramDuration() { // If repeat-programs is on, schedule the programs sequentially in a loop. To make every // device play the same program in a given channel and time, we assumes the loop started // from the epoch time. long totalDurationMs = 0; for (Program program : mProgramList) { totalDurationMs += (program.getEndTimeUtcMillis() - program.getStartTimeUtcMillis()); assertTrue(program.getEndTimeUtcMillis() >= program.getStartTimeUtcMillis()); } long programStartTimeMs = mStartMs - mStartMs % totalDurationMs; assertNotSame(0, totalDurationMs); assertTrue(programStartTimeMs > 0); assertTrue(programStartTimeMs <= mStartMs); }
Example 5
Source File: CumulusJobService.java From CumulusTV with MIT License | 4 votes |
@Override public List<Program> getProgramsForChannel(Uri channelUri, Channel channel, long startMs, long endMs) { List<Program> programs = new ArrayList<>(); ChannelDatabase channelDatabase = ChannelDatabase.getInstance(this); Log.d(TAG, "Get programs for " + channel.toString()); JsonChannel jsonChannel = channelDatabase.findChannelByMediaUrl( channel.getInternalProviderData().getVideoUrl()); if (jsonChannel != null && jsonChannel.getEpgUrl() != null && !jsonChannel.getEpgUrl().isEmpty() && epgData.containsKey(jsonChannel.getEpgUrl())) { List<Program> programForGivenTime = new ArrayList<>(); CumulusXmlParser.TvListing tvListing = epgData.get(jsonChannel.getEpgUrl()); if (tvListing == null) { return programs; // Return empty programs. } List<Program> programList = tvListing.getAllPrograms(); // If repeat-programs is on, schedule the programs sequentially in a loop. To make // every device play the same program in a given channel and time, we assumes the // loop started from the epoch time. long totalDurationMs = 0; for (Program program : programList) { totalDurationMs += program.getEndTimeUtcMillis() - program.getStartTimeUtcMillis(); } long programStartTimeMs = startMs - startMs % totalDurationMs; int i = 0; final int programCount = programList.size(); while (programStartTimeMs < endMs) { Program currentProgram = programList.get(i++ % programCount); long programEndTimeMs = currentProgram.getEndTimeUtcMillis(); if (programEndTimeMs < startMs) { programStartTimeMs = programEndTimeMs; continue; } programForGivenTime.add(new Program.Builder() .setTitle(currentProgram.getTitle()) .setDescription(currentProgram.getDescription()) .setContentRatings(currentProgram.getContentRatings()) .setCanonicalGenres(currentProgram.getCanonicalGenres()) .setPosterArtUri(currentProgram.getPosterArtUri()) .setThumbnailUri(currentProgram.getThumbnailUri()) .setInternalProviderData(currentProgram.getInternalProviderData()) .setStartTimeUtcMillis(programStartTimeMs) .setEndTimeUtcMillis(programEndTimeMs) .build() ); programStartTimeMs = programEndTimeMs; } return programForGivenTime; } else { programs.add(new Program.Builder() .setInternalProviderData(channel.getInternalProviderData()) .setTitle(channel.getDisplayName() + " Live") .setDescription(getString(R.string.currently_streaming)) .setPosterArtUri(channel.getChannelLogo()) .setThumbnailUri(channel.getChannelLogo()) .setCanonicalGenres(jsonChannel != null ? jsonChannel.getGenres() : null) .setStartTimeUtcMillis(startMs) .setEndTimeUtcMillis(startMs + 1000 * 60 * 60) // 60 minutes .build()); } return programs; }