com.google.android.media.tv.companionlibrary.model.Channel Java Examples
The following examples show how to use
com.google.android.media.tv.companionlibrary.model.Channel.
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: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 7 votes |
@Test public void testOriginalChannelsProgramSync() throws EpgSyncException { // Tests that programs and channels were correctly obtained from the EpgSyncJobService Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getOriginalProgramsForChannel( channelUri, firstChannel, mStartMs, mEndMs); assertEquals(1, mProgramList.size()); channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(1)); Channel secondChannel = mChannelList.get(1); assertEquals("XML Test Channel", secondChannel.getDisplayName()); assertNotNull(secondChannel.getInternalProviderData()); assertTrue(secondChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getOriginalProgramsForChannel( channelUri, secondChannel, mStartMs, mEndMs); assertEquals(5, mProgramList.size()); }
Example #2
Source File: XmlTvParser.java From xipl with Apache License 2.0 | 6 votes |
private static TvListing parseTvListings(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException { List<Channel> channels = new ArrayList<>(); List<Program> programs = new ArrayList<>(); while (parser.next() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() == XmlPullParser.START_TAG && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) { Channel channel = parseChannel(parser); if (channel != null) { channels.add(channel); } } if (parser.getEventType() == XmlPullParser.START_TAG && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) { Program program = parseProgram(parser); if (program != null) { programs.add(program); } } } return new TvListing(channels, programs); }
Example #3
Source File: ProviderTvInputService.java From xipl with Apache License 2.0 | 6 votes |
@Override public void onPlayChannel(Channel channel) { if (channel.getInternalProviderData() != null) { mProviderTvPlayer = new ProviderTvPlayer(mContext, channel.getInternalProviderData().getVideoUrl()); mProviderTvPlayer.addListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { notifyTimeShiftStatusChanged(TvInputManager.TIME_SHIFT_STATUS_UNSUPPORTED); } if (DEBUG) { Log.d(getClass().getSimpleName(), "Video Url: " + channel.getInternalProviderData().getVideoUrl()); Log.d(getClass().getSimpleName(), "Video format: " + channel.getVideoFormat()); } // Notify when the video is available so the channel surface can be shown to the screen. mProviderTvPlayer.play(); } else { Toast.makeText(mContext, R.string.channel_stream_failure, Toast.LENGTH_SHORT).show(); } }
Example #4
Source File: JsonChannelUnitTest.java From CumulusTV with MIT License | 6 votes |
/** * Tests that we can use the .toChannel method to successfully create a channel object. */ @Test public void testSuccessfulChannelConversion() { JsonChannel jsonChannel = new JsonChannel.Builder() .setAudioOnly(AUDIO_ONLY) .setEpgUrl(EPG_URL) .setGenres(GENRES) .setLogo(LOGO) .setMediaUrl(MEDIA_URL) .setName(NAME) .setNumber(NUMBER) .setSplashscreen(SPLASHSCREEN) .build(); Channel channel = jsonChannel.toChannel(); assertEquals(channel.getDisplayName(), jsonChannel.getName()); }
Example #5
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 6 votes |
@Test public void testRequestSync() throws InterruptedException { // Tests that a sync can be requested and complete LocalBroadcastManager.getInstance(getActivity()).registerReceiver( mSyncStatusChangedReceiver, new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED)); mSyncStatusLatch = new CountDownLatch(2); EpgSyncJobService.cancelAllSyncRequests(getActivity()); EpgSyncJobService.requestImmediateSync(getActivity(), TestTvInputService.INPUT_ID, 1000 * 60 * 60, // 1 hour sync period new ComponentName(getActivity(), TestJobService.class)); mSyncStatusLatch.await(); // Sync is completed List<Channel> channelList = ModelUtils.getChannels(getActivity().getContentResolver()); Log.d("TvContractUtils", channelList.toString()); assertEquals(2, channelList.size()); List<Program> programList = ModelUtils.getPrograms(getActivity().getContentResolver(), TvContract.buildChannelUri(channelList.get(0).getId())); assertEquals(5, programList.size()); }
Example #6
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 6 votes |
@Test public void testChannelsProgramSync() { // Tests that programs and channels were correctly obtained from the EpgSyncJobService Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); assertEquals(1, mProgramList.size()); channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(1)); Channel secondChannel = mChannelList.get(1); assertEquals("XML Test Channel", secondChannel.getDisplayName()); assertNotNull(secondChannel.getInternalProviderData()); assertTrue(secondChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, secondChannel, mStartMs, mEndMs); assertEquals(5, mProgramList.size()); }
Example #7
Source File: XmlTvParser.java From androidtv-sample-inputs with Apache License 2.0 | 6 votes |
private static TvListing parseTvListings(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException { List<Channel> channels = new ArrayList<>(); List<Program> programs = new ArrayList<>(); while (parser.next() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() == XmlPullParser.START_TAG && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) { channels.add(parseChannel(parser)); } if (parser.getEventType() == XmlPullParser.START_TAG && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) { programs.add(parseProgram(parser)); } } return new TvListing(channels, programs); }
Example #8
Source File: XmlTvParser.java From androidtv-sample-inputs with Apache License 2.0 | 6 votes |
private TvListing(List<Channel> channels, List<Program> programs) { this.mChannels = channels; this.mPrograms = new ArrayList<>(programs); // Place programs into the epg map mProgramMap = new HashMap<>(); for (Channel channel : channels) { List<Program> programsForChannel = new ArrayList<>(); Iterator<Program> programIterator = programs.iterator(); while (programIterator.hasNext()) { Program program = programIterator.next(); if (program.getChannelId() == channel.getOriginalNetworkId()) { programsForChannel.add( new Program.Builder(program).setChannelId(channel.getId()).build()); programIterator.remove(); } } mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel); } }
Example #9
Source File: CumulusBrowseService.java From CumulusTV with MIT License | 6 votes |
@Override public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); ChannelDatabase channelDatabase = ChannelDatabase.getInstance(getApplicationContext()); if (parentId.equals(MEDIA_ROOT_ID)) { try { for (Channel channel : channelDatabase.getChannels()) { MediaDescriptionCompat descriptionCompat = new MediaDescriptionCompat.Builder() .setMediaId(channel.getInternalProviderData().getVideoUrl()) .setTitle(channel.getDisplayName()) .setIconUri(Uri.parse(channel.getChannelLogo())) .setSubtitle(getString(R.string.channel_no_xxx, channel.getDisplayNumber())) .setDescription(channel.getDescription()) .setMediaUri(Uri.parse(channel.getInternalProviderData().getVideoUrl())) .build(); mediaItems.add(new MediaBrowserCompat.MediaItem(descriptionCompat, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)); } result.sendResult(mediaItems); } catch (JSONException e) { e.printStackTrace(); } } }
Example #10
Source File: CumulusXmlParser.java From CumulusTV with MIT License | 6 votes |
private TvListing(List<Channel> channels, List<Program> programs) { this.mChannels = channels; this.mPrograms = new ArrayList<>(programs); // Place programs into the epg map mProgramMap = new HashMap<>(); for (Channel channel: channels) { List<Program> programsForChannel = new ArrayList<>(); Iterator<Program> programIterator = programs.iterator(); while (programIterator.hasNext()) { Program program = programIterator.next(); if (program.getChannelId() == channel.getOriginalNetworkId()) { programsForChannel.add(new Program.Builder(program) .setChannelId(channel.getId()) .build()); programIterator.remove(); } } mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel); } }
Example #11
Source File: CumulusXmlParser.java From CumulusTV with MIT License | 6 votes |
private static TvListing parseTvListings(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException { List<Channel> channels = new ArrayList<>(); List<Program> programs = new ArrayList<>(); while (parser.next() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() == XmlPullParser.START_TAG && TAG_CHANNEL.equalsIgnoreCase(parser.getName())) { channels.add(parseChannel(parser)); } if (parser.getEventType() == XmlPullParser.START_TAG && TAG_PROGRAM.equalsIgnoreCase(parser.getName())) { programs.add(parseProgram(parser)); } } return new TvListing(channels, programs); }
Example #12
Source File: XmlTvParser.java From xipl with Apache License 2.0 | 6 votes |
private TvListing(List<Channel> channels, List<Program> programs) { this.mChannels = channels; this.mPrograms = new ArrayList<>(programs); // Place programs into the epg map mProgramMap = new HashMap<>(); for (Channel channel : channels) { List<Program> programsForChannel = new ArrayList<>(); Iterator<Program> programIterator = programs.iterator(); while (programIterator.hasNext()) { Program program = programIterator.next(); if (program.getChannelId() == channel.getOriginalNetworkId()) { programsForChannel.add( new Program.Builder(program).setChannelId(channel.getId()).build()); programIterator.remove(); } } // Don't overwrite a channel's programs list if a key was already existent if (!mProgramMap.containsKey(channel.getOriginalNetworkId())) { mProgramMap.put(channel.getOriginalNetworkId(), programsForChannel); } } }
Example #13
Source File: RichAppLinkSidePanelActivity.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); List<Channel> channels = ModelUtils.getChannels(getContentResolver()); Channel appLinkChannel = null; String displayNumber = getIntent().getStringExtra(RichFeedUtil.EXTRA_DISPLAY_NUMBER); if (displayNumber != null) { for (Channel channel : channels) { if (displayNumber.equals(channel.getDisplayNumber())) { appLinkChannel = channel; break; } } } // Sets the size and position of dialog activity. WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); layoutParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL; layoutParams.width = getResources().getDimensionPixelSize(R.dimen.side_panel_width); layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; getWindow().setAttributes(layoutParams); setContentView(R.layout.rich_app_link_side_panel); if (appLinkChannel != null && appLinkChannel.getAppLinkColor() != 0) { TextView titleView = (TextView) findViewById(R.id.title); titleView.setBackgroundColor(appLinkChannel.getAppLinkColor()); } mAppLinkMenuList = (VerticalGridView) findViewById(R.id.list); mAppLinkMenuList.setAdapter(new AppLinkMenuAdapter()); }
Example #14
Source File: SampleJobService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override public List<Channel> getChannels() { // Add channels through an XMLTV file XmlTvParser.TvListing listings = RichFeedUtil.getRichTvListings(this); List<Channel> channelList = new ArrayList<>(listings.getChannels()); // Build advertisement list for the channel. Advertisement channelAd = new Advertisement.Builder() .setType(Advertisement.TYPE_VAST) .setRequestUrl(TEST_AD_REQUEST_URL) .build(); List<Advertisement> channelAdList = new ArrayList<>(); channelAdList.add(channelAd); // Add a channel programmatically InternalProviderData internalProviderData = new InternalProviderData(); internalProviderData.setRepeatable(true); internalProviderData.setAds(channelAdList); Channel channelTears = new Channel.Builder() .setDisplayName(MPEG_DASH_CHANNEL_NAME) .setDisplayNumber(MPEG_DASH_CHANNEL_NUMBER) .setChannelLogo(MPEG_DASH_CHANNEL_LOGO) .setOriginalNetworkId(MPEG_DASH_ORIGINAL_NETWORK_ID) .setInternalProviderData(internalProviderData) .build(); channelList.add(channelTears); return channelList; }
Example #15
Source File: RichTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override public void onStopRecordingChannel(Channel channelToRecord) { if (DEBUG) { Log.d(TAG, "onStopRecording"); } // Program sources in this sample always include program info, so execution here // indicates an error. notifyError(TvInputManager.RECORDING_ERROR_UNKNOWN); return; }
Example #16
Source File: ChannelDatabase.java From CumulusTV with MIT License | 5 votes |
public List<Channel> getChannels() throws JSONException { List<JsonChannel> jsonChannelList = getJsonChannels(); List<Channel> channelList = new ArrayList<>(); for (int i = 0; i < jsonChannelList.size(); i++) { JsonChannel jsonChannel = jsonChannelList.get(i); Channel channel = jsonChannel.toChannel(); channelList.add(channel); } return channelList; }
Example #17
Source File: EpgSyncWithAdsJobService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
/** * Calls {@link #getOriginalProgramsForChannel(Uri, Channel, long, long)} and then repeats and * inserts ads as needed. */ @Override public final List<Program> getProgramsForChannel( Uri channelUri, Channel channel, long startMs, long endMs) throws EpgSyncException { return repeatAndInsertAds( channel, getOriginalProgramsForChannel(channelUri, channel, startMs, endMs), startMs, endMs); }
Example #18
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { super.setUp(); injectInstrumentation(InstrumentationRegistry.getInstrumentation()); getActivity(); // Delete all channels getActivity() .getContentResolver() .delete( TvContract.buildChannelsUriForInput(TestTvInputService.INPUT_ID), null, null); mSampleJobService = new TestJobService(); mSampleJobService.mContext = getActivity(); mChannelList = mSampleJobService.getChannels(); ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, mChannelList, null); mChannelMap = ModelUtils.buildChannelMap( getActivity().getContentResolver(), TestTvInputService.INPUT_ID); assertNotNull(mChannelMap); assertEquals(2, mChannelMap.size()); // Round start time to the current hour mStartMs = System.currentTimeMillis() - System.currentTimeMillis() % (1000 * 60 * 60); mEndMs = mStartMs + 1000 * 60 * 60 * 24 * 7 * 2; // Two week long sync period assertTrue(mStartMs < mEndMs); Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); }
Example #19
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testRequestSync() throws InterruptedException { // Tests that a sync can be requested and complete LocalBroadcastManager.getInstance(getActivity()) .registerReceiver( mSyncStatusChangedReceiver, new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED)); mSyncStatusLatch = new CountDownLatch(2); EpgSyncJobService.cancelAllSyncRequests(getActivity()); EpgSyncJobService.requestImmediateSync( getActivity(), TestTvInputService.INPUT_ID, 1000 * 60 * 60, // 1 hour sync period new ComponentName(getActivity(), TestJobService.class)); mSyncStatusLatch.await(); // Sync is completed List<Channel> channelList = ModelUtils.getChannels(getActivity().getContentResolver()); Log.d("TvContractUtils", channelList.toString()); assertEquals(2, channelList.size()); List<Program> programList = ModelUtils.getPrograms( getActivity().getContentResolver(), TvContract.buildChannelUri(channelList.get(0).getId())); assertEquals(5, programList.size()); }
Example #20
Source File: TestTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override public void onStopRecordingChannel(Channel channelToRecord) { mIsRecording = false; // Add a sample program into our DVR notifyRecordingStopped(new RecordedProgram.Builder() .setInputId(mInputId) .setTitle("That Gmail Blue Video") .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL) .setStartTimeUtcMillis(System.currentTimeMillis()) .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60) .build()); }
Example #21
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testJobService() { // Tests whether methods to get channels and programs are successful and valid List<Channel> channelList = mSampleJobService.getChannels(); assertEquals(2, channelList.size()); ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, channelList, null); LongSparseArray<Channel> channelMap = ModelUtils.buildChannelMap( getActivity().getContentResolver(), TestTvInputService.INPUT_ID); assertNotNull(channelMap); assertEquals(channelMap.size(), channelList.size()); }
Example #22
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testEpgSyncTask_GetPrograms() throws EpgSyncException { // For repeating channels, test that the program list will continually repeat for the // desired length of time Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); assertEquals(336 * 60 / 15, mProgramList.size()); }
Example #23
Source File: TestJobService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override public List<Channel> getChannels() { Assert.assertNotNull("Please set the static mContext before running", mContext); // Wrap our list in an ArrayList so we will be able to make modifications if necessary Assert.assertNotNull("Set TestJobService.mContext.", mContext); InternalProviderData internalProviderData = new InternalProviderData(); internalProviderData.setRepeatable(true); ArrayList<Channel> testChannels = new ArrayList<>(); testChannels.add( new Channel.Builder() .setOriginalNetworkId(0) .setDisplayName("Test Channel") .setDisplayNumber("1") .setInternalProviderData(internalProviderData) .build()); // Add an XML parsed channel Uri xmlUri = Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.xmltv) .normalizeScheme(); try { InputStream inputStream = mContext.getContentResolver().openInputStream(xmlUri); Assert.assertNotNull(inputStream); testChannels.addAll(XmlTvParser.parse(inputStream).getChannels()); } catch (FileNotFoundException | XmlTvParser.XmlTvParseException e) { throw new RuntimeException( "Exception found of type " + e.getClass().getCanonicalName() + ": " + e.getMessage()); } return testChannels; }
Example #24
Source File: VolatileChannelDatabase.java From CumulusTV with MIT License | 5 votes |
@Override public List<Channel> getChannels() throws JSONException { List<Channel> channelList = new ArrayList<>(); for (int i = 0; i < mJsonChannels.size(); i++) { JsonChannel jsonChannel = (JsonChannel) mJsonChannels.get(i); Channel channel = jsonChannel.toChannel(); channelList.add(channel); } return channelList; }
Example #25
Source File: TifDatabaseIntegrationTest.java From CumulusTV with MIT License | 5 votes |
/** * Test generating a {@link JsonChannel} and inserting that correctly. */ @Test public void testJsonChannelConverter() { JsonChannel jsonChannel = new JsonChannel.Builder() .setName("Hello") .setMediaUrl(MEDIA_URL) .setNumber("1234") .build(); Channel channel = jsonChannel.toChannel(); // This cannot be done until we update the Channel model. }
Example #26
Source File: CumulusJobService.java From CumulusTV with MIT License | 5 votes |
@Override public List<Channel> getChannels() { // Build advertisement list for the channel. Advertisement channelAd = new Advertisement.Builder() .setType(Advertisement.TYPE_VAST) .setRequestUrl(TEST_AD_REQUEST_URL) .build(); List<Advertisement> channelAdList = new ArrayList<>(); channelAdList.add(channelAd); InternalProviderData ipd = new InternalProviderData(); // ipd.setAds(channelAdList); ipd.setRepeatable(true); ipd.setVideoType(TvContractUtils.SOURCE_TYPE_HLS); try { List<Channel> channels = ChannelDatabase.getInstance(this).getChannels(ipd); // Add app linking for (int i = 0; i < channels.size(); i++) { JsonChannel jsonChannel = ChannelDatabase.getInstance(this).findChannelByMediaUrl( channels.get(i).getInternalProviderData().getVideoUrl()); Channel channel = new Channel.Builder(channels.get(i)) .setAppLinkText(getString(R.string.quick_settings)) .setAppLinkIconUri("https://github.com/Fleker/CumulusTV/blob/master/app/src/m" + "ain/res/drawable-xhdpi/ic_play_action_normal.png?raw=true") .setAppLinkPosterArtUri(channels.get(i).getChannelLogo()) .setAppLinkIntent(PlaybackQuickSettingsActivity.getIntent(this, jsonChannel)) .build(); Log.d(TAG, "Adding channel " + channel.getDisplayName()); channels.set(i, channel); } Log.d(TAG, "Returning with " + channels.size() + " channels"); return channels; } catch (JSONException e) { e.printStackTrace(); } Log.w(TAG, "No channels found"); return null; }
Example #27
Source File: JsonChannel.java From CumulusTV with MIT License | 5 votes |
public Channel toChannel(InternalProviderData providerData) { providerData.setVideoUrl(getMediaUrl()); // TODO Add app linking return new Channel.Builder() .setDisplayName(getName()) .setDisplayNumber(getNumber()) .setChannelLogo(getLogo()) .setInternalProviderData(providerData) .setOriginalNetworkId(getMediaUrl().hashCode()) .build(); }
Example #28
Source File: JsonChannel.java From CumulusTV with MIT License | 5 votes |
public Channel toChannel() { InternalProviderData ipd = new InternalProviderData(); ipd.setVideoUrl(getMediaUrl()); ipd.setVideoType(TvContractUtils.SOURCE_TYPE_HLS); return new Channel.Builder() .setDisplayName(getName()) .setDisplayNumber(getNumber()) .setChannelLogo(getLogo()) .setInternalProviderData(ipd) .setOriginalNetworkId(getMediaUrl().hashCode()) .build(); }
Example #29
Source File: ChannelDatabase.java From CumulusTV with MIT License | 5 votes |
public List<Channel> getChannels(InternalProviderData providerData) throws JSONException { List<JsonChannel> jsonChannelList = getJsonChannels(); List<Channel> channelList = new ArrayList<>(); for (int i = 0; i < jsonChannelList.size(); i++) { JsonChannel jsonChannel = jsonChannelList.get(i); Channel channel = jsonChannel.toChannel(providerData); channelList.add(channel); } return channelList; }
Example #30
Source File: XmlTvAdvertisementTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testAdvertisementParsing() throws XmlTvParser.XmlTvParseException, ParseException { long epochStartTime = 0; String requestUrl1 = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480" + "&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s" + "&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1" + "&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator="; String requestUrl2 = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480" + "&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s" + "&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1" + "&cust_params=deployment%3Ddevsite%26sample_ct%3Dredirectlinear&correlator="; String testXmlFile = "xmltv.xml"; InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(testXmlFile); XmlTvParser.TvListing listings = XmlTvParser.parse(inputStream); // Channel 1 should have one VAST advertisement. Channel adChannel = listings.getChannels().get(1); assertNotNull(adChannel.getInternalProviderData()); List<Advertisement> adChannelAds = adChannel.getInternalProviderData().getAds(); assertEquals(1, adChannelAds.size()); assertEquals(epochStartTime, adChannelAds.get(0).getStartTimeUtcMillis()); assertEquals(epochStartTime, adChannelAds.get(0).getStopTimeUtcMillis()); assertEquals(Advertisement.TYPE_VAST, adChannelAds.get(0).getType()); // Channel 0 should not have any advertisement. Channel noAdChannel = listings.getChannels().get(0); assertNotNull(noAdChannel.getInternalProviderData()); List<Advertisement> noAdChannelAds = noAdChannel.getInternalProviderData().getAds(); assertEquals(0, noAdChannelAds.size()); // Program 7 should have 2 advertisements with different request tags. Program adProgram = listings.getAllPrograms().get(7); assertNotNull(adProgram.getInternalProviderData()); InternalProviderData adProgramData = adProgram.getInternalProviderData(); List<Advertisement> adProgramAds = adProgramData.getAds(); assertEquals(2, adProgramAds.size()); assertEquals(requestUrl1, adProgramAds.get(0).getRequestUrl()); assertEquals(requestUrl2, adProgramAds.get(1).getRequestUrl()); }