-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MediaPlayer: Add GUI to open network streams
- Loading branch information
Showing
13 changed files
with
172 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright 2016 Dario Casalinuovo. All rights reserved. | ||
* Distributed under the terms of the MIT License. | ||
* | ||
*/ | ||
|
||
|
||
#include "NetworkStreamWin.h" | ||
|
||
#include <Alert.h> | ||
#include <Button.h> | ||
#include <Catalog.h> | ||
#include <LayoutBuilder.h> | ||
|
||
#include "MainApp.h" | ||
|
||
|
||
#undef B_TRANSLATION_CONTEXT | ||
#define B_TRANSLATION_CONTEXT "MediaPlayer-NetworkStream" | ||
|
||
|
||
enum { | ||
M_OPEN_URL = 0, | ||
M_CANCEL | ||
}; | ||
|
||
|
||
NetworkStreamWin::NetworkStreamWin(BMessenger target) | ||
: | ||
BWindow(BRect(0, 0, 300, 100), "Open Network Stream", | ||
B_TITLED_WINDOW, B_NOT_RESIZABLE), | ||
fTarget(target) | ||
{ | ||
fTextControl = new BTextControl("InputControl", | ||
"Insert URL", NULL, NULL); | ||
|
||
BLayoutBuilder::Group<>(this, B_VERTICAL) | ||
.SetInsets(0, 0, 0, 0) | ||
.Add(fTextControl) | ||
.AddGroup(B_HORIZONTAL) | ||
.Add(new BButton("Ok", new BMessage(M_OPEN_URL))) | ||
.Add(new BButton("Cancel", new BMessage(M_CANCEL))) | ||
.End() | ||
.End(); | ||
} | ||
|
||
|
||
NetworkStreamWin::~NetworkStreamWin() | ||
{ | ||
} | ||
|
||
|
||
void | ||
NetworkStreamWin::MessageReceived(BMessage* message) | ||
{ | ||
switch(message->what) { | ||
case M_OPEN_URL: | ||
{ | ||
BUrl url(fTextControl->Text()); | ||
if (!url.IsValid()) { | ||
BAlert* alert = new BAlert(B_TRANSLATE("Bad URL"), | ||
B_TRANSLATE("Invalid URL inserted!"), | ||
B_TRANSLATE("OK")); | ||
alert->Go(); | ||
return; | ||
} | ||
|
||
BMessage archivedUrl; | ||
url.Archive(&archivedUrl); | ||
|
||
BMessage msg(M_URL_RECEIVED); | ||
msg.AddMessage("mediaplayer:url", &archivedUrl); | ||
fTarget.SendMessage(&msg); | ||
|
||
Quit(); | ||
break; | ||
} | ||
|
||
case M_CANCEL: | ||
Quit(); | ||
break; | ||
|
||
default: | ||
BWindow::MessageReceived(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2016 Dario Casalinuovo. All rights reserved. | ||
* Distributed under the terms of the MIT License. | ||
* | ||
*/ | ||
#ifndef __NETWORK_STREAM_WIN_H | ||
#define __NETWORK_STREAM_WIN_H | ||
|
||
|
||
#include <Messenger.h> | ||
#include <TextControl.h> | ||
#include <Window.h> | ||
|
||
|
||
class NetworkStreamWin : public BWindow | ||
{ | ||
public: | ||
NetworkStreamWin(BMessenger target); | ||
virtual ~NetworkStreamWin(); | ||
|
||
virtual void MessageReceived(BMessage* message); | ||
|
||
private: | ||
BMessenger fTarget; | ||
BTextControl* fTextControl; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.