MediaPlayer: Add GUI to open network streams
This commit is contained in:
@@ -112,6 +112,7 @@ Application MediaPlayer :
|
|||||||
InfoWin.cpp
|
InfoWin.cpp
|
||||||
MainApp.cpp
|
MainApp.cpp
|
||||||
MainWin.cpp
|
MainWin.cpp
|
||||||
|
NetworkStreamWin.cpp
|
||||||
VideoView.cpp
|
VideoView.cpp
|
||||||
|
|
||||||
: be game media tracker translation textencoding [ TargetLibstdc++ ]
|
: be game media tracker translation textencoding [ TargetLibstdc++ ]
|
||||||
@@ -128,6 +129,7 @@ DoCatalogs MediaPlayer :
|
|||||||
MainApp.cpp
|
MainApp.cpp
|
||||||
MainWin.cpp
|
MainWin.cpp
|
||||||
MovePLItemsCommand.cpp
|
MovePLItemsCommand.cpp
|
||||||
|
NetworkStreamWin.cpp
|
||||||
PeakView.cpp
|
PeakView.cpp
|
||||||
PlaylistItem.cpp
|
PlaylistItem.cpp
|
||||||
PlaylistWindow.cpp
|
PlaylistWindow.cpp
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ enum {
|
|||||||
M_OPEN_PANEL_RESULT = 'oprs',
|
M_OPEN_PANEL_RESULT = 'oprs',
|
||||||
M_SAVE_PANEL_RESULT = 'sprs',
|
M_SAVE_PANEL_RESULT = 'sprs',
|
||||||
|
|
||||||
M_OPEN_PREVIOUS_PLAYLIST = 'oppp'
|
M_OPEN_PREVIOUS_PLAYLIST = 'oppp',
|
||||||
|
|
||||||
|
M_URL_RECEIVED = 'urrc'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <Language.h>
|
#include <Language.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
#include "DurationToString.h"
|
#include "DurationToString.h"
|
||||||
#include "FilePlaylistItem.h"
|
#include "FilePlaylistItem.h"
|
||||||
#include "MainApp.h"
|
#include "MainApp.h"
|
||||||
|
#include "NetworkStreamWin.h"
|
||||||
#include "PeakView.h"
|
#include "PeakView.h"
|
||||||
#include "PlaylistItem.h"
|
#include "PlaylistItem.h"
|
||||||
#include "PlaylistObserver.h"
|
#include "PlaylistObserver.h"
|
||||||
@@ -76,6 +78,7 @@ int MainWin::sNoVideoWidth = MIN_WIDTH;
|
|||||||
enum {
|
enum {
|
||||||
M_DUMMY = 0x100,
|
M_DUMMY = 0x100,
|
||||||
M_FILE_OPEN = 0x1000,
|
M_FILE_OPEN = 0x1000,
|
||||||
|
M_NETWORK_STREAM_OPEN,
|
||||||
M_FILE_INFO,
|
M_FILE_INFO,
|
||||||
M_FILE_PLAYLIST,
|
M_FILE_PLAYLIST,
|
||||||
M_FILE_CLOSE,
|
M_FILE_CLOSE,
|
||||||
@@ -617,8 +620,10 @@ MainWin::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
|
case M_URL_RECEIVED:
|
||||||
_RefsReceived(msg);
|
_RefsReceived(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
if (msg->HasRef("refs"))
|
if (msg->HasRef("refs"))
|
||||||
_RefsReceived(msg);
|
_RefsReceived(msg);
|
||||||
@@ -831,6 +836,15 @@ MainWin::MessageReceived(BMessage* msg)
|
|||||||
be_app->PostMessage(&appMessage);
|
be_app->PostMessage(&appMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case M_NETWORK_STREAM_OPEN:
|
||||||
|
{
|
||||||
|
BMessenger target(this);
|
||||||
|
NetworkStreamWin* win = new NetworkStreamWin(target);
|
||||||
|
win->Show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case M_FILE_INFO:
|
case M_FILE_INFO:
|
||||||
ShowFileInfo();
|
ShowFileInfo();
|
||||||
break;
|
break;
|
||||||
@@ -1499,6 +1513,10 @@ MainWin::_CreateMenu()
|
|||||||
item->SetShortcut('O', 0);
|
item->SetShortcut('O', 0);
|
||||||
fFileMenu->AddItem(item);
|
fFileMenu->AddItem(item);
|
||||||
|
|
||||||
|
item = new BMenuItem(B_TRANSLATE("Open network stream"),
|
||||||
|
new BMessage(M_NETWORK_STREAM_OPEN));
|
||||||
|
fFileMenu->AddItem(item);
|
||||||
|
|
||||||
fFileMenu->AddSeparatorItem();
|
fFileMenu->AddSeparatorItem();
|
||||||
|
|
||||||
fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("File info" B_UTF8_ELLIPSIS),
|
fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("File info" B_UTF8_ELLIPSIS),
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -45,7 +45,7 @@ ImportPLItemsCommand::ImportPLItemsCommand(Playlist* playlist,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Playlist temp;
|
Playlist temp;
|
||||||
temp.AppendRefs(refsMessage);
|
temp.AppendItems(refsMessage);
|
||||||
|
|
||||||
fNewCount = temp.CountItems();
|
fNewCount = temp.CountItems();
|
||||||
if (fNewCount <= 0)
|
if (fNewCount <= 0)
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ Playlist::RemoveListener(Listener* listener)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
|
Playlist::AppendItems(const BMessage* refsReceivedMessage, int32 appendIndex)
|
||||||
{
|
{
|
||||||
// the playlist is replaced by the refs in the message
|
// the playlist is replaced by the refs in the message
|
||||||
// or the refs are appended at the appendIndex
|
// or the refs are appended at the appendIndex
|
||||||
@@ -448,6 +448,15 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
|
|||||||
Playlist* playlist = add ? &temporaryPlaylist : this;
|
Playlist* playlist = add ? &temporaryPlaylist : this;
|
||||||
bool sortPlaylist = true;
|
bool sortPlaylist = true;
|
||||||
|
|
||||||
|
// TODO: This is not very fair, we should abstract from
|
||||||
|
// entry ref representation and support more URLs.
|
||||||
|
BMessage archivedUrl;
|
||||||
|
if (refsReceivedMessage->FindMessage("mediaplayer:url", &archivedUrl)
|
||||||
|
== B_OK) {
|
||||||
|
BUrl url(&archivedUrl);
|
||||||
|
AddItem(new UrlPlaylistItem(url));
|
||||||
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
int32 subAppendIndex = CountItems();
|
int32 subAppendIndex = CountItems();
|
||||||
for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK;
|
for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK;
|
||||||
|
|||||||
@@ -105,9 +105,10 @@ public:
|
|||||||
void RemoveListener(Listener* listener);
|
void RemoveListener(Listener* listener);
|
||||||
|
|
||||||
// support functions
|
// support functions
|
||||||
void AppendRefs(const BMessage* refsReceivedMessage,
|
void AppendItems(const BMessage* refsReceivedMessage,
|
||||||
int32 appendIndex
|
int32 appendIndex
|
||||||
= APPEND_INDEX_REPLACE_PLAYLIST);
|
= APPEND_INDEX_REPLACE_PLAYLIST);
|
||||||
|
|
||||||
static void AppendToPlaylistRecursive(const entry_ref& ref,
|
static void AppendToPlaylistRecursive(const entry_ref& ref,
|
||||||
Playlist* playlist);
|
Playlist* playlist);
|
||||||
static void AppendPlaylistToPlaylist(const entry_ref& ref,
|
static void AppendPlaylistToPlaylist(const entry_ref& ref,
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ PlaylistItem::TrackNumber() const
|
|||||||
bigtime_t
|
bigtime_t
|
||||||
PlaylistItem::Duration()
|
PlaylistItem::Duration()
|
||||||
{
|
{
|
||||||
|
printf("duration\n");
|
||||||
bigtime_t duration;
|
bigtime_t duration;
|
||||||
if (GetAttribute(ATTR_INT64_DURATION, duration) != B_OK) {
|
if (GetAttribute(ATTR_INT64_DURATION, duration) != B_OK) {
|
||||||
duration = this->_CalculateDuration();
|
duration = this->_CalculateDuration();
|
||||||
@@ -188,6 +189,7 @@ PlaylistItem::_NotifyListeners() const
|
|||||||
|
|
||||||
bigtime_t PlaylistItem::_CalculateDuration()
|
bigtime_t PlaylistItem::_CalculateDuration()
|
||||||
{
|
{
|
||||||
|
printf("calc duration\n");
|
||||||
// To be overridden in subclasses with more efficient methods
|
// To be overridden in subclasses with more efficient methods
|
||||||
TrackSupplier* supplier = GetTrackSupplier();
|
TrackSupplier* supplier = GetTrackSupplier();
|
||||||
|
|
||||||
|
|||||||
@@ -310,12 +310,12 @@ PlaylistListView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
if (message->HasRef("refs"))
|
if (message->HasRef("refs"))
|
||||||
RefsReceived(message, fDropIndex);
|
ItemsReceived(message, fDropIndex);
|
||||||
else if (message->HasPointer("list"))
|
else if (message->HasPointer("list"))
|
||||||
SimpleListView::MessageReceived(message);
|
SimpleListView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
RefsReceived(message, fDropIndex);
|
ItemsReceived(message, fDropIndex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -506,7 +506,7 @@ PlaylistListView::DrawListItem(BView* owner, int32 index, BRect frame) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistListView::RefsReceived(BMessage* message, int32 appendIndex)
|
PlaylistListView::ItemsReceived(const BMessage* message, int32 appendIndex)
|
||||||
{
|
{
|
||||||
if (fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist,
|
if (fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist,
|
||||||
message, appendIndex)) != B_OK) {
|
message, appendIndex)) != B_OK) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
BRect frame) const;
|
BRect frame) const;
|
||||||
|
|
||||||
// PlaylistListView
|
// PlaylistListView
|
||||||
void RefsReceived(BMessage* message,
|
void ItemsReceived(const BMessage* message,
|
||||||
int32 appendIndex);
|
int32 appendIndex);
|
||||||
|
|
||||||
void Randomize();
|
void Randomize();
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ PlaylistWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case M_URL_RECEIVED:
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
// Used for when we open a playlist from playlist window
|
// Used for when we open a playlist from playlist window
|
||||||
if (!message->HasInt32("append_index")) {
|
if (!message->HasInt32("append_index")) {
|
||||||
@@ -193,7 +194,7 @@ PlaylistWindow::MessageReceived(BMessage* message)
|
|||||||
// outside of the playlist!
|
// outside of the playlist!
|
||||||
int32 appendIndex;
|
int32 appendIndex;
|
||||||
if (message->FindInt32("append_index", &appendIndex) == B_OK)
|
if (message->FindInt32("append_index", &appendIndex) == B_OK)
|
||||||
fListView->RefsReceived(message, appendIndex);
|
fListView->ItemsReceived(message, appendIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ UrlPlaylistItem::UrlPlaylistItem(BUrl url)
|
|||||||
:
|
:
|
||||||
fUrl(url)
|
fUrl(url)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ UrlPlaylistItem::Instantiate(BMessage* archive)
|
|||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::Archive(BMessage* into, bool deep) const
|
UrlPlaylistItem::Archive(BMessage* into, bool deep) const
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,35 +65,40 @@ UrlPlaylistItem::SetAttribute(const Attribute& attribute, const BString& string)
|
|||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::GetAttribute(const Attribute& attribute, BString& string) const
|
UrlPlaylistItem::GetAttribute(const Attribute& attribute, BString& string) const
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
if (attribute == ATTR_STRING_NAME) {
|
||||||
|
string = fUrl.UrlString();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int32& value)
|
UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int32& value)
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::GetAttribute(const Attribute& attribute, int32& value) const
|
UrlPlaylistItem::GetAttribute(const Attribute& attribute, int32& value) const
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int64& value)
|
UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int64& value)
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::GetAttribute(const Attribute& attribute, int64& value) const
|
UrlPlaylistItem::GetAttribute(const Attribute& attribute, int64& value) const
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,21 +112,21 @@ UrlPlaylistItem::LocationURI() const
|
|||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::GetIcon(BBitmap* bitmap, icon_size iconSize) const
|
UrlPlaylistItem::GetIcon(BBitmap* bitmap, icon_size iconSize) const
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::MoveIntoTrash()
|
UrlPlaylistItem::MoveIntoTrash()
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UrlPlaylistItem::RestoreFromTrash()
|
UrlPlaylistItem::RestoreFromTrash()
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user