use of com.google.android.exoplayer2.util.Log in project android-player-samples by BrightcoveOS.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
brightcoveVideoView.getEventEmitter().on(EventType.DID_SET_SOURCE, new EventListener() {
@Override
public void processEvent(Event event) {
ExoPlayerVideoDisplayComponent exoPlayerVideoDisplayComponent = (ExoPlayerVideoDisplayComponent) brightcoveVideoView.getVideoDisplay();
exoPlayerVideoDisplayComponent.setMetadataListener(new ExoPlayerVideoDisplayComponent.MetadataListener() {
@Override
public void onMetadata(Metadata metadata) {
for (int i = 0; i < metadata.length(); i++) {
Metadata.Entry entry = metadata.get(i);
if (entry instanceof Id3Frame) {
Id3Frame id3Frame = (Id3Frame) entry;
Log.v(TAG, "id3 Frame id: " + id3Frame.id);
}
}
}
});
}
});
Video video = Video.createVideo("https://s3.amazonaws.com/as-zencoder/hls-timed-metadata/test.m3u8", DeliveryType.HLS);
video.getProperties().put(Video.Fields.PUBLISHER_ID, "5420904993001");
brightcoveVideoView.add(video);
brightcoveVideoView.start();
// Log whether or not instance state in non-null.
if (savedInstanceState != null) {
Log.v(TAG, "Restoring saved position");
} else {
Log.v(TAG, "No saved state");
}
}
use of com.google.android.exoplayer2.util.Log in project ExoPlayer by google.
the class EventLogger method onTracksChanged.
@Override
public void onTracksChanged(EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
MappedTrackInfo mappedTrackInfo = trackSelector != null ? trackSelector.getCurrentMappedTrackInfo() : null;
if (mappedTrackInfo == null) {
logd(eventTime, "tracks", "[]");
return;
}
logd("tracks [" + getEventTimeString(eventTime));
// Log tracks associated to renderers.
int rendererCount = mappedTrackInfo.getRendererCount();
for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
TrackSelection trackSelection = trackSelections.get(rendererIndex);
if (rendererTrackGroups.length == 0) {
logd(" " + mappedTrackInfo.getRendererName(rendererIndex) + " []");
} else {
logd(" " + mappedTrackInfo.getRendererName(rendererIndex) + " [");
for (int groupIndex = 0; groupIndex < rendererTrackGroups.length; groupIndex++) {
TrackGroup trackGroup = rendererTrackGroups.get(groupIndex);
String adaptiveSupport = getAdaptiveSupportString(trackGroup.length, mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, /* includeCapabilitiesExceededTracks= */
false));
logd(" Group:" + trackGroup.id + ", adaptive_supported=" + adaptiveSupport + " [");
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
@Capabilities int capabilities = mappedTrackInfo.getCapabilities(rendererIndex, groupIndex, trackIndex);
String formatSupport = getFormatSupportString(getFormatSupport(capabilities));
String hardwareAccelerationSupport = getHardwareAccelerationSupport(capabilities) == HARDWARE_ACCELERATION_SUPPORTED ? ", accelerated=YES" : "";
String decoderSupport = getDecoderSupport(capabilities) == DECODER_SUPPORT_FALLBACK ? ", fallback=YES" : "";
logd(" " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport + hardwareAccelerationSupport + decoderSupport);
}
logd(" ]");
}
// Log metadata for at most one of the tracks selected for the renderer.
if (trackSelection != null) {
for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
if (metadata != null) {
logd(" Metadata [");
printMetadata(metadata, " ");
logd(" ]");
break;
}
}
}
logd(" ]");
}
}
// Log tracks not associated with a renderer.
TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
if (unassociatedTrackGroups.length > 0) {
logd(" Unmapped [");
for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
logd(" Group:" + groupIndex + " [");
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(false);
String formatSupport = getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
logd(" " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
}
logd(" ]");
}
logd(" ]");
}
logd("]");
}
use of com.google.android.exoplayer2.util.Log in project DistributedFractalNetwork by Budder21.
the class FractalEditor method initialize.
/**
* Initializes the menus and fractal. Adds the various action listeners to all the GUI components. Constructs most of the
* GUI logic
*
* @author David
*
* @throws FileNotFoundException
* @throws AWTException
*/
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public void initialize() throws FileNotFoundException, AWTException {
// initializing stuff
Layer.initializeFractalRegistry();
File fractalDirectory = new File(Constants.FRACTAL_FILEPATH);
if (!fractalDirectory.exists()) {
fractalDirectory.mkdirs();
try {
fractalDirectory.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
}
fractal = new RenderManager();
selectedLayer = fractal.getLayers().get(0);
MenuBar menu = new MenuBar();
SwingNode fractalEditor = new SwingNode();
parameters = new TreeView();
layers = new TreeView();
VBox trees = new VBox();
trees.minHeightProperty().bind(bp.minHeightProperty().subtract(menu.minHeightProperty()));
trees.minWidthProperty().bind(bp.minWidthProperty().divide(6));
trees.setAlignment(Pos.CENTER);
Button render = new Button("Update");
render.setFont(new Font("Ariel", 36));
// TODO: change color of update button
render.minWidthProperty().bind(trees.minWidthProperty());
fractalView = new ImageView();
fractalView.setOnMouseClicked(e -> {
Point p = new Point(e.getScreenX(), e.getScreenY() - 52);
double screenDistX = fractalView.getFitWidth() / 2 - p.x;
double screenDistY = fractalView.getFitHeight() / 2 - p.y;
double realDistX = -screenDistX * fractal.getRealResolution().x / fractal.getScreenResolution().width;
double realDistY = screenDistY * fractal.getRealResolution().y / fractal.getScreenResolution().height;
fractal.setLocation(new Point(fractal.getLocation().x + realDistX * 2, fractal.getLocation().y + realDistY * 2));
this.updateFractalImage();
});
fractalView.setOnMouseEntered(e -> {
zoom = true;
});
fractalView.setOnMouseExited(e -> {
zoom = false;
});
this.setOnKeyPressed(e -> {
if (zoom)
if (e.getCode() == KeyCode.COMMA) {
this.fractal.setZoom(this.fractal.getZoom() * 1.5);
updateFractalImage();
} else if (e.getCode() == KeyCode.PERIOD) {
this.fractal.setZoom(this.fractal.getZoom() / 1.5);
updateFractalImage();
}
});
fractalView.setOnScroll(e -> {
double zoom = e.getDeltaY() > 0 ? 1 / .9 : .9;
this.fractal.setZoom(this.fractal.getZoom() * zoom);
this.updateFractalImage();
});
this.fractal = new RenderManager();
render.setOnAction(e -> {
updateFractalImage();
});
// Fitting the image to the screen
fractalView.fitWidthProperty().bind(bp.minWidthProperty().subtract(trees.minWidthProperty()));
fractalView.fitHeightProperty().bind(bp.heightProperty().subtract(menu.minHeightProperty()).subtract(220));
{
// Fitting gradientEditor to full screen
Dimension p = new Dimension((int) (Toolkit.getDefaultToolkit().getScreenSize().width * 0.75), 200);
System.out.println("Gradient Dimensions: " + p);
gradient = new Window(p, 50, this.fractal.getLayers().get(0));
}
{
// Tree Stuff
parameters.setRoot(new TreeItem());
parameters.getRoot().setExpanded(true);
parameters.setShowRoot(false);
parameters.setEditable(true);
// TODO if need click for params
/**
* parameters.setOnMouseClicked(new EventHandler<MouseEvent>(){
*
* @Override public void handle(MouseEvent event) { // TODO
* Auto-generated method stub
* if(event.getClickCount()==2){
* System.out.println("boop"); updateParams(); } }
*
* });
*/
parameters.setCellFactory(new Callback<TreeView, TreeCell<MetaParam>>() {
@Override
public TreeCell call(TreeView param) {
StringConverter s = new StringConverter() {
@Override
public String toString(Object object) {
return object.toString();
}
@Override
public Object fromString(String string) {
int index = string.indexOf(":");
if (!string.substring(index + 1, index + 2).equals(" "))
string = string.substring(0, index + 1) + " " + string.substring(index + 1);
Parameters params = new Parameters();
for (Object o : parameters.getRoot().getChildren()) {
TreeItem i = (TreeItem) o;
String msg = i.getValue().toString();
if (param.getSelectionModel().getSelectedItem().equals(o))
msg = string;
String key = msg.substring(0, msg.indexOf(":"));
String value = msg.substring(msg.indexOf(":") + 2);
params.put(key, value);
}
getSelectedLayer().setParameters(params);
updateFractalImage();
return new MetaParam(string.substring(0, string.indexOf(": ")), string.substring(string.indexOf(": ") + 2));
}
};
return new TextFieldTreeCell<MetaParam>(s) {
@Override
public void updateItem(MetaParam item, boolean empty) {
super.updateItem(item, empty);
}
};
}
});
layers.setRoot(new TreeItem());
layers.getRoot().setExpanded(true);
layers.setShowRoot(false);
// layers.setEditable(true);
// Use a custom callback to determine the style of the tree item
layers.setCellFactory(new Callback<TreeView, TreeCell>() {
@Override
public TreeCell call(TreeView param) {
return new CheckBoxTreeCell() {
@Override
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
// empty
if (empty) {
setGraphic(null);
setText(null);
// Otherwise if it's not representation as an
// item of the tree
// is not a CheckBoxTreeItem, remove the
// checkbox item
} else if (!(getTreeItem() instanceof CheckBoxTreeItem)) {
BufferedImage image;
try {
image = ImageIO.read(new File("textures\\plusButton.png"));
Image plusImage = SwingFXUtils.toFXImage(image, null);
ImageView plusView = new ImageView(plusImage);
plusView.setFitHeight(16);
plusView.setFitWidth(16);
setGraphic(plusView);
} catch (IOException e) {
e.printStackTrace();
}
}
setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("wofenh");
layers.getRoot().getChildren().remove(mouseEvent.getSource());
layers.layout();
}
});
}
};
}
});
TreeItem add = new TreeItem();
layerIndex = 1;
CheckBoxTreeItem item = getNewTreeItem();
layers.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
if (mouseEvent.getClickCount() == 1) {
if (layers.getSelectionModel().getSelectedItem() != add) {
updateParams();
}
if (layers.getSelectionModel().getSelectedItem() == add) {
CheckBoxTreeItem i = getNewTreeItem();
layers.getRoot().getChildren().add(0, i);
fractal.addLayer("HistogramLayer");
fractal.getLayers().get(fractal.getLayers().size() - 1).setName("Layer " + layerIndex);
updateFractalImage();
}
}
if (mouseEvent.getClickCount() == 2) {
if (layers.getSelectionModel().getSelectedItem() == add) {
} else {
((TreeItem) layers.getSelectionModel().getSelectedItem()).setValue(GradientMenus.displayLayerMenu((TreeItem<MetaLayer>) layers.getSelectionModel().getSelectedItem()));
MetaLayer meta = ((MetaLayer) ((TreeItem) layers.getSelectionModel().getSelectedItem()).getValue());
int index = layers.getRoot().getChildren().size() - 2 - layers.getRoot().getChildren().indexOf(layers.getSelectionModel().getSelectedItem());
Layer l = fractal.getLayers().get(index);
if (meta.isDelete()) {
fractal.getLayers().remove(index);
updateFractalImage();
layers.getRoot().getChildren().remove(layers.getSelectionModel().getSelectedItem());
layerIndex--;
return;
} else if (!meta.getType().equals(l.getClass().getSimpleName())) {
Layer newLayer = Layer.getLayerByType(meta.getType());
newLayer.init(l.getPalette(), index + 1);
l = newLayer;
fractal.getLayers().set(index, newLayer);
fractal.update();
updateParams();
}
l.setOpacity(meta.getOpacity());
fractal.getLayers().get(index).setName(meta.getName());
updateFractalImage();
}
} else if (mouseEvent.getClickCount() == 1 && layers.getSelectionModel().getSelectedItem() != add) {
int index = layers.getRoot().getChildren().size() - 2 - layers.getRoot().getChildren().indexOf(layers.getSelectionModel().getSelectedItem());
Layer l = fractal.getLayers().get(index);
gradient.updateLayer(l);
}
}
});
// TODO LAYER UP LAYER DOWN
layers.addEventFilter(KeyEvent.KEY_RELEASED, e -> {
if (e.getCode() == KeyCode.RIGHT) {
int index = this.fractal.getLayers().indexOf(getSelectedLayer());
moveUp((TreeItem) layers.getSelectionModel().getSelectedItem());
if (index < this.fractal.getNumLayers() - 1)
this.fractal.getLayers().add(index + 1, this.fractal.getLayers().remove(index));
}
if (e.getCode() == KeyCode.LEFT) {
moveDown((TreeItem) layers.getSelectionModel().getSelectedItem());
int index = this.fractal.getLayers().indexOf(getSelectedLayer());
if (index > 0)
this.fractal.getLayers().add(index - 1, this.fractal.getLayers().remove(index));
}
});
layers.getRoot().getChildren().addAll(item, add);
}
{
// This is the menu stuff
Menu network = new Menu("Network");
Menu fractal = new Menu("Fractal");
Menu system = new Menu("System");
MenuItem newNet = new MenuItem("Create New Network");
MenuItem viewNetLog = new MenuItem("View Network Log");
MenuItem viewNet = new MenuItem("View Network");
MenuItem endNet = new MenuItem("Close Network");
newNet.setOnAction(e -> {
NetworkCreationTool createNet = new NetworkCreationTool();
if (createNet.createNetwork()) {
this.network = createNet.getServer();
this.network.init(log);
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Network Message");
alert.setHeaderText(null);
alert.setContentText("Network succesfully created.");
viewNet.setDisable(false);
endNet.setDisable(false);
newNet.setDisable(true);
viewNetLog.setDisable(false);
alert.showAndWait();
}
});
viewNet.setDisable(true);
endNet.setDisable(true);
viewNetLog.setDisable(true);
viewNet.setOnAction(e -> {
Display display = new Display(this.network);
this.network.setDisplay(display);
display.updateNetworkView(this.network.getChildren(), this.network.getUncompletedJobs());
});
endNet.setOnAction(e -> {
// TODO: kill won't stop network without getting a response from
// all clients
this.network.kill();
viewNet.setDisable(true);
endNet.setDisable(true);
viewNetLog.setDisable(true);
newNet.setDisable(false);
});
viewNetLog.setOnAction(e -> {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Network Log");
alert.setHeaderText(null);
alert.setContentText(this.network.getLog().getLog());
alert.showAndWait();
});
network.getItems().addAll(newNet, viewNet, viewNetLog, endNet);
MenuItem newFract = new MenuItem("New Fractal");
newFract.setOnAction(e -> {
layerIndex = 1;
this.fractal = new RenderManager();
gradient.updateLayer(this.fractal.getLayers().get(0));
System.out.println(this.fractal.getLayers().get(0));
deleteLayers();
CheckBoxTreeItem i = getNewTreeItem();
layers.getRoot().getChildren().add(0, i);
this.updateFractalImage();
});
MenuItem openFract = new MenuItem("Open Fractal");
openFract.setOnAction(e -> {
FileChooser chooser = new FileChooser();
chooser.setTitle("Open Fractal");
chooser.setInitialDirectory(new File("fractals"));
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("Fractals (*.fractal)", "*.fractal");
chooser.getExtensionFilters().add(filter);
File f = chooser.showOpenDialog(null);
this.fractal = new RenderManager(f);
gradient.updateLayer(this.fractal.getLayers().get(0));
deleteLayers();
for (int k = 0; k < this.fractal.getLayers().size(); k++) {
Layer l = this.fractal.getLayers().get(k);
CheckBoxTreeItem i = getNewTreeItem();
MetaLayer meta = (MetaLayer) (i.getValue());
meta.setName(l.getName());
meta.setOpacity(l.getOpacity());
meta.setType(l.getClass().getSimpleName());
layers.getRoot().getChildren().add(0, i);
}
this.updateFractalImage();
});
MenuItem saveFract = new MenuItem("Save Fractal");
saveFract.setOnAction(e -> {
this.fractal.saveFractal();
});
MenuItem saveFractAs = new MenuItem("Save Fractal As");
saveFractAs.setOnAction(e -> {
this.fractal.saveFractalAs();
});
MenuItem exportFract = new MenuItem("Export Fractal");
exportFract.setOnAction(e -> {
ExportImageTool export = new ExportImageTool();
export.exportImage(this.fractal);
});
fractal.getItems().addAll(newFract, openFract, saveFract, saveFractAs, exportFract);
MenuItem newLayer = new MenuItem("New Layer Type");
newLayer.setOnAction(e -> {
RegisterLayerTool register = new RegisterLayerTool();
register.registerLayer();
Layer.registerLayer(register.getFile());
});
MenuItem help = new MenuItem("Help");
help.setOnAction(e -> {
ExpandableMenu.displayInformation("Help", "Instructions:", getHelpText());
});
system.getItems().addAll(newLayer, help);
menu.getMenus().addAll(fractal);
menu.getMenus().addAll(network);
menu.getMenus().addAll(system);
}
VBox center = new VBox();
center.getChildren().addAll(fractalView, fractalEditor);
trees.getChildren().addAll(parameters, layers, render);
bp.setCenter(center);
bp.setRight(trees);
// This is where the menu is located on the border pane
bp.setTop(menu);
bp.minWidthProperty().bind(this.widthProperty());
bp.minHeightProperty().bind(this.heightProperty());
render.minHeightProperty().bind(trees.minHeightProperty().subtract(fractalView.fitHeightProperty()));
fractalEditor.setContent(gradient);
fractalEditor.minHeight(200);
updateParams(0);
}
use of com.google.android.exoplayer2.util.Log in project ExoPlayer by google.
the class EventLogger method onTracksChanged.
@Override
public void onTracksChanged(TrackGroupArray ignored, TrackSelectionArray trackSelections) {
MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo == null) {
Log.d(TAG, "Tracks []");
return;
}
Log.d(TAG, "Tracks [");
// Log tracks associated to renderers.
for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.length; rendererIndex++) {
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
TrackSelection trackSelection = trackSelections.get(rendererIndex);
if (rendererTrackGroups.length > 0) {
Log.d(TAG, " Renderer:" + rendererIndex + " [");
for (int groupIndex = 0; groupIndex < rendererTrackGroups.length; groupIndex++) {
TrackGroup trackGroup = rendererTrackGroups.get(groupIndex);
String adaptiveSupport = getAdaptiveSupportString(trackGroup.length, mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, false));
Log.d(TAG, " Group:" + groupIndex + ", adaptive_supported=" + adaptiveSupport + " [");
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
String formatSupport = getFormatSupportString(mappedTrackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex));
Log.d(TAG, " " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
}
Log.d(TAG, " ]");
}
// Log metadata for at most one of the tracks selected for the renderer.
if (trackSelection != null) {
for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
if (metadata != null) {
Log.d(TAG, " Metadata [");
printMetadata(metadata, " ");
Log.d(TAG, " ]");
break;
}
}
}
Log.d(TAG, " ]");
}
}
// Log tracks not associated with a renderer.
TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnassociatedTrackGroups();
if (unassociatedTrackGroups.length > 0) {
Log.d(TAG, " Renderer:None [");
for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
Log.d(TAG, " Group:" + groupIndex + " [");
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(false);
String formatSupport = getFormatSupportString(RendererCapabilities.FORMAT_UNSUPPORTED_TYPE);
Log.d(TAG, " " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
}
Log.d(TAG, " ]");
}
Log.d(TAG, " ]");
}
Log.d(TAG, "]");
}
use of com.google.android.exoplayer2.util.Log in project DistributedFractalNetwork by Budder21.
the class Main method start.
@Override
public void start(Stage primaryStage) {
try {
Log log = new Log();
log.setLogLevel(Log.LEVEL_LOG);
log.setPrintLevel(Log.LEVEL_LOG);
log.setPrintStream(System.out);
// Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
primaryStage.setTitle("Fractal Editor");
FractalEditor scene = new FractalEditor(log);
primaryStage.setOnCloseRequest(e -> {
System.exit(0);
});
primaryStage.setScene(scene);
primaryStage.centerOnScreen();
primaryStage.setMaximized(true);
scene.initialize();
primaryStage.show();
scene.gradient.repaint();
primaryStage.minWidthProperty().bind(scene.heightProperty().multiply(2));
primaryStage.minHeightProperty().bind(scene.widthProperty().divide(2));
scene.updateFractalImage();
Thread t = null;
t = new Thread(() -> {
try {
t.sleep(200);
scene.gradient.repaint();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
t.start();
/* BorderPane root = new BorderPane();
Scene scene = new Scene(root,400,400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();*/
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations